From b4fe39f7e16c434dfb669099c641b424ea4e0b53 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Tue, 26 Jun 2018 15:47:32 +0800 Subject: [PATCH] Button add ghost prop --- examples/routers/button.vue | 76 ++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- src/components/button/button.vue | 12 +++++++++--- src/styles/components/button.less | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/styles/custom.less | 4 ++-- src/styles/mixins/button.less | 2 +- 5 files changed, 115 insertions(+), 37 deletions(-) diff --git a/examples/routers/button.vue b/examples/routers/button.vue index c66e7fd..37c17a5 100644 --- a/examples/routers/button.vue +++ b/examples/routers/button.vue @@ -1,5 +1,25 @@ diff --git a/src/components/button/button.vue b/src/components/button/button.vue index a0da17e..81228bc 100644 --- a/src/components/button/button.vue +++ b/src/components/button/button.vue @@ -35,8 +35,9 @@ props: { type: { validator (value) { - return oneOf(value, ['primary', 'ghost', 'dashed', 'text', 'info', 'success', 'warning', 'error', 'default']); - } + return oneOf(value, ['default', 'primary', 'dashed', 'text', 'info', 'success', 'warning', 'error']); + }, + default: 'default' }, shape: { validator (value) { @@ -68,6 +69,10 @@ type: Boolean, default: false }, + ghost: { + type: Boolean, + default: false + } }, data () { return { @@ -84,7 +89,8 @@ [`${prefixCls}-${this.shape}`]: !!this.shape, [`${prefixCls}-${this.size}`]: !!this.size, [`${prefixCls}-loading`]: this.loading != null && this.loading, - [`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || !!this.customIcon || this.loading) + [`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || !!this.customIcon || this.loading), + [`${prefixCls}-ghost`]: this.ghost } ]; } diff --git a/src/styles/components/button.less b/src/styles/components/button.less index dd3c97c..5511825 100644 --- a/src/styles/components/button.less +++ b/src/styles/components/button.less @@ -60,9 +60,9 @@ } } - &-ghost { - .btn-ghost; - } + //&-ghost { + // .btn-ghost; + //} &-dashed{ .btn-dashed; @@ -125,4 +125,56 @@ &-group-vertical { .btn-group-vertical(@btn-prefix-cls); } + + // The new ghost in 3.0 + &-ghost{ + color: #fff; + background: transparent; + &:hover{ + background: transparent; + } + } + &-ghost&-dashed, &-ghost&-default{ + color: #fff; + border-color: #fff; + &:hover{ + color: tint(@primary-color, 20%); + border-color: tint(@primary-color, 20%); + } + } + &-ghost&-primary{ + color: @primary-color; + &:hover{ + color: tint(@primary-color, 20%); + background: fade(tint(@primary-color, 95%), 50%); + } + } + &-ghost&-info{ + color: @info-color; + &:hover{ + color: tint(@info-color, 20%); + background: fade(tint(@info-color, 95%), 50%); + } + } + &-ghost&-success{ + color: @success-color; + &:hover{ + color: tint(@success-color, 20%); + background: fade(tint(@success-color, 95%), 50%); + } + } + &-ghost&-warning{ + color: @warning-color; + &:hover{ + color: tint(@warning-color, 20%); + background: fade(tint(@warning-color, 95%), 50%); + } + } + &-ghost&-error{ + color: @error-color; + &:hover{ + color: tint(@error-color, 20%); + background: fade(tint(@error-color, 95%), 50%); + } + } } diff --git a/src/styles/custom.less b/src/styles/custom.less index eff7238..c5417d3 100644 --- a/src/styles/custom.less +++ b/src/styles/custom.less @@ -81,14 +81,14 @@ @btn-disable-border : @border-color-base; @btn-default-color : @text-color; -@btn-default-bg : @background-color-base; +@btn-default-bg : #fff; @btn-default-border : @border-color-base; @btn-primary-color : #fff; @btn-primary-bg : @primary-color; @btn-ghost-color : @text-color; -@btn-ghost-bg : transparent; +@btn-ghost-bg : #fff; @btn-ghost-border : @border-color-base; @btn-circle-size : 32px; diff --git a/src/styles/mixins/button.less b/src/styles/mixins/button.less index 04bbdd8..980fc79 100644 --- a/src/styles/mixins/button.less +++ b/src/styles/mixins/button.less @@ -246,7 +246,7 @@ // Text .btn-text() { - .button-variant(@btn-ghost-color, @btn-ghost-bg, transparent); + .button-variant(@btn-ghost-color, transparent, transparent); // for disabled &.disabled, -- libgit2 0.21.4