wire diagram toggle checkbox state

This commit is contained in:
2026-06-02 14:52:23 +02:00
parent 50664f4759
commit 1a9d26a6ea
2 changed files with 6 additions and 2 deletions
+1 -2
View File
@@ -4,8 +4,6 @@ import Chessboard from "#/pages/Chessboard.tsx";
const ChessboardContainer = () => { const ChessboardContainer = () => {
const chessGameProps = useChessGame(); const chessGameProps = useChessGame();
console.log(chessGameProps.currentPosition);
return ( return (
<Chessboard <Chessboard
gameState={chessGameProps.gameState} gameState={chessGameProps.gameState}
@@ -17,6 +15,7 @@ const ChessboardContainer = () => {
handleToggleDiagram={chessGameProps.handleToggleDiagram} handleToggleDiagram={chessGameProps.handleToggleDiagram}
handlePlyChange={chessGameProps.handlePlyChange} handlePlyChange={chessGameProps.handlePlyChange}
fileInputRef={chessGameProps.fileInputRef} fileInputRef={chessGameProps.fileInputRef}
currentPosition={chessGameProps.currentPosition}
/> />
); );
}; };
+5
View File
@@ -14,6 +14,7 @@ interface IProps {
handleToggleDiagram: () => void; handleToggleDiagram: () => void;
handlePlyChange: ({ ply, fen }: { ply: number; fen: string }) => void; handlePlyChange: ({ ply, fen }: { ply: number; fen: string }) => void;
fileInputRef: RefObject<HTMLInputElement | null>; fileInputRef: RefObject<HTMLInputElement | null>;
currentPosition: { ply: number; fen: string };
} }
const Chessboard = ({ const Chessboard = ({
@@ -26,6 +27,7 @@ const Chessboard = ({
handleToggleDiagram, handleToggleDiagram,
handlePlyChange, handlePlyChange,
fileInputRef, fileInputRef,
currentPosition,
}: IProps) => { }: IProps) => {
return ( return (
<main className="px-4 pb-8 place-self-center min-h-[calc(100vh-226px)]"> <main className="px-4 pb-8 place-self-center min-h-[calc(100vh-226px)]">
@@ -84,6 +86,9 @@ const Chessboard = ({
name="diagram-toggle" name="diagram-toggle"
type="checkbox" type="checkbox"
className="checkbox-accent" className="checkbox-accent"
checked={gameState.diagrams.some(
(d) => d.ply === currentPosition.ply,
)}
onChange={handleToggleDiagram} onChange={handleToggleDiagram}
/> />
</div> </div>