From 75d8db409874834871fe61cbe8e0142884edf95a Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Thu, 21 Sep 2023 18:55:33 -0700 Subject: [PATCH] Improve 'Add to dictionary' UI --- ui/src/Game.tsx | 33 ++++++++++++++++++++++----------- ui/src/style.less | 9 +++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ui/src/Game.tsx b/ui/src/Game.tsx index c2bd6f0..28874d4 100644 --- a/ui/src/Game.tsx +++ b/ui/src/Game.tsx @@ -107,7 +107,6 @@ export function Game(props: { function addWordFn(word: string) { props.wasm.add_word(word); - logDispatch(
{word} was added to dictionary.
); } const [playerLetters, trayDispatch] = useReducer(movePlayableLetters, []); @@ -359,7 +358,7 @@ export function Game(props: { if (message.endsWith("is not a valid word")) { // extract out word const word = message.split(" ")[0]; - logDispatch(
{message}
); + logDispatch(); } else { logDispatch(
{message}
); } @@ -410,12 +409,24 @@ export function Game(props: { function AddWordButton(props: {word: string, addWordFn: (x: string) => void}) { const [isClicked, setIsClicked] = useState(false); - return -} \ No newline at end of file + if (!isClicked) { + return
+ {props.word} is not a valid word. + +
; + } else { + return
+ {props.word} was added to dictionary. +
; + } + +} + diff --git a/ui/src/style.less b/ui/src/style.less index 865561a..e893181 100644 --- a/ui/src/style.less +++ b/ui/src/style.less @@ -270,4 +270,13 @@ dialog { } +} + +button.add-to-dictionary { + padding: 0; + margin: 0 0 0 1em; +} + +div.log { + line-height: 1.5em; } \ No newline at end of file