From 65a5ed85537b7a406655bd39f7e4f5332d780a82 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 30 Nov 2020 22:51:34 +0800 Subject: [PATCH] style(Circle): add @circle-layer-color less var --- src/button/index.tsx | 4 +-- .../test/__snapshots__/demo.spec.js.snap | 4 +-- .../test/__snapshots__/index.spec.js.snap | 4 +-- src/circle/README.md | 1 + src/circle/README.zh-CN.md | 1 + src/circle/index.js | 28 ++++++++----------- src/circle/index.less | 4 +++ .../test/__snapshots__/demo.spec.js.snap | 24 ++++++++-------- .../test/__snapshots__/index.spec.js.snap | 12 ++++---- .../test/__snapshots__/demo.spec.js.snap | 4 +-- src/style/var.less | 1 + .../test/__snapshots__/index.spec.js.snap | 2 +- src/utils/constant.ts | 1 - 13 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/button/index.tsx b/src/button/index.tsx index dbcfc06ad..5048333e2 100644 --- a/src/button/index.tsx +++ b/src/button/index.tsx @@ -1,7 +1,7 @@ // Utils import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; -import { BORDER_SURROUND, WHITE } from '../utils/constant'; +import { BORDER_SURROUND } from '../utils/constant'; import { routeProps, RouteProps, functionalRoute } from '../utils/router'; // Components @@ -70,7 +70,7 @@ function Button( const style: Record = {}; if (color) { - style.color = plain ? color : WHITE; + style.color = plain ? color : 'white'; if (!plain) { // Use background instead of backgroundColor to make linear-gradient work diff --git a/src/button/test/__snapshots__/demo.spec.js.snap b/src/button/test/__snapshots__/demo.spec.js.snap index 466a4c918..6f531106b 100644 --- a/src/button/test/__snapshots__/demo.spec.js.snap +++ b/src/button/test/__snapshots__/demo.spec.js.snap @@ -75,11 +75,11 @@ exports[`renders demo correctly 1`] = ` -
diff --git a/src/calendar/test/__snapshots__/index.spec.js.snap b/src/calendar/test/__snapshots__/index.spec.js.snap index a45e76732..36899eec8 100644 --- a/src/calendar/test/__snapshots__/index.spec.js.snap +++ b/src/calendar/test/__snapshots__/index.spec.js.snap @@ -47,7 +47,7 @@ exports[`color prop when type is range 1`] = ` - @@ -100,7 +100,7 @@ exports[`color prop when type is single 1`] = ` - diff --git a/src/circle/README.md b/src/circle/README.md index c84a8590c..6ea277773 100644 --- a/src/circle/README.md +++ b/src/circle/README.md @@ -132,6 +132,7 @@ How to use: [Custom Theme](#/en-US/theme). | Name | Default Value | Description | | ------------------------ | ------------------- | ----------- | | @circle-color | `@blue` | - | +| @circle-layer-color | `@white` | - | | @circle-text-color | `@text-color` | - | | @circle-text-font-weight | `@font-weight-bold` | - | | @circle-text-font-size | `@font-size-md` | - | diff --git a/src/circle/README.zh-CN.md b/src/circle/README.zh-CN.md index d2247be9a..a56b88eb7 100644 --- a/src/circle/README.zh-CN.md +++ b/src/circle/README.zh-CN.md @@ -143,6 +143,7 @@ export default { | 名称 | 默认值 | 描述 | | ------------------------ | ------------------- | ---- | | @circle-color | `@blue` | - | +| @circle-layer-color | `@white` | - | | @circle-text-color | `@text-color` | - | | @circle-text-font-weight | `@font-weight-bold` | - | | @circle-text-font-size | `@font-size-md` | - | diff --git a/src/circle/index.js b/src/circle/index.js index 81a842909..d77c7af95 100644 --- a/src/circle/index.js +++ b/src/circle/index.js @@ -1,6 +1,5 @@ import { createNamespace, isObject, addUnit } from '../utils'; import { raf, cancelRaf } from '../utils/dom/raf'; -import { WHITE } from '../utils/constant'; const [createComponent, bem] = createNamespace('circle'); @@ -23,6 +22,7 @@ export default createComponent({ props: { text: String, color: [String, Object], + layerColor: String, strokeLinecap: String, value: { type: Number, @@ -44,10 +44,6 @@ export default createComponent({ type: [Number, String], default: 100, }, - layerColor: { - type: String, - default: WHITE, - }, strokeWidth: { type: [Number, String], default: 40, @@ -80,6 +76,14 @@ export default createComponent({ }, layerStyle() { + return { + fill: `${this.fill}`, + stroke: `${this.layerColor}`, + strokeWidth: `${this.strokeWidth}px`, + }; + }, + + hoverStyle() { const offset = (PERIMETER * this.value) / 100; return { @@ -90,14 +94,6 @@ export default createComponent({ }; }, - hoverStyle() { - return { - fill: `${this.fill}`, - stroke: `${this.layerColor}`, - strokeWidth: `${this.strokeWidth}px`, - }; - }, - gradient() { return isObject(this.color); }, @@ -164,11 +160,11 @@ export default createComponent({
{this.LinearGradient} - + diff --git a/src/circle/index.less b/src/circle/index.less index 978ac220b..40f51e015 100644 --- a/src/circle/index.less +++ b/src/circle/index.less @@ -14,6 +14,10 @@ } &__layer { + stroke: @circle-layer-color; + } + + &__hover { fill: none; stroke: @circle-color; stroke-linecap: round; diff --git a/src/circle/test/__snapshots__/demo.spec.js.snap b/src/circle/test/__snapshots__/demo.spec.js.snap index 46643df77..2512dab4e 100644 --- a/src/circle/test/__snapshots__/demo.spec.js.snap +++ b/src/circle/test/__snapshots__/demo.spec.js.snap @@ -4,22 +4,22 @@ exports[`renders demo correctly 1`] = `
- - + +
70%
- - + +
宽度定制
- - + +
颜色定制
@@ -30,20 +30,20 @@ exports[`renders demo correctly 1`] = ` - - + +
渐变色
- - + +
逆时针
- - + +
大小定制
diff --git a/src/circle/test/__snapshots__/index.spec.js.snap b/src/circle/test/__snapshots__/index.spec.js.snap index f9d78db40..3680a6ce3 100644 --- a/src/circle/test/__snapshots__/index.spec.js.snap +++ b/src/circle/test/__snapshots__/index.spec.js.snap @@ -2,21 +2,21 @@ exports[`size prop 1`] = `
- - + +
`; exports[`speed is 0 1`] = `
- - + +
`; exports[`stroke-linecap prop 1`] = `
- - + +
`; diff --git a/src/goods-action/test/__snapshots__/demo.spec.js.snap b/src/goods-action/test/__snapshots__/demo.spec.js.snap index c916dffe8..efac4d1b1 100644 --- a/src/goods-action/test/__snapshots__/demo.spec.js.snap +++ b/src/goods-action/test/__snapshots__/demo.spec.js.snap @@ -80,9 +80,9 @@ exports[`renders demo correctly 1`] = `
购物车 -
diff --git a/src/style/var.less b/src/style/var.less index 647862b8b..d9ba3ed8d 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -242,6 +242,7 @@ // Circle @circle-color: @blue; +@circle-layer-color: @white; @circle-text-color: @text-color; @circle-text-font-weight: @font-weight-bold; @circle-text-font-size: @font-size-md; diff --git a/src/submit-bar/test/__snapshots__/index.spec.js.snap b/src/submit-bar/test/__snapshots__/index.spec.js.snap index ef4265298..00935bbf9 100644 --- a/src/submit-bar/test/__snapshots__/index.spec.js.snap +++ b/src/submit-bar/test/__snapshots__/index.spec.js.snap @@ -8,7 +8,7 @@ exports[`button slot 1`] = ` exports[`button-color prop 1`] = `
-
diff --git a/src/utils/constant.ts b/src/utils/constant.ts index d9c41d913..c8ec11e4f 100644 --- a/src/utils/constant.ts +++ b/src/utils/constant.ts @@ -1,6 +1,5 @@ // color export const RED = '#ee0a24'; -export const WHITE = '#fff'; // border export const BORDER = 'van-hairline';