Skip to content

Commit e73deee

Browse files
author
Pascal Wegner
committed
Show resume label for pause button
1 parent 5206545 commit e73deee

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/pwa/src/__tests__/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ describe('Home', () => {
274274
fireEvent.click(screen.getAllByRole('button', { name: /pause/i })[0]);
275275

276276
// 2, 1
277-
fireEvent.click(screen.getAllByRole('button', { name: /pause/i })[0]);
277+
fireEvent.click(screen.getAllByRole('button', { name: /resume/i })[0]);
278278
advanceOneSecond();
279279
expectCountDownFrom({
280280
minutes: 0,

packages/pwa/src/components/Counter/Counter.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TimerSubState } from '@interval-timer/core';
12
import { getMinutes, getSeconds } from 'date-fns';
23
import dynamic from 'next/dynamic';
34
import * 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

2930
export 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>

packages/pwa/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default function Home() {
138138
/>
139139
) : (
140140
<Counter
141-
state={parentState}
141+
stateValues={state.toStrings()}
142142
timeTotal={getActiveTimeTotal({
143143
breakInterval,
144144
prepareTime,

0 commit comments

Comments
 (0)