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

This commit is contained in:
rex 2018-12-17 12:55:24 +08:00 committed by neverland
parent 9268700d0c
commit e903a3b974
3 changed files with 74 additions and 66 deletions

View File

@ -3,12 +3,13 @@
.van-card { .van-card {
color: @text-color; color: @text-color;
height: 100px; display: flex;
font-size: 12px; font-size: 12px;
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
padding: 5px 15px 5px 115px; padding: 5px 15px;
background-color: @background-color-light; background-color: @background-color-light;
flex-wrap: wrap;
&:not(:first-child) { &:not(:first-child) {
margin-top: 10px; margin-top: 10px;
@ -21,11 +22,11 @@
} }
&__thumb { &__thumb {
top: 5px; position: relative;
left: 15px;
width: 90px; width: 90px;
height: 90px; height: 90px;
position: absolute; margin-right: 10px;
flex: none;
img { img {
border: none; border: none;
@ -34,52 +35,52 @@
} }
} }
&,
&__thumb,
&__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;
.multi-ellipsis(2); .multi-ellipsis(2);
} }
&__desc { &__desc {
color: @gray-darker; color: @gray-darker;
max-height: 20px; max-height: 17px;
} }
&__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-shrink: 0; display: inline-block;
line-height: 20px;
padding-left: 10px;
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 {
@ -89,9 +90,9 @@
} }
&__footer { &__footer {
right: 15px; width: 100%;
bottom: 8px; text-align: right;
position: absolute; flex: none;
.van-button { .van-button {
margin-left: 5px; margin-left: 5px;

View File

@ -1,6 +1,7 @@
<template> <template>
<div :class="b({ center: centered })"> <div :class="b({ center: centered })">
<a <a
v-if="thumb || $slots.thumb"
:href="thumbLink" :href="thumbLink"
:class="b('thumb')" :class="b('thumb')"
> >
@ -25,28 +26,33 @@
{{ tag }} {{ tag }}
</van-tag> </van-tag>
</a> </a>
<div :class="b('content')"> <div :class="b('content')">
<div :class="b('left')"> <slot name="title">
<slot name="title"> <div
<div v-if="title"
v-if="title" :class="b('title')"
:class="b('title')" >
> {{ title }}
{{ title }} </div>
</div> </slot>
</slot> <slot name="desc">
<slot name="desc"> <div
<div v-if="desc"
v-if="desc" :class="[b('desc'), 'van-ellipsis']"
:class="[b('desc'), 'van-ellipsis']" >
> {{ desc }}
{{ desc }} </div>
</div> </slot>
</slot> <slot name="tags" />
<slot name="tags" />
</div> <div class="van-card__bottom">
<div :class="b('right')"> <div
<div v-if="isDef(price)">{{ currency }} {{ price }}</div> v-if="isDef(price)"
:class="b('price')"
>
{{ currency }} {{ price }}
</div>
<div <div
v-if="isDef(originPrice)" v-if="isDef(originPrice)"
:class="b('origin-price')" :class="b('origin-price')"
@ -61,6 +67,7 @@
</div> </div>
</div> </div>
</div> </div>
<div <div
:class="b('footer')" :class="b('footer')"
v-if="$slots.footer" v-if="$slots.footer"

View File

@ -6,16 +6,16 @@ exports[`renders demo correctly 1`] = `
<div class="van-card"><a class="van-card__thumb"><img src="//img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg" class="van-card__img"> <div class="van-card"><a class="van-card__thumb"><img src="//img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg" class="van-card__img">
<!----></a> <!----></a>
<div class="van-card__content"> <div class="van-card__content">
<div class="van-card__left"> <div class="van-card__title">
<div class="van-card__title"> 商品标题
商品标题
</div>
<div class="van-card__desc van-ellipsis">
描述信息
</div>
</div> </div>
<div class="van-card__right"> <div class="van-card__desc van-ellipsis">
<div>¥ 2.00</div> 描述信息
</div>
<div class="van-card__bottom">
<div class="van-card__price">
¥ 2.00
</div>
<!----> <!---->
<div class="van-card__num"> <div class="van-card__num">
x 2 x 2
@ -30,16 +30,16 @@ exports[`renders demo correctly 1`] = `
标签 标签
</span></a> </span></a>
<div class="van-card__content"> <div class="van-card__content">
<div class="van-card__left"> <div class="van-card__title">
<div class="van-card__title"> 商品标题
商品标题
</div>
<div class="van-card__desc van-ellipsis">
描述信息
</div>
</div> </div>
<div class="van-card__right"> <div class="van-card__desc van-ellipsis">
<div>¥ 2.00</div> 描述信息
</div>
<div class="van-card__bottom">
<div class="van-card__price">
¥ 2.00
</div>
<div class="van-card__origin-price"> <div class="van-card__origin-price">
¥ 10.00 ¥ 10.00
</div> </div>