Add lang toggler

This commit is contained in:
2024-02-19 14:04:56 +01:00
parent 1cf7035449
commit 588eab0caf
14 changed files with 249 additions and 87 deletions
+4 -1
View File
@@ -9,6 +9,7 @@ import { useState } from 'react';
// ----------------------------------------------------- Context -------------------------------------------------------
import { useRecoilState } from 'recoil';
import { gameStateAtom } from '../../contexts/gameState';
import { langAtom } from '../../contexts/langState';
// ---------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------ Hooks --------------------------------------------------------
@@ -29,6 +30,8 @@ const Grid = () => {
const [gameState, setGameState] = useRecoilState(gameStateAtom);
const [grid, setGrid] = useState(genGrid(gameState.gridSize));
const [lang] = useRecoilState(langAtom);
const { handleLeftClick, handleRightClick } = useActions(grid, setGrid, gameState, setGameState);
return (
@@ -69,7 +72,7 @@ const Grid = () => {
} as React.CSSProperties
}
>
<p className='overlayTitle'>{gameState.endType === 'win' ? 'Gagné !' : 'Perdu !'}</p>
<p className='overlayTitle'>{gameState.endType === 'win' ? lang.config.win : lang.config.loose}</p>
<button
className='overlayButton'
onClick={() => setGameState((prev) => ({ ...prev, status: 'board' }))}