style render move times toggle

This commit is contained in:
2026-06-02 13:11:13 +02:00
parent 2805bd74df
commit 401ac760cf
5 changed files with 91 additions and 9 deletions
+6
View File
@@ -67,11 +67,16 @@ export const useChessGame = () => {
}; };
const handleToggleClock = () => { const handleToggleClock = () => {
console.log("Toggle clock");
gameDispatch({ gameDispatch({
type: "TOGGLE_DIAGRAM_CLOCK", type: "TOGGLE_DIAGRAM_CLOCK",
}); });
}; };
const handleToggleDiagram = () => {
console.log("Toggle diagram");
};
return { return {
gameState, gameState,
fileInputRef, fileInputRef,
@@ -80,5 +85,6 @@ export const useChessGame = () => {
handleClearGame, handleClearGame,
handleLoadPgn, handleLoadPgn,
handleToggleClock, handleToggleClock,
handleToggleDiagram,
}; };
}; };
+1
View File
@@ -12,6 +12,7 @@ const ChessboardContainer = () => {
handleSavePgn={chessGameProps.handleSavePgn} handleSavePgn={chessGameProps.handleSavePgn}
handleSavePdf={chessGameProps.handleSavePdf} handleSavePdf={chessGameProps.handleSavePdf}
handleToggleClock={chessGameProps.handleToggleClock} handleToggleClock={chessGameProps.handleToggleClock}
handleToggleDiagram={chessGameProps.handleToggleDiagram}
fileInputRef={chessGameProps.fileInputRef} fileInputRef={chessGameProps.fileInputRef}
/> />
); );
+26 -9
View File
@@ -11,6 +11,7 @@ interface IProps {
handleSavePgn: () => void; handleSavePgn: () => void;
handleSavePdf: () => void; handleSavePdf: () => void;
handleToggleClock: () => void; handleToggleClock: () => void;
handleToggleDiagram: () => void;
fileInputRef: RefObject<HTMLInputElement | null>; fileInputRef: RefObject<HTMLInputElement | null>;
} }
@@ -21,6 +22,7 @@ const Chessboard = ({
handleSavePgn, handleSavePgn,
handleSavePdf, handleSavePdf,
handleToggleClock, handleToggleClock,
handleToggleDiagram,
fileInputRef, fileInputRef,
}: IProps) => { }: IProps) => {
return ( return (
@@ -64,15 +66,30 @@ const Chessboard = ({
</button> </button>
</div> </div>
<PgnViewer gamePgn={gameState.pgn || ""} /> <PgnViewer gamePgn={gameState.pgn || ""} />
<label htmlFor="diagram-clock"> <div className="flex justify-between max-w-150">
Render Clock Times <div className="flex gap-2">
<input <label htmlFor="diagram-add">Select Diagram</label>
id="diagram-clock" <input
name="diagram-clock" id="diagram-add"
type="checkbox" name="diagram-add"
onChange={handleToggleClock} type="checkbox"
/> className="cursor-pointer"
</label> onChange={handleToggleDiagram}
/>
</div>
<label className="toggle">
Render move times
<input
id="render-times"
name="render-times"
type="checkbox"
checked={gameState.diagramClock}
onChange={handleToggleClock}
/>
<span className="slider round" />
</label>
</div>
</main> </main>
); );
}; };
+1
View File
@@ -1,5 +1,6 @@
@import "tailwindcss"; @import "tailwindcss";
@import "styles/_accordion.css"; @import "styles/_accordion.css";
@import "./styles/_input.css";
@import "./styles/_file-input.css"; @import "./styles/_file-input.css";
@import './styles/_pgn-viewer.css'; @import './styles/_pgn-viewer.css';
+57
View File
@@ -0,0 +1,57 @@
.toggle {
display: inline-flex;
align-items: center;
gap: 8px;
cursor: pointer;
}
.toggle input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: relative;
cursor: pointer;
width: 36px;
height: 20px;
background-color: #ccc;
-webkit-transition: 0.4s;
transition: 0.4s;
flex-shrink: 0;
}
.slider:before {
position: absolute;
content: "";
height: 14px;
width: 14px;
left: 3px;
bottom: 3px;
background-color: white;
-webkit-transition: 0.4s;
transition: 0.4s;
}
input:checked + .slider {
background-color: var(--accent);
}
input:focus + .slider {
box-shadow: 0 0 1px var(--accent);
}
input:checked + .slider:before {
-webkit-transform: translateX(16px);
-ms-transform: translateX(16px);
transform: translateX(16px);
}
.slider.round {
border-radius: 12px;
}
.slider.round:before {
border-radius: 50%;
}