@@ -6,19 +6,26 @@ import useAppState, { type Round } from "./hooks/useAppState";
66import useLoadData from "./hooks/useLoadData" ;
77import countIf from "./util/countIf" ;
88import pluralize from "./util/pluralize" ;
9+ import Word from "./Word" ;
910
1011function Container ( {
1112 children,
12- finishedRounds = [ ] ,
1313 currentRound,
14+ finishedRounds = [ ] ,
15+ guess,
1416} : {
1517 children : ReactNode ;
1618 currentRound ?: Round ;
1719 finishedRounds ?: readonly Round [ ] ;
20+ guess ?: string ;
1821} ) {
1922 return (
2023 < div className = { `${ styles . container } centered-container flex-col` } >
21- < Rounds finishedRounds = { finishedRounds } currentRound = { currentRound } />
24+ < Rounds
25+ finishedRounds = { finishedRounds }
26+ currentRound = { currentRound }
27+ guess = { guess }
28+ />
2229 { children }
2330 </ div >
2431 ) ;
@@ -75,18 +82,35 @@ export default function App() {
7582 < Container
7683 finishedRounds = { state . finishedRounds }
7784 currentRound = { state . currentRound }
85+ guess = { state . guess }
7886 >
7987 < label className = { `${ styles . guessLabel } centered-container flex-col` } >
80- < input
81- ref = { guessInputRef }
82- type = "text"
83- autoFocus
84- className = { `${ styles . guess } word` }
85- value = { state . guess }
86- onChange = { ( ev ) =>
87- dispatch ( { type : "update-guess" , newGuess : ev . target . value } )
88- }
89- />
88+ < div className = { styles . guessContainer } >
89+ < div
90+ className = { `${ styles . guessUnderlay } word centered-container flex-col` }
91+ >
92+ < Word
93+ word = {
94+ state . guess . toUpperCase ( ) ||
95+ // Make sure the container is never empty, so that it takes some vertical space.
96+ " "
97+ }
98+ highlightInReference
99+ highlightOutOfReference
100+ referenceWord = { state . currentRound . wordScrambled }
101+ />
102+ </ div >
103+ < input
104+ ref = { guessInputRef }
105+ type = "text"
106+ autoFocus
107+ className = { `${ styles . guess } word` }
108+ value = { state . guess }
109+ onChange = { ( ev ) =>
110+ dispatch ( { type : "update-guess" , newGuess : ev . target . value } )
111+ }
112+ />
113+ </ div >
90114 < div > Unscramble the word!</ div >
91115 </ label >
92116 < div className = { `${ styles . buttonRow } centered-container flex-row` } >
0 commit comments