-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTimerControls.jsx
More file actions
56 lines (53 loc) · 1.58 KB
/
TimerControls.jsx
File metadata and controls
56 lines (53 loc) · 1.58 KB
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
import { FaPlay, FaPause, FaRedo, FaFlag } from "react-icons/fa";
const TimerControls = ({
isRunning,
handleStart,
handleStop,
handleReset,
handleLap,
isDisabled,
hasStarted,
}) => {
return (
<div className="mt-8 flex flex-wrap gap-7 items-center">
{/* Lap or Reset */}
<button
onClick={isRunning ? handleLap : handleReset}
disabled={!isRunning && isDisabled}
className={`flex gap-4 items-center text-base px-5 py-2.5 font-medium rounded-lg border border-secondary-light dark:border-secondary-dark
hover:shadow-md hover:bg-hover-light hover:dark:bg-hover-dark
${!isRunning && isDisabled ? "opacity-50 cursor-not-allowed" : "transition-all duration-200 ease-in-out active:scale-105 active:translate-y-0.5"}`}
>
{isRunning || !hasStarted ? (
<>
<FaFlag /> Lap
</>
) : (
<>
<FaRedo /> Reset
</>
)}
</button>
{/* Start / Stop / Resume */}
<button
onClick={isRunning ? handleStop : handleStart}
className="flex gap-4 items-center text-base px-5 py-2.5 font-medium rounded-lg bg-secondary-light dark:bg-secondary-dark text-white hover:bg-secondary-dark hover:dark:bg-secondary-light transition"
>
{isRunning ? (
<>
<FaPause /> Stop
</>
) : hasStarted ? (
<>
<FaPlay /> Resume
</>
) : (
<>
<FaPlay /> Start
</>
)}
</button>
</div>
);
};
export default TimerControls;