mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
style render move times toggle
This commit is contained in:
@@ -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,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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">
|
||||||
|
<label htmlFor="diagram-add">Select Diagram</label>
|
||||||
<input
|
<input
|
||||||
id="diagram-clock"
|
id="diagram-add"
|
||||||
name="diagram-clock"
|
name="diagram-add"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
className="cursor-pointer"
|
||||||
|
onChange={handleToggleDiagram}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label className="toggle">
|
||||||
|
Render move times
|
||||||
|
<input
|
||||||
|
id="render-times"
|
||||||
|
name="render-times"
|
||||||
|
type="checkbox"
|
||||||
|
checked={gameState.diagramClock}
|
||||||
onChange={handleToggleClock}
|
onChange={handleToggleClock}
|
||||||
/>
|
/>
|
||||||
|
<span className="slider round" />
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
|
|||||||
@@ -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%;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user