mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] Cell: optimize flex layout (#919)
This commit is contained in:
parent
5d5e192d59
commit
9d623a6196
@ -65,7 +65,7 @@ export default {
|
|||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
.demo-list {
|
.demo-list {
|
||||||
.van-cell {
|
.van-cell {
|
||||||
justify-content: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-desc {
|
.page-desc {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="van-cell-group" :class="{ 'van-hairline--top-bottom': border }">
|
<div :class="[b(), { 'van-hairline--top-bottom': border }]">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,37 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="van-cell"
|
:class="[
|
||||||
:class="{
|
b({
|
||||||
'van-hairline': border,
|
center,
|
||||||
'van-cell--center': center,
|
required,
|
||||||
'van-cell--required': required,
|
clickable: isLink || clickable
|
||||||
'van-cell--clickable': isLink || clickable
|
}),
|
||||||
}"
|
{ 'van-hairline': border }
|
||||||
|
]"
|
||||||
@click="onClick"
|
@click="onClick"
|
||||||
>
|
>
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<icon v-if="icon" class="van-cell__left-icon" :name="icon" />
|
<icon v-if="icon" :class="b('left-icon')" :name="icon" />
|
||||||
</slot>
|
</slot>
|
||||||
<div class="van-cell__title" v-if="title || $slots.title">
|
<div v-if="title || $slots.title" :class="b('title')">
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
<span v-text="title" />
|
<span v-text="title" />
|
||||||
<div class="van-cell__label" v-if="label" v-text="label" />
|
<div v-if="label" v-text="label" :class="b('label')" />
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="van-cell__value"
|
|
||||||
v-if="value || $slots.default"
|
v-if="value || $slots.default"
|
||||||
:class="{
|
:class="b('value', { alone: !$slots.title && !title })"
|
||||||
'van-cell__value--link': isLink,
|
|
||||||
'van-cell__value--alone': !$slots.title && !title && !label
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<slot>
|
<slot>
|
||||||
<span v-text="value" />
|
<span v-text="value" />
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<slot name="right-icon">
|
<slot name="right-icon">
|
||||||
<icon name="arrow" class="van-cell__right-icon" v-if="isLink" />
|
<icon v-if="isLink" :class="b('right-icon')" name="arrow" />
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="extra" />
|
<slot name="extra" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@ export default {
|
|||||||
}
|
}
|
||||||
el = join(name, el, ELEMENT);
|
el = join(name, el, ELEMENT);
|
||||||
|
|
||||||
return mods ? [el, prefix(name, mods)] : el;
|
return mods ? [el, prefix(el, mods)] : el;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
&__area {
|
&__area {
|
||||||
.van-cell__title {
|
.van-cell__title {
|
||||||
width: 90px;
|
max-width: 90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-cell__value {
|
.van-cell__value {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
@import './common/var.css';
|
@import './common/var.css';
|
||||||
|
|
||||||
.van-cell {
|
.van-cell {
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -24,31 +23,38 @@
|
|||||||
background-color: $white;
|
background-color: $white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__left-icon {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 1.5;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
color: $gray-darker;
|
color: $gray-darker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__title,
|
||||||
&__value {
|
&__value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__value {
|
||||||
|
overflow: hidden;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&--alone {
|
&--alone {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__left-icon {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 24px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
&--link {
|
&__right-icon {
|
||||||
padding-right: 15px;
|
color: $gray-dark;
|
||||||
}
|
font-size: 12px;
|
||||||
|
line-height: 24px;
|
||||||
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--clickable {
|
&--clickable {
|
||||||
@ -72,13 +78,4 @@
|
|||||||
&--center {
|
&--center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__right-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
right: 15px;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: $gray-dark;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
.van-field {
|
.van-field {
|
||||||
.van-cell__title {
|
.van-cell__title {
|
||||||
min-width: 90px;
|
max-width: 90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-cell__value {
|
.van-cell__value {
|
||||||
|
@ -164,7 +164,7 @@
|
|||||||
|
|
||||||
&__image-cell {
|
&__image-cell {
|
||||||
.van-cell__title {
|
.van-cell__title {
|
||||||
width: 90px;
|
max-width: 90px;
|
||||||
}
|
}
|
||||||
.van-cell__value {
|
.van-cell__value {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user