-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathprogress-indicators.tsx
More file actions
56 lines (51 loc) · 1.54 KB
/
progress-indicators.tsx
File metadata and controls
56 lines (51 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import { useTranslationContext } from '../../context/TranslationContext';
export type ProgressIndicatorProps = {
/** Clamped 0–100 completion. */
percent: number;
};
const RING_RADIUS = 12;
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
/** Circular progress indicator with input from 0 to 100. */
export const CircularProgressIndicator = ({ percent }: ProgressIndicatorProps) => {
const { t } = useTranslationContext('CircularProgressIndicator');
const dashOffset = RING_CIRCUMFERENCE * (1 - percent / 100);
return (
<div className='str-chat__circular-progress-indicator str-chat__progress-indicator'>
<svg
aria-label={t('aria/Percent complete', { percent })}
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={percent}
data-testid='circular-progress-ring'
height='100%'
role='progressbar'
viewBox='0 0 32 32'
width='100%'
xmlns='http://www.w3.org/2000/svg'
>
<circle
cx='16'
cy='16'
fill='none'
r={RING_RADIUS}
stroke='currentColor'
strokeOpacity={0.35}
strokeWidth='2.5'
/>
<circle
cx='16'
cy='16'
fill='none'
r={RING_RADIUS}
stroke='currentColor'
strokeDasharray={RING_CIRCUMFERENCE}
strokeDashoffset={dashOffset}
strokeLinecap='round'
strokeWidth='2.5'
transform='rotate(-90 16 16)'
/>
</svg>
</div>
);
};