-
Notifications
You must be signed in to change notification settings - Fork 1
/
Wheel.js
62 lines (58 loc) · 1.86 KB
/
Wheel.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
import React from "react";
import { MOVE_CLOCKWISE, MOVE_COUNTERCLOCKWISE } from "../state/action-types";
import { useSelector, useDispatch } from "react-redux";
export default function Wheel() {
const wheelState = useSelector((state) => state.wheel);
const dispatch = useDispatch();
const handleMoveCounterClockwise = () => {
dispatch({ type: MOVE_COUNTERCLOCKWISE });
};
const handleMoveClockwise = () => {
dispatch({ type: MOVE_CLOCKWISE });
};
return (
<div id="wrapper">
<div id="wheel">
<div
className={`cog ${wheelState === 0 ? "active" : ""}`}
style={{ "--i": 0 }}
>
{`${wheelState === 0 ? "B" : ""}`}
</div>
<div
className={`cog ${wheelState === 1 ? "active" : ""}`}
style={{ "--i": 1 }}
>{`${wheelState === 1 ? "B" : ""}`}</div>
<div
className={`cog ${wheelState === 2 ? "active" : ""}`}
style={{ "--i": 2 }}
>{`${wheelState === 2 ? "B" : ""}`}</div>
<div
className={`cog ${wheelState === 3 ? "active" : ""}`}
style={{ "--i": 3 }}
>{`${wheelState === 3 ? "B" : ""}`}</div>
<div
className={`cog ${wheelState === 4 ? "active" : ""}`}
style={{ "--i": 4 }}
>{`${wheelState === 4 ? "B" : ""}`}</div>
<div
className={`cog ${wheelState === 5 ? "active" : ""}`}
style={{ "--i": 5 }}
>{`${wheelState === 5 ? "B" : ""}`}</div>
</div>
<div id="keypad">
<button
id="counterClockwiseBtn"
className="counterClockwiseBtn"
type="button"
onClick={handleMoveCounterClockwise}
>
Counter clockwise
</button>
<button id="clockwiseBtn" type="button" onClick={handleMoveClockwise}>
Clockwise
</button>
</div>
</div>
);
}