mirror of
https://github.com/sigmasternchen/x86-64-wordle
synced 2025-03-15 08:09:01 +00:00
feat: Add new game button
This commit is contained in:
parent
749057040f
commit
92058e63a7
3 changed files with 21 additions and 4 deletions
|
@ -130,13 +130,19 @@ body {
|
|||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
font-size: 70px;
|
||||
padding-top: 100px;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
|
||||
.result h1 {
|
||||
font-size: 70px;
|
||||
}
|
||||
|
||||
.result button {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.result.won {
|
||||
background-color: #090;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import {CellState, sortCellStates} from "../model/CellState";
|
|||
import {Field} from "./Field";
|
||||
import {Keyboard} from "./Keyboard";
|
||||
import {Toast} from "./Toast";
|
||||
import {GameResult} from "./GameResult";
|
||||
|
||||
export const Game = ({wordLength, numberOfGuesses, correctWord, availableWords, reset}) => {
|
||||
const [gameState, setGameState] = useState(GameState.Active);
|
||||
|
@ -96,7 +97,7 @@ export const Game = ({wordLength, numberOfGuesses, correctWord, availableWords,
|
|||
/>
|
||||
<Keyboard enabled={gameState === GameState.Active} used={usedWithState} onKey={inputHandler}/>
|
||||
<Toast message={message}/>
|
||||
<div className={"result won " + (gameState === GameState.Won ? "show" : "")}>You won!</div>
|
||||
<div className={"result lost " + (gameState === GameState.Lost ? "show" : "")}>You lost!</div>
|
||||
<GameResult reset={resetHandler} show={gameState === GameState.Won} className={"won"} text={"You won!"} />
|
||||
<GameResult reset={resetHandler} show={gameState === GameState.Lost} className={"lost"} text={"You lost!"} />
|
||||
</div>
|
||||
}
|
10
src/components/GameResult.jsx
Normal file
10
src/components/GameResult.jsx
Normal file
|
@ -0,0 +1,10 @@
|
|||
import React from "react";
|
||||
|
||||
export const GameResult = ({show, className, text, reset}) => {
|
||||
|
||||
|
||||
return <div className={"result " + className + " " + (show ? "show" : "")}>
|
||||
<h1>{text}</h1>
|
||||
<button onClick={reset}>New Game</button>
|
||||
</div>
|
||||
}
|
Loading…
Reference in a new issue