File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,27 @@ import {
8
8
type TimerProps = { totalTime : number ; timeLeft : number } ;
9
9
10
10
const Timer : React . FC < CircularProgressProps & TimerProps > = ( props ) => {
11
- const { totalTime, timeLeft } = props ;
11
+ const { totalTime, timeLeft, thickness , size } = props ;
12
12
const percentage = ( timeLeft / totalTime ) * 100 ;
13
+ const minutes = Math . floor ( timeLeft / 60 ) ;
14
+ const seconds = timeLeft % 60 ;
15
+ const formattedSeconds = String ( seconds ) . padStart ( 2 , "0" ) ;
16
+ const formattedMinutes = String ( minutes ) . padStart ( 2 , "0" ) ;
13
17
return (
14
18
< Box sx = { { position : "relative" , display : "inline-flex" } } >
15
19
< CircularProgress
16
20
variant = "determinate"
17
- size = { 80 }
21
+ size = { size }
18
22
value = { 100 }
19
- sx = { ( theme ) => ( { color : theme . palette . grey [ 200 ] } ) }
23
+ sx = { { opacity : 0.4 } }
24
+ thickness = { thickness }
20
25
/>
21
26
< CircularProgress
22
27
variant = "determinate"
23
- disableShrink
24
28
value = { percentage }
25
- size = { 80 }
29
+ size = { size }
26
30
sx = { { position : "absolute" } }
31
+ thickness = { thickness }
27
32
{ ...props }
28
33
/>
29
34
< Box
@@ -38,7 +43,9 @@ const Timer: React.FC<CircularProgressProps & TimerProps> = (props) => {
38
43
alignItems : "center" ,
39
44
} }
40
45
>
41
- < Typography variant = "h6" > { timeLeft } </ Typography >
46
+ < Typography variant = "h6" >
47
+ { formattedMinutes } :{ formattedSeconds }
48
+ </ Typography >
42
49
</ Box >
43
50
</ Box >
44
51
) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ const Matching: React.FC = () => {
23
23
Finding your practice partner
24
24
</ Typography >
25
25
< img src = { matching } style = { { height : 120 , width : "auto" } } />
26
- < Timer totalTime = { totalTime } timeLeft = { timeLeft } thickness = { 4 } />
26
+ < Timer
27
+ totalTime = { totalTime }
28
+ timeLeft = { timeLeft }
29
+ thickness = { 4.8 }
30
+ size = { 120 }
31
+ />
27
32
</ Stack >
28
33
</ AppMargin >
29
34
) ;
You can’t perform that action at this time.
0 commit comments