1
1
import clsx from "clsx" ;
2
- import React , { ReactNode , useState } from "react" ;
2
+ import React , { ReactNode } from "react" ;
3
3
import "./CircularProgressBar.scss"
4
4
5
- type TVariant = "clockwise" | "static" | "selectable"
6
5
type TCircularProgressProps = {
7
6
children ?: ReactNode ;
8
7
className ?: string ;
@@ -13,8 +12,6 @@ type TCircularProgressProps = {
13
12
stroke ?: number ;
14
13
warning_limit ?: number ;
15
14
icon ?: ReactNode ;
16
- variant ?: TVariant ;
17
- onSelect ?: ( ) => void ;
18
15
} ;
19
16
20
17
export const CircularProgressBar = ( {
@@ -26,25 +23,14 @@ export const CircularProgressBar = ({
26
23
radius = 22 ,
27
24
stroke = 3 ,
28
25
warning_limit = 50 ,
29
- variant = "clockwise" ,
30
- onSelect // Function to be called when circle is selected
31
26
} : TCircularProgressProps ) => {
32
27
const normalizedRadius = radius - stroke / 2 ;
33
28
const circumference = normalizedRadius * 2 * Math . PI ;
34
29
const strokeDashoffset = circumference - ( progress / 100 ) * circumference ;
35
30
36
- const [ selected , setSelected ] = useState ( false ) ;
37
-
38
- const handleSelect = ( ) => {
39
- setSelected ( prev => ! prev ) ;
40
- if ( onSelect ) {
41
- onSelect ( ) ;
42
- }
43
- } ;
44
-
45
31
return (
46
32
< div className = { clsx ( "deriv-circular-progress" , className ) } >
47
- < svg height = { radius * 2 } width = { radius * 2 } onClick = { variant === "selectable" ? handleSelect : undefined } >
33
+ < svg height = { radius * 2 } width = { radius * 2 } >
48
34
{ children && (
49
35
< foreignObject x = "0" y = "0" width = { radius * 2 } height = { radius * 2 } >
50
36
< div className = { clsx ( "deriv-circular-progress__content" ) } >
@@ -57,30 +43,15 @@ export const CircularProgressBar = ({
57
43
"deriv-circular-progress--clockwise" : is_clockwise ,
58
44
"deriv-circular-progress__bar--warning" : progress <= warning_limit && progress > danger_limit ,
59
45
"deriv-circular-progress__bar--danger" : progress <= danger_limit ,
60
- "deriv-circular-progress__bar--selected" : selected && variant === "selectable"
61
46
} ) }
62
47
cx = { radius }
63
48
cy = { radius }
64
- fill = { variant === "selectable" && selected ? "blue" : "transparent" }
49
+ fill = { "transparent" }
65
50
r = { normalizedRadius }
66
51
strokeDasharray = { `${ circumference } ${ circumference } ` }
67
52
strokeWidth = { stroke }
68
- style = { variant != "clockwise" ? { strokeDashoffset : "none" } : { strokeDashoffset } }
53
+ style = { { strokeDashoffset } }
69
54
/>
70
- {
71
- variant != "clockwise" && (
72
- < circle
73
- cx = { radius }
74
- cy = { radius }
75
- r = { normalizedRadius }
76
- fill = "none"
77
- stroke = "#E8EEFC"
78
- strokeDasharray = { `${ circumference } ${ circumference } ` }
79
- strokeWidth = { stroke }
80
- style = { { strokeDashoffset : circumference - strokeDashoffset } }
81
- />
82
- )
83
- }
84
55
</ svg >
85
56
</ div >
86
57
) ;
0 commit comments