1+ import { TimerSubState } from '@interval-timer/core' ;
12import { getMinutes , getSeconds } from 'date-fns' ;
23import dynamic from 'next/dynamic' ;
34import * as React from 'react' ;
@@ -23,7 +24,7 @@ type CounterProps = {
2324 timeTotal : Date ;
2425 onStop : ( ) => void ;
2526 onPause : ( ) => void ;
26- state : string ;
27+ stateValues : string [ ] ;
2728} ;
2829
2930export function Counter ( {
@@ -33,7 +34,7 @@ export function Counter({
3334 rounds,
3435 onStop,
3536 onPause,
36- state ,
37+ stateValues ,
3738} : CounterProps ) {
3839 const timeLeftInSeconds =
3940 getSeconds ( timeLeft ) + getMinutes ( timeLeft ) * SECONDS_PER_MINUTE ;
@@ -46,6 +47,8 @@ export function Counter({
4647
4748 const stepLength = 1 - timeLeftAdvancedByOneInSeconds / timeTotalInSeconds ;
4849
50+ const [ parentState , childState ] = stateValues ;
51+
4952 const counterDesktop = (
5053 < div className = "h-full w-full lg:max-w-screen-xl hidden lg:flex justify-between flex-col items-center" >
5154 < div className = "w-full flex" >
@@ -66,7 +69,7 @@ export function Counter({
6669 </ div >
6770 < div className = "flex flex-col justify-center items-center" >
6871 < Arc
69- key = { state }
72+ key = { parentState }
7073 className = "absolute origin-center"
7174 progress = { factor * 100 }
7275 progressPerSecond = { stepLength * 100 }
@@ -87,7 +90,7 @@ export function Counter({
8790 className = "text-white bg-blue-600 text-2xl 2xl:text-3xl px-12 h-16 2xl:h-20 rounded-full tracking-widest ml-4"
8891 onClick = { onPause }
8992 >
90- PAUSE
93+ { childState . endsWith ( TimerSubState . RUNNING ) ? ' PAUSE' : 'RESUME' }
9194 </ button >
9295 </ div >
9396 </ div >
@@ -115,7 +118,7 @@ export function Counter({
115118 </ div >
116119 < div className = "flex flex-col justify-center items-center relative w-72 h-72 mb-16" >
117120 < Arc
118- key = { state }
121+ key = { parentState }
119122 className = "absolute origin-center"
120123 progress = { factor * 100 }
121124 progressPerSecond = { stepLength * 100 }
@@ -139,7 +142,7 @@ export function Counter({
139142 className = "text-white bg-blue-600 text-2xl px-12 h-14 rounded-full tracking-widest ml-4"
140143 onClick = { onPause }
141144 >
142- PAUSE
145+ { childState . endsWith ( TimerSubState . RUNNING ) ? ' PAUSE' : 'RESUME' }
143146 </ button >
144147 </ div >
145148 </ div >
0 commit comments