mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
wire diagram toggle checkbox state
This commit is contained in:
@@ -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}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user