Skip to content

Commit bafb99b

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

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
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: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,26 @@ function App() {
5858
if (playerMove == null) {
5959
return (
6060
<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-
))}
61+
{MOVES.flatMap((move, i) => {
62+
const [beatsA, beatsB] = Object.keys(MOVE_CONFIG[move]);
63+
64+
return [
65+
<MoveButton
66+
key={`button:${move}`}
67+
move={move}
68+
onClick={() => handleMove(move)}
69+
transform={`rotate(${
70+
i / MOVES.length
71+
}turn) translateY(-35vmin) rotate(${-i / MOVES.length}turn)`}
72+
/>,
73+
74+
<h1 className={styles.moveInfo} key={`moveInfo:${move}`}>
75+
<strong>{capitalize(move)}</strong> beats{" "}
76+
<strong>{beatsA}</strong>&nbsp;and&nbsp;<strong>{beatsB}</strong>.
77+
</h1>,
78+
];
79+
})}
80+
<h1 className={styles.heading}>Make your move!</h1>
7281
</div>
7382
);
7483
}
@@ -104,7 +113,10 @@ function App() {
104113
})();
105114

106115
return (
107-
<div className="App-container centered-container" style={{ gap: "4vmin" }}>
116+
<div
117+
className={`${styles.container} centered-container`}
118+
style={{ gap: "4vmin" }}
119+
>
108120
<div className="centered-container" style={{ gap: "2vmin" }}>
109121
<div>
110122
You picked <strong>{playerMove}</strong>, computer picked{" "}
@@ -115,9 +127,7 @@ function App() {
115127
Wins: {wins} / Losses: {losses} / Draws: {draws}
116128
</div>
117129
</div>
118-
<button className="App-reset-button" onClick={resetGame}>
119-
Play again
120-
</button>
130+
<button onClick={resetGame}>Play again</button>
121131
</div>
122132
);
123133
}

0 commit comments

Comments
 (0)