mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
toggle diagram clock state
This commit is contained in:
@@ -66,6 +66,12 @@ export const useChessGame = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleToggleClock = () => {
|
||||||
|
gameDispatch({
|
||||||
|
type: "TOGGLE_DIAGRAM_CLOCK",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gameState,
|
gameState,
|
||||||
fileInputRef,
|
fileInputRef,
|
||||||
@@ -73,5 +79,6 @@ export const useChessGame = () => {
|
|||||||
handleSavePdf,
|
handleSavePdf,
|
||||||
handleClearGame,
|
handleClearGame,
|
||||||
handleLoadPgn,
|
handleLoadPgn,
|
||||||
|
handleToggleClock,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const ChessboardContainer = () => {
|
|||||||
handleClearGame={chessGameProps.handleClearGame}
|
handleClearGame={chessGameProps.handleClearGame}
|
||||||
handleSavePgn={chessGameProps.handleSavePgn}
|
handleSavePgn={chessGameProps.handleSavePgn}
|
||||||
handleSavePdf={chessGameProps.handleSavePdf}
|
handleSavePdf={chessGameProps.handleSavePdf}
|
||||||
|
handleToggleClock={chessGameProps.handleToggleClock}
|
||||||
fileInputRef={chessGameProps.fileInputRef}
|
fileInputRef={chessGameProps.fileInputRef}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface IProps {
|
|||||||
handleClearGame: () => void;
|
handleClearGame: () => void;
|
||||||
handleSavePgn: () => void;
|
handleSavePgn: () => void;
|
||||||
handleSavePdf: () => void;
|
handleSavePdf: () => void;
|
||||||
|
handleToggleClock: () => void;
|
||||||
fileInputRef: RefObject<HTMLInputElement | null>;
|
fileInputRef: RefObject<HTMLInputElement | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ const Chessboard = ({
|
|||||||
handleClearGame,
|
handleClearGame,
|
||||||
handleSavePgn,
|
handleSavePgn,
|
||||||
handleSavePdf,
|
handleSavePdf,
|
||||||
|
handleToggleClock,
|
||||||
fileInputRef,
|
fileInputRef,
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
return (
|
return (
|
||||||
@@ -60,6 +62,15 @@ const Chessboard = ({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<PgnViewer gamePgn={gameState.pgn || ""} />
|
<PgnViewer gamePgn={gameState.pgn || ""} />
|
||||||
|
<label htmlFor="diagram-clock">
|
||||||
|
Render Clock Times
|
||||||
|
<input
|
||||||
|
id="diagram-clock"
|
||||||
|
name="diagram-clock"
|
||||||
|
type="checkbox"
|
||||||
|
onChange={handleToggleClock}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type GameAction =
|
|||||||
| { type: "SET_HEADERS"; payload: IHeader }
|
| { type: "SET_HEADERS"; payload: IHeader }
|
||||||
| { type: "ADD_DIAGRAM"; payload: IDiagrams }
|
| { type: "ADD_DIAGRAM"; payload: IDiagrams }
|
||||||
| { type: "DELETE_DIAGRAM"; payload: { ply: number } }
|
| { type: "DELETE_DIAGRAM"; payload: { ply: number } }
|
||||||
| { type: "TOGGLE_DIAGRAM_CLOCK"; payload: boolean };
|
| { type: "TOGGLE_DIAGRAM_CLOCK" };
|
||||||
|
|
||||||
const defaultHeaderFields = {
|
const defaultHeaderFields = {
|
||||||
event: "",
|
event: "",
|
||||||
@@ -92,7 +92,7 @@ export const gameReducer = (state: IGameState, action: GameAction) => {
|
|||||||
case "TOGGLE_DIAGRAM_CLOCK":
|
case "TOGGLE_DIAGRAM_CLOCK":
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
diagramClock: action.payload,
|
diagramClock: !state.diagramClock,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
Reference in New Issue
Block a user