feat: support theme variables

This commit is contained in:
rex 2019-10-23 14:36:05 +08:00 committed by GitHub
parent dd5d76dbb4
commit bac17157f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 62 deletions

View File

@ -2,14 +2,14 @@
@import '../common/style/theme.less'; @import '../common/style/theme.less';
.van-action-sheet { .van-action-sheet {
max-height: @action-sheet-max-height !important; .theme(max-height, '@action-sheet-max-height') !important;
.theme(color, '@action-sheet-item-text-color'); .theme(color, '@action-sheet-item-text-color');
&__item, &__item,
&__cancel { &__cancel {
font-size: @action-sheet-item-font-size;
line-height: @action-sheet-item-height;
text-align: center; text-align: center;
.theme(font-size, '@action-sheet-item-font-size');
.theme(line-height, '@action-sheet-item-height');
.theme(background-color, '@action-sheet-item-background'); .theme(background-color, '@action-sheet-item-background');
&--hover { &--hover {
@ -18,12 +18,12 @@
} }
&__cancel { &__cancel {
height: @action-sheet-item-height; .theme(height, '@action-sheet-item-height');
&::before { &::before {
display: block; display: block;
height: @action-sheet-cancel-padding-top;
content: ' '; content: ' ';
.theme(height, '@action-sheet-cancel-padding-top');
.theme(background-color, '@action-sheet-cancel-padding-color'); .theme(background-color, '@action-sheet-cancel-padding-color');
} }
} }
@ -37,33 +37,33 @@
} }
&__subname { &__subname {
margin-left: @padding-base; .theme(margin-left, '@padding-base');
font-size: @action-sheet-subname-font-size; .theme(font-size, '@action-sheet-subname-font-size');
.theme(color, '@action-sheet-subname-color'); .theme(color, '@action-sheet-subname-color');
} }
&__header { &__header {
font-weight: @font-weight-bold;
font-size: @action-sheet-header-font-size;
line-height: @action-sheet-header-height;
text-align: center; text-align: center;
.theme(font-weight, '@font-weight-bold');
.theme(font-size, '@action-sheet-header-font-size');
.theme(line-height, '@action-sheet-header-height');
} }
&__description { &__description {
padding: @padding-md;
color: @action-sheet-description-color;
font-size: @action-sheet-description-font-size;
line-height: @action-sheet-description-line-height;
text-align: center; text-align: center;
.theme(padding, '@padding-md');
.theme(color, '@action-sheet-description-color');
.theme(font-size, '@action-sheet-description-font-size');
.theme(line-height, '@action-sheet-description-line-height');
} }
&__close { &__close {
position: absolute !important; position: absolute !important;
top: 0; top: 0;
right: 0; right: 0;
padding: @action-sheet-close-icon-padding;
font-size: @action-sheet-close-icon-size !important;
line-height: inherit !important; line-height: inherit !important;
.theme(padding, '@action-sheet-close-icon-padding');
.theme(font-size, '@action-sheet-close-icon-size') !important;
.theme(color, '@action-sheet-close-icon-color'); .theme(color, '@action-sheet-close-icon-color');
} }
} }

View File

@ -5,18 +5,18 @@
position: relative; position: relative;
display: inline-block; display: inline-block;
box-sizing: border-box; box-sizing: border-box;
height: @button-default-height;
padding: 0; padding: 0;
font-size: @button-default-font-size;
line-height: @button-default-line-height;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
transition: opacity @animation-duration-fast;
.theme(border-radius, '@button-border-radius');
-webkit-appearance: none; -webkit-appearance: none;
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
.theme(height, '@button-default-height');
.theme(font-size, '@button-default-font-size');
.theme(line-height, '@button-default-line-height');
.theme(transition, 'opacity @animation-duration-fast');
.theme(border-radius, '@button-border-radius');
&::before { &::before {
position: absolute; position: absolute;
top: 50%; top: 50%;
@ -98,30 +98,30 @@
&--large { &--large {
width: 100%; width: 100%;
height: @button-large-height; .theme(height, '@button-large-height');
line-height: @button-large-line-height; .theme(line-height, '@button-large-line-height');
} }
&--normal { &--normal {
padding: 0 15px; padding: 0 15px;
font-size: @button-normal-font-size; .theme(font-size, '@button-normal-font-size');
} }
&--small { &--small {
min-width: @button-small-min-width; .theme(min-width, '@button-small-min-width');
height: @button-small-height; .theme(height, '@button-small-height');
padding: 0 @padding-xs; .theme(padding, '0 @padding-xs');
font-size: @button-small-font-size; .theme(font-size, '@button-small-font-size');
line-height: @button-small-line-height; .theme(line-height, '@button-small-line-height');
} }
// mini图标默认宽度50px文字不能超过4个 // mini图标默认宽度50px文字不能超过4个
&--mini { &--mini {
display: inline-block; display: inline-block;
min-width: @button-mini-min-width; .theme(min-width, '@button-mini-min-width');
height: @button-mini-height; .theme(height, '@button-mini-height');
font-size: @button-mini-font-size; .theme(font-size, '@button-mini-font-size');
line-height: @button-mini-line-height; .theme(line-height, '@button-mini-line-height');
& + .van-button--mini { & + .van-button--mini {
margin-left: 5px; margin-left: 5px;
@ -142,7 +142,7 @@
} }
&--disabled { &--disabled {
opacity: @button-disabled-opacity; .theme(opacity, '@button-disabled-opacity');
} }
&__text { &__text {

View File

@ -4,8 +4,8 @@
.van-card { .van-card {
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
padding: @card-padding; .theme(padding, '@card-padding');
font-size: @card-font-size; .theme(font-size, '@card-font-size');
.theme(color, '@card-text-color'); .theme(color, '@card-text-color');
.theme(background-color, '@card-background-color'); .theme(background-color, '@card-background-color');
@ -21,9 +21,9 @@
&__thumb { &__thumb {
position: relative; position: relative;
flex: none; flex: none;
width: @card-thumb-size; .theme(width, '@card-thumb-size');
height: @card-thumb-size; .theme(height, '@card-thumb-size');
margin-right: @padding-xs; .theme(margin-right, '@padding-xs');
&:empty { &:empty {
display: none; display: none;
@ -48,11 +48,11 @@
&__title { &__title {
font-weight: bold; font-weight: bold;
line-height: @card-title-line-height; .theme(line-height, '@card-title-line-height');
} }
&__desc { &__desc {
line-height: @card-desc-line-height; .theme(line-height, '@card-desc-line-height');
.theme(color, '@card-desc-color'); .theme(color, '@card-desc-color');
} }
@ -69,8 +69,8 @@
&__origin-price { &__origin-price {
display: inline-block; display: inline-block;
margin-left: 5px; margin-left: 5px;
font-size: @card-origin-price-font-size;
text-decoration: line-through; text-decoration: line-through;
.theme(font-size, '@card-origin-price-font-size');
.theme(color, '@card-origin-price-color'); .theme(color, '@card-origin-price-color');
} }

View File

@ -1,7 +1,8 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
@import '../common/style/theme.less';
.van-count-down { .van-count-down {
color: @count-down-text-color; .theme(color, '@count-down-text-color');
font-size: @count-down-font-size; .theme(font-size, '@count-down-font-size');
line-height: @count-down-line-height; .theme(line-height, '@count-down-line-height');
} }

View File

@ -1,16 +1,18 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
@import '../common/style/theme.less';
.van-divider { .van-divider {
display: flex; display: flex;
align-items: center; align-items: center;
margin: @divider-margin;
color: @divider-text-color;
font-size: @divider-font-size;
line-height: @divider-line-height;
border-color: @divider-border-color;
border-style: solid; border-style: solid;
border-width: 0; border-width: 0;
.theme(margin, '@divider-margin');
.theme(color, '@divider-text-color');
.theme(font-size, '@divider-font-size');
.theme(line-height, '@divider-line-height');
.theme(border-color, '@divider-border-color');
&::before, &::before,
&::after { &::after {
display: block; display: block;
@ -41,24 +43,24 @@
&--left, &--left,
&--right { &--right {
&::before { &::before {
margin-right: @divider-content-padding; .theme(margin-right, '@divider-content-padding');
} }
&::after { &::after {
margin-left: @divider-content-padding;
content: ''; content: '';
.theme(margin-left, '@divider-content-padding');
} }
} }
&--left { &--left {
&::before { &::before {
max-width: @divider-content-left-width; .theme(max-width, '@divider-content-left-width');
} }
} }
&--right { &--right {
&::after { &::after {
max-width: @divider-content-right-width; .theme(max-width, '@divider-content-right-width');
} }
} }
} }

View File

@ -1,4 +1,5 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
@import '../common/style/theme.less';
:host { :host {
flex: 1; flex: 1;
@ -7,9 +8,9 @@
.van-goods-action-button { .van-goods-action-button {
height: 36px !important; height: 36px !important;
font-weight: 500 !important; font-weight: 500 !important;
font-size: @font-size-md !important;
line-height: 34px !important; line-height: 34px !important;
border: none !important; border: none !important;
.theme(font-size, '@font-size-md') !important;
&--first { &--first {
display: block !important; display: block !important;

View File

@ -1,4 +1,5 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
@import '../common/style/theme.less';
.van-image { .van-image {
position: relative; position: relative;
@ -30,8 +31,8 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: @image-placeholder-text-color; .theme(color, '@image-placeholder-text-color');
font-size: @image-placeholder-font-size; .theme(font-size, '@image-placeholder-font-size');
background-color: @image-placeholder-background-color; .theme(background-color, '@image-placeholder-background-color');
} }
} }

View File

@ -9,17 +9,17 @@
// use pseudo element to expand click area // use pseudo element to expand click area
&::before { &::before {
position: absolute; position: absolute;
top: -@padding-xs;
right: 0; right: 0;
bottom: -@padding-xs;
left: 0; left: 0;
content: ''; content: '';
.theme(top, '-@padding-xs');
.theme(bottom, '-@padding-xs');
} }
&__bar { &__bar {
position: relative; position: relative;
border-radius: inherit; border-radius: inherit;
transition: width @animation-duration-fast; .theme(transition, 'width @animation-duration-fast');
.theme(background-color, '@blue'); .theme(background-color, '@blue');
} }