[Improvement] Cell: optimize flex layout (#919)

This commit is contained in:
neverland 2018-04-24 08:38:26 +08:00 committed by GitHub
parent 5d5e192d59
commit 9d623a6196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 42 deletions

View File

@ -65,7 +65,7 @@ export default {
<style lang="postcss">
.demo-list {
.van-cell {
justify-content: center;
text-align: center;
}
.page-desc {

View File

@ -1,5 +1,5 @@
<template>
<div class="van-cell-group" :class="{ 'van-hairline--top-bottom': border }">
<div :class="[b(), { 'van-hairline--top-bottom': border }]">
<slot />
</div>
</template>

View File

@ -1,37 +1,34 @@
<template>
<div
class="van-cell"
:class="{
'van-hairline': border,
'van-cell--center': center,
'van-cell--required': required,
'van-cell--clickable': isLink || clickable
}"
:class="[
b({
center,
required,
clickable: isLink || clickable
}),
{ 'van-hairline': border }
]"
@click="onClick"
>
<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>
<div class="van-cell__title" v-if="title || $slots.title">
<div v-if="title || $slots.title" :class="b('title')">
<slot name="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>
</div>
<div
class="van-cell__value"
v-if="value || $slots.default"
:class="{
'van-cell__value--link': isLink,
'van-cell__value--alone': !$slots.title && !title && !label
}"
:class="b('value', { alone: !$slots.title && !title })"
>
<slot>
<span v-text="value" />
</slot>
</div>
<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 name="extra" />
</div>

View File

@ -39,7 +39,7 @@ export default {
}
el = join(name, el, ELEMENT);
return mods ? [el, prefix(name, mods)] : el;
return mods ? [el, prefix(el, mods)] : el;
}
}
};

View File

@ -11,7 +11,7 @@
&__area {
.van-cell__title {
width: 90px;
max-width: 90px;
}
.van-cell__value {

View File

@ -1,7 +1,6 @@
@import './common/var.css';
.van-cell {
width: 100%;
display: flex;
padding: 10px 15px;
box-sizing: border-box;
@ -24,31 +23,38 @@
background-color: $white;
}
&__left-icon {
font-size: 16px;
line-height: 1.5;
margin-right: 5px;
}
&__label {
font-size: 12px;
line-height: 1.2;
color: $gray-darker;
}
&__title,
&__value {
flex: 1;
}
&__value {
overflow: hidden;
text-align: right;
vertical-align: middle;
overflow: hidden;
&--alone {
text-align: left;
}
}
&__left-icon {
font-size: 16px;
line-height: 24px;
margin-right: 5px;
}
&--link {
padding-right: 15px;
}
&__right-icon {
color: $gray-dark;
font-size: 12px;
line-height: 24px;
margin-left: 5px;
}
&--clickable {
@ -72,13 +78,4 @@
&--center {
align-items: center;
}
&__right-icon {
position: absolute;
top: 50%;
right: 15px;
transform: translateY(-50%);
color: $gray-dark;
font-size: 12px;
}
}

View File

@ -2,7 +2,7 @@
.van-field {
.van-cell__title {
min-width: 90px;
max-width: 90px;
}
.van-cell__value {

View File

@ -164,7 +164,7 @@
&__image-cell {
.van-cell__title {
width: 90px;
max-width: 90px;
}
.van-cell__value {
text-align: left;