pgnviewer lazy load and suspense

This commit is contained in:
2026-06-03 10:02:53 +02:00
parent 6a9a51c1ed
commit 9ecbce5a15
2 changed files with 61 additions and 49 deletions
+2 -5
View File
@@ -3,12 +3,9 @@ FEN string
Env Vars Env Vars
API base URL API base URL
- favicon and page titles - favicon and page titles - SEO related things
- rearrange buttons / header space - collapse on smaller screens - rearrange buttons / header space - collapse on smaller screens
- Loading Chessboard with suspense and spinner - Loading Chessboard with suspense and spinner
- toasts
- Lichess login - Lichess login
- logger - logger
- contact form
+16 -1
View File
@@ -1,10 +1,23 @@
import { lazy, Suspense } from "react";
import CustomHeaders from "#/components/CustomHeaders.tsx"; import CustomHeaders from "#/components/CustomHeaders.tsx";
import HeaderFields from "#/components/HeaderFields.tsx"; import HeaderFields from "#/components/HeaderFields.tsx";
import LichessButton from "#/components/LichessButton.tsx"; import LichessButton from "#/components/LichessButton.tsx";
import PgnViewer from "#/components/PgnViewer.tsx";
import Section from "#/components/Section.tsx"; import Section from "#/components/Section.tsx";
import { useChessGame } from "#/hooks/useChessGame.ts"; import { useChessGame } from "#/hooks/useChessGame.ts";
const PgnViewer = lazy(() => import("#/components/PgnViewer.tsx"));
const LoadingBoard = () => {
return (
<div className="relative grid h-125 w-160 items-center text-center">
<p>Loading...</p>
<div id="loading-bar-spinner" className="spinner">
<div className="spinner-icon"></div>
</div>
</div>
);
};
const Chessboard = () => { const Chessboard = () => {
const { const {
gameState, gameState,
@@ -35,6 +48,7 @@ const Chessboard = () => {
</Section> </Section>
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<Suspense fallback={<LoadingBoard />}>
<div> <div>
<PgnViewer <PgnViewer
gamePgn={gameState.pgn || ""} gamePgn={gameState.pgn || ""}
@@ -80,6 +94,7 @@ const Chessboard = () => {
</label> </label>
</div> </div>
</div> </div>
</Suspense>
<div className="flex flex-col gap-4 items-center"> <div className="flex flex-col gap-4 items-center">
<div className="flex justify-center gap-4"> <div className="flex justify-center gap-4">