[new feature] Card: update style (#1085)

This commit is contained in:
rex 2018-12-18 14:02:34 +08:00 committed by GitHub
parent 5fe840ad2b
commit 41b11bc454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 43 deletions

View File

@ -9,6 +9,15 @@
/> />
</demo-block> </demo-block>
<demo-block title="没有商品图片">
<van-card
num="2"
price="2.00"
desc="描述信息"
title="商品标题"
/>
</demo-block>
<demo-block title="高级用法"> <demo-block title="高级用法">
<van-card <van-card
num="2" num="2"
@ -22,9 +31,9 @@
<view slot="tags"> <view slot="tags">
<van-tag plain type="danger">满减</van-tag> <van-tag plain type="danger">满减</van-tag>
</view> </view>
<view slot="footer"> <view slot="footer" class="van-card__footer">
<van-button size="mini" custom-class="button">按钮</van-button> <van-button size="mini" round custom-class="button">按钮</van-button>
<van-button size="mini">按钮</van-button> <van-button size="mini" round>按钮</van-button>
</view> </view>
</van-card> </van-card>
</demo-block> </demo-block>

View File

@ -6,3 +6,7 @@
.button { .button {
margin-right: 5px; margin-right: 5px;
} }
.van-card__footer {
margin-top: 5px;
}

View File

@ -1,13 +1,14 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
.van-card { .van-card {
box-sizing: border-box;
position: relative; position: relative;
height: 100px; display: flex;
padding: 5px 15px;
font-size: 12px; font-size: 12px;
color: @text-color; color: @text-color;
padding: 5px 15px 5px 115px;
background: @background-color-light; background: @background-color-light;
box-sizing: border-box;
flex-wrap: wrap;
&--center { &--center {
align-items: center; align-items: center;
@ -15,11 +16,15 @@
} }
&__thumb { &__thumb {
position: absolute; position: relative;
top: 5px;
left: 15px;
width: 90px; width: 90px;
height: 90px; height: 90px;
margin-right: 10px;
flex: none;
&:empty {
display: none;
}
} }
&__img { &__img {
@ -27,49 +32,52 @@
height: 100%; height: 100%;
} }
&,
&__content { &__content {
display: flex; position: relative;
} height: 90px;
flex: 1;
&__content {
width: 100%;
} }
&__title, &__title,
&__desc { &__desc {
line-height: 20px; line-height: 17px;
word-break: break-all; word-break: break-all;
} }
&__title { &__title {
max-height: 40px; max-height: 34px;
font-weight: bold;
} }
&__desc { &__desc {
max-height: 20px; max-height: 17px;
color: @gray-darker; color: @gray-darker;
} }
&__left { &__bottom {
flex: 1; position: absolute;
min-width: 0; // hack for flex box ellipsis bottom: 0;
left: 0;
width: 100%;
line-height: 17px;
} }
&__right { &__price {
flex: none; display: inline-block;
padding-left: 10px; font-weight: bold;
line-height: 20px; color: @red;
text-align: right;
} }
&__origin-price { &__origin-price {
display: inline-block;
margin-left: 5px;
font-size: 10px;
color: @gray-darker; color: @gray-darker;
text-decoration: line-through; text-decoration: line-through;
} }
&__num { &__num {
color: @gray-darker; float: right;
} }
&__tag { &__tag {
@ -79,12 +87,8 @@
} }
&__footer { &__footer {
position: absolute; width: 100%;
right: 15px; text-align: right;
bottom: 5px; flex: none;
.van-button {
margin-left: 5px;
}
} }
} }

View File

@ -7,7 +7,7 @@
lazy-load="{{ lazyLoad }}" lazy-load="{{ lazyLoad }}"
class="van-card__img thumb-class" class="van-card__img thumb-class"
/> />
<slot wx:else name="thumb" /> <slot name="thumb" />
<van-tag <van-tag
wx:if="{{ tag }}" wx:if="{{ tag }}"
mark mark
@ -19,7 +19,6 @@
</view> </view>
<view class="van-card__content"> <view class="van-card__content">
<view class="van-card__left">
<view wx:if="{{ title }}" class="van-card__title van-multi-ellipsis--l2 title-class">{{ title }}</view> <view wx:if="{{ title }}" class="van-card__title van-multi-ellipsis--l2 title-class">{{ title }}</view>
<slot wx:else name="title" /> <slot wx:else name="title" />
@ -27,8 +26,8 @@
<slot wx:else name="desc" /> <slot wx:else name="desc" />
<slot name="tags" /> <slot name="tags" />
</view>
<view class="van-card__right"> <view class="van-card__bottom">
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view> <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view> <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view> <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>