From 19f5ec81ba05520986a3f8fb45737a7dae407eca Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 4 Apr 2019 17:50:10 +0800 Subject: [PATCH] [improvement] Button: add less vars (#3093) --- packages/button/index.less | 46 +++++++++++++++++++------------------- packages/style/var.less | 17 ++++++++++++++ 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/packages/button/index.less b/packages/button/index.less index 15e01e134..79f11d237 100644 --- a/packages/button/index.less +++ b/packages/button/index.less @@ -1,15 +1,15 @@ @import '../style/var'; .van-button { + display: inline-block; position: relative; padding: 0; - display: inline-block; - height: 44px; - line-height: 42px; - font-size: 16px; + height: @button-default-height; + line-height: @button-default-line-height; + font-size: @button-default-font-size; + border-radius: @button-border-radius; text-align: center; box-sizing: border-box; - border-radius: @button-border-radius; -webkit-appearance: none; -webkit-text-size-adjust: 100%; @@ -42,35 +42,35 @@ &--default { color: @button-default-color; background-color: @button-default-background-color; - border: 1px solid @button-default-border-color; + border: @button-border-width solid @button-default-border-color; } &--primary { color: @button-primary-color; background-color: @button-primary-background-color; - border: 1px solid @button-primary-border-color; + border: @button-border-width solid @button-primary-border-color; } &--info { color: @button-info-color; background-color: @button-info-background-color; - border: 1px solid @button-info-border-color; + border: @button-border-width solid @button-info-border-color; } &--danger { color: @button-danger-color; background-color: @button-danger-background-color; - border: 1px solid @button-danger-border-color; + border: @button-border-width solid @button-danger-border-color; } &--warning { color: @button-warning-color; background-color: @button-warning-background-color; - border: 1px solid @button-warning-border-color; + border: @button-border-width solid @button-warning-border-color; } &--plain { - background-color: @white; + background-color: @button-plain-background-color; &.van-button--primary { color: @button-primary-background-color; @@ -91,21 +91,21 @@ &--large { width: 100%; - height: 50px; - line-height: 48px; + height: @button-large-height; + line-height: @button-large-line-height; } &--normal { padding: 0 15px; - font-size: 14px; + font-size: @button-normal-font-size; } &--small { - height: 30px; padding: 0 8px; - min-width: 60px; - font-size: 12px; - line-height: 28px; + height: @button-small-height; + min-width: @button-small-min-width; + font-size: @button-small-font-size; + line-height: @button-small-line-height; } &--loading { @@ -116,10 +116,10 @@ &--mini { display: inline-block; - width: 50px; - height: 22px; - line-height: 20px; - font-size: 10px; + height: @button-mini-height; + min-width: @button-mini-min-width; + font-size: @button-mini-font-size; + line-height: @button-mini-line-height; & + .van-button--mini { margin-left: 5px; @@ -147,7 +147,7 @@ } &--disabled { - opacity: .5; + opacity: @button-disabled-opacity; } &--round { diff --git a/packages/style/var.less b/packages/style/var.less index f0d08b97f..1af7890ad 100644 --- a/packages/style/var.less +++ b/packages/style/var.less @@ -33,6 +33,20 @@ @action-sheet-close-icon-color: @gray-dark; // Button +@button-mini-height: 22px; +@button-mini-min-width: 50px; +@button-mini-font-size: 10px; +@button-mini-line-height: 20px; +@button-small-height: 30px; +@button-small-font-size: 12px; +@button-small-min-width: 60px; +@button-small-line-height: 28px; +@button-normal-font-size: 14px; +@button-large-height: 50px; +@button-large-line-height: 48px; +@button-default-height: 44px; +@button-default-line-height: 42px; +@button-default-font-size: 16px; @button-default-color: @text-color; @button-default-background-color: @white; @button-default-border-color: @border-color; @@ -52,8 +66,11 @@ @button-bottom-action-default-background-color: @orange; @button-bottom-action-primary-color: @white; @button-bottom-action-primary-background-color: @red; +@button-border-width: 1px; @button-border-radius: 2px; @button-round-border-radius: 10em; +@button-plain-background-color: @white; +@button-disabled-opacity: .5; // Checkbox @checkbox-size: 20px;