11import React , { type ReactNode } from "react" ;
22
33import 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" ;
66import useLoadData from "./hooks/useLoadData" ;
77import countIf from "./util/countIf" ;
88import 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" ) } .
0 commit comments