mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 09:56:57 +00:00
pass generatingPdf state to checkbox to disable, remove container compoentn for chessboard
This commit is contained in:
@@ -149,5 +149,6 @@ export const useChessGame = () => {
|
|||||||
handlePlyChange,
|
handlePlyChange,
|
||||||
handleToggleDiagram,
|
handleToggleDiagram,
|
||||||
currentPosition,
|
currentPosition,
|
||||||
|
generatingPdf,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import { useChessGame } from "#/hooks/useChessGame.ts";
|
|
||||||
import Chessboard from "#/pages/Chessboard.tsx";
|
|
||||||
|
|
||||||
const ChessboardContainer = () => {
|
|
||||||
const chessGameProps = useChessGame();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Chessboard
|
|
||||||
gameState={chessGameProps.gameState}
|
|
||||||
handleLoadPgn={chessGameProps.handleLoadPgn}
|
|
||||||
handleClearGame={chessGameProps.handleClearGame}
|
|
||||||
handleSavePgn={chessGameProps.handleSavePgn}
|
|
||||||
handleSavePdf={chessGameProps.handleSavePdf}
|
|
||||||
handleToggleClock={chessGameProps.handleToggleClock}
|
|
||||||
handleToggleDiagram={chessGameProps.handleToggleDiagram}
|
|
||||||
handlePlyChange={chessGameProps.handlePlyChange}
|
|
||||||
fileInputRef={chessGameProps.fileInputRef}
|
|
||||||
currentPosition={chessGameProps.currentPosition}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ChessboardContainer;
|
|
||||||
+16
-27
@@ -1,34 +1,23 @@
|
|||||||
import type { ChangeEvent, RefObject } from "react";
|
|
||||||
import LichessButton from "#/components/LichessButton.tsx";
|
import LichessButton from "#/components/LichessButton.tsx";
|
||||||
import PgnViewer from "#/components/PgnViewer.tsx";
|
import PgnViewer from "#/components/PgnViewer.tsx";
|
||||||
import Section from "#/components/Section.tsx";
|
import Section from "#/components/Section.tsx";
|
||||||
import type { IGameState } from "#/reducers/gameReducer.ts";
|
import { useChessGame } from "#/hooks/useChessGame.ts";
|
||||||
|
|
||||||
interface IProps {
|
const Chessboard = () => {
|
||||||
gameState: IGameState;
|
const {
|
||||||
handleLoadPgn: (e: ChangeEvent<HTMLInputElement>) => void;
|
gameState,
|
||||||
handleClearGame: () => void;
|
fileInputRef,
|
||||||
handleSavePgn: () => void;
|
currentPosition,
|
||||||
handleSavePdf: () => void;
|
generatingPdf,
|
||||||
handleToggleClock: () => void;
|
handleLoadPgn,
|
||||||
handleToggleDiagram: () => void;
|
handleClearGame,
|
||||||
handlePlyChange: ({ ply, fen }: { ply: number; fen: string }) => void;
|
handleSavePgn,
|
||||||
fileInputRef: RefObject<HTMLInputElement | null>;
|
handleSavePdf,
|
||||||
currentPosition: { ply: number; fen: string };
|
handleToggleClock,
|
||||||
}
|
handleToggleDiagram,
|
||||||
|
handlePlyChange,
|
||||||
|
} = useChessGame();
|
||||||
|
|
||||||
const Chessboard = ({
|
|
||||||
gameState,
|
|
||||||
handleLoadPgn,
|
|
||||||
handleClearGame,
|
|
||||||
handleSavePgn,
|
|
||||||
handleSavePdf,
|
|
||||||
handleToggleClock,
|
|
||||||
handleToggleDiagram,
|
|
||||||
handlePlyChange,
|
|
||||||
fileInputRef,
|
|
||||||
currentPosition,
|
|
||||||
}: 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)]">
|
||||||
<Section title="Convert PGN to PDF">
|
<Section title="Convert PGN to PDF">
|
||||||
@@ -64,7 +53,7 @@ const Chessboard = ({
|
|||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleSavePdf}
|
onClick={handleSavePdf}
|
||||||
disabled={!gameState.pgn}
|
disabled={!gameState.pgn || generatingPdf}
|
||||||
>
|
>
|
||||||
Save PDF
|
Save PDF
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import ChessboardContainer from "#/pages/Chessboard.container.tsx";
|
import Chessboard from "#/pages/Chessboard.tsx";
|
||||||
|
|
||||||
export const Route = createFileRoute("/chessboard")({
|
export const Route = createFileRoute("/chessboard")({
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <ChessboardContainer />;
|
return <Chessboard />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user