Nav for settings

This commit is contained in:
Lynn
2022-01-17 13:34:32 +01:00
parent 670267055f
commit 62fc52b97c
2 changed files with 31 additions and 12 deletions

View File

@@ -74,17 +74,40 @@ function About() {
); );
} }
function Settings() {
return <>TODO: dark theme, hard mode, etc.</>;
}
function App() { function App() {
const [about, setAbout] = useState(false); const [page, setPage] = useState<"game" | "about" | "settings">("game");
return ( return (
<div className="App-container"> <div className="App-container">
<h1>hello wordl</h1> <h1>hello wordl</h1>
<div style={{ position: "absolute", right: 5, top: 5 }}> <div style={{ position: "absolute", right: 5, top: 5 }}>
<a href="#" onClick={() => setAbout((a) => !a)}> {page !== "game" ? (
{about ? "Close" : "About"} <a href="#" onClick={() => setPage("game")}>
</a> Close
</a>
) : (
<>
<a href="#" onClick={() => setPage("about")}>
Help
</a>
{" • "}
<a href="#" onClick={() => setPage("settings")}>
Settings
</a>
</>
)}
</div> </div>
<div style={{ position: "absolute", left: 5, top: 5 }}> <div
style={{
position: "absolute",
left: 5,
top: 5,
visibility: page === "game" ? "visible" : "hidden",
}}
>
<a <a
href="#" href="#"
onClick={() => onClick={() =>
@@ -97,8 +120,9 @@ function App() {
{seed ? "Random" : "Today's"} {seed ? "Random" : "Today's"}
</a> </a>
</div> </div>
{about && <About />} {page === "about" && <About />}
<Game maxGuesses={maxGuesses} hidden={about} /> {page === "settings" && <Settings />}
<Game maxGuesses={maxGuesses} hidden={page !== "game"} />
</div> </div>
); );
} }

View File

@@ -30,7 +30,6 @@ function Game(props: GameProps) {
const [currentGuess, setCurrentGuess] = useState<string>(""); const [currentGuess, setCurrentGuess] = useState<string>("");
const [wordLength, setWordLength] = useState(5); const [wordLength, setWordLength] = useState(5);
const [hint, setHint] = useState<string>(`Make your first guess!`); const [hint, setHint] = useState<string>(`Make your first guess!`);
const [srStatus, setSrStatus] = useState<string>(``);
const [target, setTarget] = useState(() => { const [target, setTarget] = useState(() => {
resetRng(); resetRng();
return randomTarget(wordLength); return randomTarget(wordLength);
@@ -59,7 +58,6 @@ function Game(props: GameProps) {
(guess + key.toLowerCase()).slice(0, wordLength) (guess + key.toLowerCase()).slice(0, wordLength)
); );
setHint(""); setHint("");
setSrStatus("");
} else if (key === "Backspace") { } else if (key === "Backspace") {
setCurrentGuess((guess) => guess.slice(0, -1)); setCurrentGuess((guess) => guess.slice(0, -1));
setHint(""); setHint("");
@@ -182,9 +180,6 @@ function Game(props: GameProps) {
<tbody>{tableRows}</tbody> <tbody>{tableRows}</tbody>
</table> </table>
<p role="alert">{hint || `\u00a0`}</p> <p role="alert">{hint || `\u00a0`}</p>
{/* <p role="alert" className="Game-sr-feedback">
{srStatus}
</p> */}
<Keyboard letterInfo={letterInfo} onKey={onKey} /> <Keyboard letterInfo={letterInfo} onKey={onKey} />
{seed ? ( {seed ? (
<div className="Game-seed-info"> <div className="Game-seed-info">