From 6475f534e7bf457113dcc82d94bfb7ac413f71c4 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 13 Jun 2025 23:24:49 -0700 Subject: grouping --- frontend/src/Grid.tsx | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'frontend/src/Grid.tsx') diff --git a/frontend/src/Grid.tsx b/frontend/src/Grid.tsx index b35f757..f6df3a8 100644 --- a/frontend/src/Grid.tsx +++ b/frontend/src/Grid.tsx @@ -9,28 +9,52 @@ const Tile = ({ word: GameState["words"][number]; }) => ( ); export const Grid = ({ selectWordHandler, - words, + submitSelectionHandler, + gameState, }: { selectWordHandler: (idx: number) => void; - words: GameState["words"]; -}) => ( -
- {new Array(16).fill(undefined).map((_, i) => ( + submitSelectionHandler: () => void; + gameState: GameState; +}) => { + const groups = gameState.groups.map(({ title, words }) => ( +
+
+        

{title.toUpperCase()}

+

{words.join(", ")}

+
+
+ )); + const tiles = gameState.words.map((word, i) => + !word.used ? ( selectWordHandler(i)} - word={words[i]} + word={word} key={i} /> - ))} -
-); + ) : undefined + ); + return ( +
+ {groups} +
{tiles}
+ {gameState.words.filter(({ selected }) => selected).length === 4 ? ( + + ) : undefined} +
+ ); +}; -- cgit v1.2.3-70-g09d2