File tree Expand file tree Collapse file tree 2 files changed +28
-13
lines changed Expand file tree Collapse file tree 2 files changed +28
-13
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import classNames from 'classnames' ;
33import { useTransitionDuration , defaultProps } from './common' ;
4- import { ProgressProps , GapPositionType } from './interface' ;
4+ import type { ProgressProps , GapPositionType } from './interface' ;
55
66let gradientSeed = 0 ;
77
@@ -51,7 +51,7 @@ function getPathStyles(
5151 const len = Math . PI * 2 * radius ;
5252
5353 const pathStyle = {
54- stroke : strokeColor ,
54+ stroke : typeof strokeColor === 'string' ? strokeColor : undefined ,
5555 strokeDasharray : `${ ( percent / 100 ) * ( len - gapDegree ) } px ${ len } px` ,
5656 strokeDashoffset : `-${ gapDegree / 2 + ( offset / 100 ) * ( len - gapDegree ) } px` ,
5757 transition :
@@ -93,7 +93,7 @@ const Circle: React.FC<ProgressProps> = ({
9393 const percentList = toArray ( percent ) ;
9494 const strokeColorList = toArray ( strokeColor ) ;
9595 const gradient = strokeColorList . find (
96- color => Object . prototype . toString . call ( color ) === '[object Object]' ,
96+ ( color ) => Object . prototype . toString . call ( color ) === '[object Object]' ,
9797 ) ;
9898
9999 const [ paths ] = useTransitionDuration ( percentList ) ;
Original file line number Diff line number Diff line change @@ -30,14 +30,14 @@ describe('Progress', () => {
3030 const wrapper = mount (
3131 < >
3232 < Line percent = { 20 } strokeLinecap = "butt" />
33- < br />
33+ < br />
3434 < Line percent = { 20 } strokeLinecap = "round" />
35- < br />
35+ < br />
3636 < Line percent = { 20 } strokeLinecap = "square" />
37- </ >
37+ </ > ,
3838 ) ;
3939 expect ( wrapper ) . toMatchSnapshot ( ) ;
40- } )
40+ } ) ;
4141
4242 describe ( 'Circle' , ( ) => {
4343 it ( 'change with animation' , ( ) => {
@@ -129,16 +129,31 @@ describe('Progress', () => {
129129 strokeWidth = "6"
130130 strokeLinecap = "round"
131131 />
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" />
138133 </ > ,
139134 ) ;
140135
141136 expect ( wrapper ) . toMatchSnapshot ( ) ;
142137 } ) ;
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+ } ) ;
143158 } ) ;
144159} ) ;
You can’t perform that action at this time.
0 commit comments