File tree 2 files changed +28
-13
lines changed
2 files changed +28
-13
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
import classNames from 'classnames' ;
3
3
import { useTransitionDuration , defaultProps } from './common' ;
4
- import { ProgressProps , GapPositionType } from './interface' ;
4
+ import type { ProgressProps , GapPositionType } from './interface' ;
5
5
6
6
let gradientSeed = 0 ;
7
7
@@ -51,7 +51,7 @@ function getPathStyles(
51
51
const len = Math . PI * 2 * radius ;
52
52
53
53
const pathStyle = {
54
- stroke : strokeColor ,
54
+ stroke : typeof strokeColor === 'string' ? strokeColor : undefined ,
55
55
strokeDasharray : `${ ( percent / 100 ) * ( len - gapDegree ) } px ${ len } px` ,
56
56
strokeDashoffset : `-${ gapDegree / 2 + ( offset / 100 ) * ( len - gapDegree ) } px` ,
57
57
transition :
@@ -93,7 +93,7 @@ const Circle: React.FC<ProgressProps> = ({
93
93
const percentList = toArray ( percent ) ;
94
94
const strokeColorList = toArray ( strokeColor ) ;
95
95
const gradient = strokeColorList . find (
96
- color => Object . prototype . toString . call ( color ) === '[object Object]' ,
96
+ ( color ) => Object . prototype . toString . call ( color ) === '[object Object]' ,
97
97
) ;
98
98
99
99
const [ paths ] = useTransitionDuration ( percentList ) ;
Original file line number Diff line number Diff line change @@ -30,14 +30,14 @@ describe('Progress', () => {
30
30
const wrapper = mount (
31
31
< >
32
32
< Line percent = { 20 } strokeLinecap = "butt" />
33
- < br />
33
+ < br />
34
34
< Line percent = { 20 } strokeLinecap = "round" />
35
- < br />
35
+ < br />
36
36
< Line percent = { 20 } strokeLinecap = "square" />
37
- </ >
37
+ </ > ,
38
38
) ;
39
39
expect ( wrapper ) . toMatchSnapshot ( ) ;
40
- } )
40
+ } ) ;
41
41
42
42
describe ( 'Circle' , ( ) => {
43
43
it ( 'change with animation' , ( ) => {
@@ -129,16 +129,31 @@ describe('Progress', () => {
129
129
strokeWidth = "6"
130
130
strokeLinecap = "round"
131
131
/>
132
- < Circle
133
- percent = { 30 }
134
- gapDegree = { 70 }
135
- gapPosition = "top"
136
- strokeWidth = "6"
137
- />
132
+ < Circle percent = { 30 } gapDegree = { 70 } gapPosition = "top" strokeWidth = "6" />
138
133
</ > ,
139
134
) ;
140
135
141
136
expect ( wrapper ) . toMatchSnapshot ( ) ;
142
137
} ) ;
138
+
139
+ // https://github.com/ant-design/ant-design/issues/30552
140
+ it ( 'should change strokeColor between gradient and color string correctly' , ( ) => {
141
+ const gradientColor = {
142
+ '0%' : '#108ee9' ,
143
+ '100%' : '#87d068' ,
144
+ } ;
145
+ const wrapper = mount ( < Circle strokeColor = { gradientColor } /> ) ;
146
+ expect ( wrapper . find ( '.rc-progress-circle-path' ) . getDOMNode ( ) . style . cssText ) . not . toContain (
147
+ 'stroke:' ,
148
+ ) ;
149
+ wrapper . setProps ( { strokeColor : '#eeeeee' } ) ;
150
+ expect ( wrapper . find ( '.rc-progress-circle-path' ) . getDOMNode ( ) . style . cssText ) . toContain (
151
+ 'stroke: #eeeeee' ,
152
+ ) ;
153
+ wrapper . setProps ( { strokeColor : gradientColor } ) ;
154
+ expect ( wrapper . find ( '.rc-progress-circle-path' ) . getDOMNode ( ) . style . cssText ) . not . toContain (
155
+ 'stroke:' ,
156
+ ) ;
157
+ } ) ;
143
158
} ) ;
144
159
} ) ;
You can’t perform that action at this time.
0 commit comments