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%);
|
transform: translate(-50%, -50%);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 70px;
|
|
||||||
padding-top: 100px;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.5s;
|
transition: opacity 0.5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result h1 {
|
||||||
|
font-size: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result button {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.result.won {
|
.result.won {
|
||||||
background-color: #090;
|
background-color: #090;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {CellState, sortCellStates} from "../model/CellState";
|
||||||
import {Field} from "./Field";
|
import {Field} from "./Field";
|
||||||
import {Keyboard} from "./Keyboard";
|
import {Keyboard} from "./Keyboard";
|
||||||
import {Toast} from "./Toast";
|
import {Toast} from "./Toast";
|
||||||
|
import {GameResult} from "./GameResult";
|
||||||
|
|
||||||
export const Game = ({wordLength, numberOfGuesses, correctWord, availableWords, reset}) => {
|
export const Game = ({wordLength, numberOfGuesses, correctWord, availableWords, reset}) => {
|
||||||
const [gameState, setGameState] = useState(GameState.Active);
|
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}/>
|
<Keyboard enabled={gameState === GameState.Active} used={usedWithState} onKey={inputHandler}/>
|
||||||
<Toast message={message}/>
|
<Toast message={message}/>
|
||||||
<div className={"result won " + (gameState === GameState.Won ? "show" : "")}>You won!</div>
|
<GameResult reset={resetHandler} show={gameState === GameState.Won} className={"won"} text={"You won!"} />
|
||||||
<div className={"result lost " + (gameState === GameState.Lost ? "show" : "")}>You lost!</div>
|
<GameResult reset={resetHandler} show={gameState === GameState.Lost} className={"lost"} text={"You lost!"} />
|
||||||
</div>
|
</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