-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathTimer.js
75 lines (70 loc) · 1.66 KB
/
Timer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import * as React from 'react';
import { useReducer } from 'react';
import { faPlay, faPause } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ProgressCircle } from '../ProgressCircle';
// Import the timer machine and its initial state:
// import { ... } from './timerMachine';
export const Timer = () => {
const state = ''; // delete me - useReducer instead!
const { duration, elapsed, interval } = {
duration: 60,
elapsed: 0,
interval: 0.1,
};
return (
<div
className="timer"
data-state={state}
style={{
// @ts-ignore
'--duration': duration,
'--elapsed': elapsed,
'--interval': interval,
}}
>
<header>
<h1>Exercise 00</h1>
</header>
<ProgressCircle />
<div className="display">
<div className="label">{state}</div>
<div
className="elapsed"
onClick={() => {
// ...
}}
>
{Math.ceil(duration - elapsed)}
</div>
<div className="controls">
<button
onClick={() => {
// ...
}}
>
Reset
</button>
</div>
</div>
<div className="actions">
<button
onClick={() => {
// ...
}}
title="Pause timer"
>
<FontAwesomeIcon icon={faPause} />
</button>
<button
onClick={() => {
// ...
}}
title="Start timer"
>
<FontAwesomeIcon icon={faPlay} />
</button>
</div>
</div>
);
};