@@ -15,10 +15,12 @@ import {createContext, forwardRef} from 'react';
15
15
import { DOMRef , DOMRefValue } from '@react-types/shared' ;
16
16
import { getAllowedOverrides , staticColor , StylesPropWithHeight , UnsafeStyles } from './style-utils' with { type : 'macro' } ;
17
17
import { keyframes } from '../style/style-macro' with { type : 'macro' } ;
18
+ import { pxToRem } from './progress-utils' with { type : 'macro' } ;
18
19
import { style } from '../style' with { type : 'macro' } ;
19
20
import { useDOMRef } from '@react-spectrum/utils' ;
20
21
import { useSpectrumContextProps } from './useSpectrumContextProps' ;
21
22
23
+ const pxToRemDynamic = ( px : number ) : string => ( px / 16 ) + 'rem' ;
22
24
export interface ProgressCircleStyleProps {
23
25
/**
24
26
* The size of the ProgressCircle.
@@ -54,17 +56,52 @@ const track = style({
54
56
default : 'gray-300' ,
55
57
isStaticColor : 'transparent-overlay-300' ,
56
58
forcedColors : 'Background'
59
+ } ,
60
+ strokeWidth : {
61
+ default : `[${ pxToRem ( 3 ) } ]` ,
62
+ size : {
63
+ S : `[${ pxToRem ( 2 ) } ]` ,
64
+ L : `[${ pxToRem ( 4 ) } ]`
65
+ } ,
66
+ forcedColors : {
67
+ default : `[${ pxToRem ( 2 ) } ]` ,
68
+ size : {
69
+ S : `[${ pxToRem ( 1 ) } ]` ,
70
+ L : `[${ pxToRem ( 3 ) } ]`
71
+ }
72
+ }
57
73
}
58
74
} ) ;
59
75
60
76
const fill = style ( {
61
77
stroke : {
62
78
default : 'blue-900' ,
63
79
isStaticColor : 'transparent-overlay-900' ,
64
- forcedColors : 'Highlight '
80
+ forcedColors : 'ButtonText '
65
81
} ,
66
82
rotate : - 90 ,
67
- transformOrigin : 'center'
83
+ transformOrigin : 'center' ,
84
+ strokeWidth : {
85
+ default : `[${ pxToRem ( 3 ) } ]` ,
86
+ size : {
87
+ S : `[${ pxToRem ( 2 ) } ]` ,
88
+ L : `[${ pxToRem ( 4 ) } ]`
89
+ }
90
+ }
91
+ } ) ;
92
+
93
+ const hcmStroke = style ( {
94
+ stroke : {
95
+ default : 'transparent' ,
96
+ forcedColors : 'ButtonText'
97
+ } ,
98
+ strokeWidth : {
99
+ default : `[${ pxToRem ( 3 ) } ]` ,
100
+ size : {
101
+ S : `[${ pxToRem ( 2 ) } ]` ,
102
+ L : `[${ pxToRem ( 4 ) } ]`
103
+ }
104
+ }
68
105
} ) ;
69
106
70
107
export interface ProgressCircleProps extends Omit < RACProgressBarProps , 'children' | 'style' | 'valueLabel' | 'formatOptions' | 'label' | 'className' > , ProgressCircleStyleProps , UnsafeStyles {
@@ -93,8 +130,6 @@ const dashoffsetAnimation = keyframes(`
93
130
}
94
131
` ) ;
95
132
96
- let pxToRem = px => ( px / 16 ) + 'rem' ;
97
-
98
133
/**
99
134
* ProgressCircles show the progression of a system operation such as downloading, uploading, or processing, in a visual way.
100
135
* They can represent determinate or indeterminate progress.
@@ -117,7 +152,7 @@ export const ProgressCircle = /*#__PURE__*/ forwardRef(function ProgressCircle(p
117
152
}
118
153
119
154
// SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.
120
- let radius = `calc(50% - ${ pxToRem ( strokeWidth / 2 ) } )` ;
155
+ let radius = `calc(50% - ${ pxToRemDynamic ( strokeWidth / 2 ) } )` ;
121
156
let isStaticColor = ! ! staticColor ;
122
157
123
158
return (
@@ -139,14 +174,17 @@ export const ProgressCircle = /*#__PURE__*/ forwardRef(function ProgressCircle(p
139
174
cx = "50%"
140
175
cy = "50%"
141
176
r = { radius }
142
- strokeWidth = { pxToRem ( strokeWidth ) }
143
- className = { track ( { isStaticColor} ) } />
177
+ className = { hcmStroke ( { size} ) } />
178
+ < circle
179
+ cx = "50%"
180
+ cy = "50%"
181
+ r = { radius }
182
+ className = { track ( { isStaticColor, size} ) } />
144
183
< circle
145
184
cx = "50%"
146
185
cy = "50%"
147
186
r = { radius }
148
- strokeWidth = { pxToRem ( strokeWidth ) }
149
- className = { fill ( { isStaticColor} ) }
187
+ className = { fill ( { isStaticColor, size} ) }
150
188
style = { {
151
189
// These cubic-bezier timing functions were derived from the previous animation keyframes
152
190
// using a best fit algorithm, and then manually adjusted to approximate the original animation.
0 commit comments