Skip to content

Commit fa4f105

Browse files
committed
Bunch of styling
1 parent 7c82546 commit fa4f105

5 files changed

Lines changed: 36 additions & 23 deletions

File tree

src/App.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
}
1212

1313
.guess {
14-
width: min-content;
1514
min-width: 50%;
1615
max-width: 100%;
1716
text-align: center;

src/App.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
import React, { type ReactNode } from "react";
22

33
import styles from "./App.module.css";
4-
import FinishedRounds from "./FinishedRounds";
5-
import useAppState from "./hooks/useAppState";
4+
import Rounds from "./Rounds";
5+
import useAppState, { type Round } from "./hooks/useAppState";
66
import useLoadData from "./hooks/useLoadData";
77
import countIf from "./util/countIf";
88
import pluralize from "./util/pluralize";
99

10-
function Container({ children }: { children: ReactNode }) {
10+
function Container({
11+
children,
12+
finishedRounds = [],
13+
currentRound,
14+
}: {
15+
children: ReactNode;
16+
currentRound?: Round;
17+
finishedRounds?: readonly Round[];
18+
}) {
1119
return (
1220
<div className={`${styles.container} centered-container flex-col`}>
21+
<Rounds finishedRounds={finishedRounds} currentRound={currentRound} />
1322
{children}
1423
</div>
1524
);
@@ -27,7 +36,10 @@ export default function App() {
2736

2837
return (
2938
<Container>
30-
<div>Word pack is ready with {state.wordPack.length} words!</div>
39+
<div>
40+
Word pack (<strong>fruits</strong>) is ready with{" "}
41+
{pluralize(state.wordPack.length, "word")}!
42+
</div>
3143
<button onClick={() => dispatch({ type: "start-game" })}>
3244
Begin
3345
</button>
@@ -37,11 +49,10 @@ export default function App() {
3749

3850
case "in-game": {
3951
return (
40-
<Container>
41-
<FinishedRounds
42-
rounds={state.finishedRounds}
43-
currentRound={state.currentRound}
44-
/>
52+
<Container
53+
finishedRounds={state.finishedRounds}
54+
currentRound={state.currentRound}
55+
>
4556
<label className={`${styles.guessLabel} centered-container flex-col`}>
4657
<input
4758
type="text"
@@ -52,7 +63,7 @@ export default function App() {
5263
dispatch({ type: "update-guess", newGuess: ev.target.value })
5364
}
5465
/>
55-
<div>Guess the word!</div>
66+
<div>Unscramble the word!</div>
5667
</label>
5768
<div className={`${styles.buttonRow} centered-container flex-row`}>
5869
<button onClick={() => dispatch({ type: "skip-word" })}>
@@ -69,13 +80,12 @@ export default function App() {
6980
case "post-game": {
7081
const wordsGuessed = countIf(
7182
state.finishedRounds,
72-
(round) => round.didGuess
83+
(round) => round.didGuess,
7384
);
7485
const wordsSkipped = state.finishedRounds.length - wordsGuessed;
7586

7687
return (
77-
<Container>
78-
<FinishedRounds rounds={state.finishedRounds} />
88+
<Container finishedRounds={state.finishedRounds}>
7989
<div>
8090
You guessed {pluralize(wordsGuessed, "word")} and skipped{" "}
8191
{pluralize(wordsSkipped, "word")}.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.container {
2-
gap: 1.5vw;
32
height: 35%;
3+
mask-image: linear-gradient(transparent, rgb(0 0 0 / 100%));
44
overflow: hidden;
55

6-
mask-image: linear-gradient(transparent, rgb(0 0 0 / 100%));
6+
gap: 1.5vw;
77
}
88

99
/* double specificity to override other style */
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React from "react";
22

3-
import styles from "./FinishedRounds.module.css";
3+
import styles from "./Rounds.module.css";
44
import type { Round } from "./hooks/useAppState";
55
import Word from "./Word";
66

77
type Props = {
8-
rounds: readonly Round[];
8+
finishedRounds: readonly Round[];
99
currentRound?: Round;
1010
};
1111

12-
export default function FinishedRounds({ currentRound, rounds }: Props) {
12+
export default function Rounds({ currentRound, finishedRounds }: Props) {
1313
return (
1414
<div className={`${styles.container} centered-container flex-col`}>
15-
{rounds.map(({ wordUnscrambled: word, didGuess }, index) => (
15+
{finishedRounds.map(({ wordUnscrambled: word, didGuess }, index) => (
1616
<Word
1717
key={index}
1818
word={word}

src/index.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ button {
1010
-moz-osx-font-smoothing: grayscale;
1111

1212
font-size: calc(max(12px, 1.5vw));
13-
line-height: 120%;
13+
line-height: 150%;
1414
}
1515

1616
html,
@@ -52,8 +52,8 @@ code {
5252
flex-direction: row;
5353
}
5454

55-
button {
56-
background: color-mix(in oklch, cornflowerblue 25%, transparent);
55+
button,
56+
input {
5757
border: calc(max(1px, 0.3vmin)) solid black;
5858
border-radius: 1vmin;
5959

@@ -62,6 +62,10 @@ button {
6262
overflow: hidden;
6363
}
6464

65+
button {
66+
background: color-mix(in oklch, cornflowerblue 25%, transparent);
67+
}
68+
6569
button:hover,
6670
button:focus {
6771
background: color-mix(in oklch, cornflowerblue 45%, transparent);

0 commit comments

Comments
 (0)