Skip to content

Commit fea931a

Browse files
committed
Add info about who beats who
1 parent df2a9ba commit fea931a

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

src/App.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,21 @@
44

55
position: relative;
66
}
7+
8+
.moveInfo {
9+
display: none;
10+
}
11+
12+
:has(button:hover) + .moveInfo,
13+
:has(button:focus) + .moveInfo {
14+
display: block;
15+
}
16+
17+
:has(button:hover) ~ .heading,
18+
:has(button:focus) ~ .heading {
19+
display: none;
20+
}
21+
22+
.container h1 {
23+
max-width: 40%;
24+
}

src/App.tsx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,30 @@ function App() {
5757

5858
if (playerMove == null) {
5959
return (
60-
<div className={`${styles.container} centered-container`}>
61-
<h1>Make your move!</h1>
62-
{MOVES.map((move, i) => (
63-
<MoveButton
64-
key={move}
65-
move={move}
66-
onClick={() => handleMove(move)}
67-
transform={`rotate(${
68-
i / MOVES.length
69-
}turn) translateY(-35vmin) rotate(${-i / MOVES.length}turn)`}
70-
/>
71-
))}
60+
<div
61+
className={`${styles.container} centered-container`}
62+
style={{ gap: "2vmin" }}
63+
>
64+
{MOVES.flatMap((move, i) => {
65+
const [beatsA, beatsB] = Object.keys(MOVE_CONFIG[move]);
66+
67+
return [
68+
<MoveButton
69+
key={`button:${move}`}
70+
move={move}
71+
onClick={() => handleMove(move)}
72+
transform={`rotate(${
73+
i / MOVES.length
74+
}turn) translateY(-35vmin) rotate(${-i / MOVES.length}turn)`}
75+
/>,
76+
77+
<h1 className={styles.moveInfo} key={`moveInfo:${move}`}>
78+
<strong>{capitalize(move)}</strong> beats{" "}
79+
<strong>{beatsA}</strong>&nbsp;and&nbsp;<strong>{beatsB}</strong>.
80+
</h1>,
81+
];
82+
})}
83+
<h1 className={styles.heading}>Make your move!</h1>
7284
</div>
7385
);
7486
}
@@ -104,7 +116,10 @@ function App() {
104116
})();
105117

106118
return (
107-
<div className="App-container centered-container" style={{ gap: "4vmin" }}>
119+
<div
120+
className={`${styles.container} centered-container`}
121+
style={{ gap: "4vmin" }}
122+
>
108123
<div className="centered-container" style={{ gap: "2vmin" }}>
109124
<div>
110125
You picked <strong>{playerMove}</strong>, computer picked{" "}
@@ -115,9 +130,7 @@ function App() {
115130
Wins: {wins} / Losses: {losses} / Draws: {draws}
116131
</div>
117132
</div>
118-
<button className="App-reset-button" onClick={resetGame}>
119-
Play again
120-
</button>
133+
<button onClick={resetGame}>Play again</button>
121134
</div>
122135
);
123136
}

0 commit comments

Comments
 (0)