@@ -20,6 +20,9 @@ const BarGraph = ({
20
20
isCurriculumCanceled ?: boolean ;
21
21
} ) => {
22
22
const [ showTooltip , setShowTooltip ] = useState ( false ) ;
23
+ const toggleTooltip = ( ) => {
24
+ if ( isToolTipActive ) setShowTooltip ( ( prevState ) => ! prevState ) ;
25
+ } ;
23
26
return (
24
27
< Flex
25
28
alignItems = "center"
@@ -35,17 +38,13 @@ const BarGraph = ({
35
38
{ percent > 0 ? (
36
39
< div
37
40
style = { { width : `${ 50 + ( 232 - 50 ) * ( percent / 100 ) } px` } }
38
- className = { BarGraphStyle ( {
41
+ className = { barGraphStyle ( {
39
42
type : barColor ,
40
43
} ) }
41
- onMouseEnter = { ( ) => {
42
- if ( isToolTipActive ) setShowTooltip ( true ) ;
43
- } }
44
- onMouseLeave = { ( ) => {
45
- if ( isToolTipActive ) setShowTooltip ( false ) ;
46
- } }
44
+ onMouseEnter = { toggleTooltip }
45
+ onMouseLeave = { toggleTooltip }
47
46
>
48
- < div className = { BarGraphInnerStyle } >
47
+ < div className = { barGraphInnerStyle } >
49
48
< Text className = { percentLabelStyle } color = "white" typo = "label2" >
50
49
{ percent > 0 && `${ percent } %` }
51
50
</ Text >
@@ -57,7 +56,7 @@ const BarGraph = ({
57
56
</ div >
58
57
</ div >
59
58
) : (
60
- < Text className = { ZeroPercentLabel } color = "sub" typo = "label2" >
59
+ < Text className = { zeroPercentLabelStyle } color = "sub" typo = "label2" >
61
60
0%
62
61
</ Text >
63
62
) }
@@ -98,7 +97,7 @@ const BarGraphBackgroundStyle = cva({
98
97
} ,
99
98
} ) ;
100
99
101
- const BarGraphStyle = cva ( {
100
+ const barGraphStyle = cva ( {
102
101
base : {
103
102
position : "absolute" ,
104
103
zIndex : 10 ,
@@ -128,12 +127,12 @@ const percentLabelStyle = css({
128
127
alignItems : "center" ,
129
128
} ) ;
130
129
131
- const BarGraphInnerStyle = css ( {
130
+ const barGraphInnerStyle = css ( {
132
131
position : "relative" ,
133
132
width : "100%" ,
134
133
height : "100%" ,
135
134
} ) ;
136
135
137
- const ZeroPercentLabel = css ( {
136
+ const zeroPercentLabelStyle = css ( {
138
137
marginLeft : "8px" ,
139
138
} ) ;
0 commit comments