(props: ProgressCircleProps)
| 8 | } |
| 9 | |
| 10 | export function ProgressCircle(props: ProgressCircleProps) { |
| 11 | // SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke. |
| 12 | let strokeWidth = 4; |
| 13 | let radius = `calc(50% - ${strokeWidth / 2}px)`; |
| 14 | |
| 15 | return ( |
| 16 | <ProgressBar |
| 17 | {...props} |
| 18 | style={composeRenderProps(props.style, style => ({ |
| 19 | ...style, |
| 20 | width: props.size || 16, |
| 21 | height: props.size || 16 |
| 22 | }))}> |
| 23 | {({percentage, isIndeterminate}) => ( |
| 24 | <> |
| 25 | <svg fill="none" width="100%" height="100%" viewBox="0 0 32 32"> |
| 26 | <circle |
| 27 | cx="50%" |
| 28 | cy="50%" |
| 29 | r={radius} |
| 30 | stroke="var(--highlight-pressed)" |
| 31 | strokeWidth={strokeWidth} |
| 32 | /> |
| 33 | <circle |
| 34 | cx="50%" |
| 35 | cy="50%" |
| 36 | r={radius} |
| 37 | stroke="var(--highlight-background)" |
| 38 | strokeWidth={strokeWidth} |
| 39 | // Normalize the path length to 100 so we can easily set stroke-dashoffset to a percentage. |
| 40 | pathLength="100" |
| 41 | // Add extra gap between dashes so 0% works in Chrome. |
| 42 | strokeDasharray="100 200" |
| 43 | strokeDashoffset={100 - (isIndeterminate || percentage == null ? 25 : percentage)} |
| 44 | strokeLinecap="round" |
| 45 | style={{ |
| 46 | rotate: '-90deg', |
| 47 | transformOrigin: 'center center' |
| 48 | }}> |
| 49 | {isIndeterminate && ( |
| 50 | <animateTransform |
| 51 | attributeName="transform" |
| 52 | type="rotate" |
| 53 | dur="0.75s" |
| 54 | values="0;360" |
| 55 | repeatCount="indefinite" |
| 56 | /> |
| 57 | )} |
| 58 | </circle> |
| 59 | </svg> |
| 60 | </> |
| 61 | )} |
| 62 | </ProgressBar> |
| 63 | ); |
| 64 | } |
nothing calls this directly
no test coverage detected