mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 09:56:57 +00:00
import lichess pgn viewer as a react component
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
DISCORD_CONTACT_WEBHOOK="https://discord.com/api/webhooks/1166012977313497248/bDOfla0XnRgkBfDJYeRKs_QNe8P_S2kzXokuZNsLGfZN1mvfQAecYJlIrOC0qfMTOEpl"
|
||||||
|
DISCORD_ERROR_LOG_WEBHOOK="https://discord.com/api/webhooks/1174005798200938618/lLgOihkU9MlYwW2slPOTIK3q1kX80f04BSQbimdhHGFgOrN6zC5s2MlmtlSk8K6POZcJ"
|
||||||
|
LICHESS_CLIENT_ID="chess-scribe.org"
|
||||||
|
WEBSITE_URL="http://localhost:3000"
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
"@tanstack/react-start": "latest",
|
"@tanstack/react-start": "latest",
|
||||||
"@tanstack/router-plugin": "^1.132.0",
|
"@tanstack/router-plugin": "^1.132.0",
|
||||||
"@unpic/react": "^1.0.2",
|
"@unpic/react": "^1.0.2",
|
||||||
|
"jotai": "^2.20.0",
|
||||||
"lichess-pgn-viewer": "^2.4.5",
|
"lichess-pgn-viewer": "^2.4.5",
|
||||||
"nitro": "npm:nitro-nightly@latest",
|
"nitro": "npm:nitro-nightly@latest",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
|
|||||||
Generated
+28
@@ -38,6 +38,9 @@ importers:
|
|||||||
'@unpic/react':
|
'@unpic/react':
|
||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.2(next@16.2.6(@babel/core@7.29.7)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
version: 1.0.2(next@16.2.6(@babel/core@7.29.7)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
|
||||||
|
jotai:
|
||||||
|
specifier: ^2.20.0
|
||||||
|
version: 2.20.0(@babel/core@7.29.7)(@babel/template@7.29.7)(@types/react@19.2.15)(react@19.2.6)
|
||||||
lichess-pgn-viewer:
|
lichess-pgn-viewer:
|
||||||
specifier: ^2.4.5
|
specifier: ^2.4.5
|
||||||
version: 2.4.5
|
version: 2.4.5
|
||||||
@@ -1605,6 +1608,24 @@ packages:
|
|||||||
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
|
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
jotai@2.20.0:
|
||||||
|
resolution: {integrity: sha512-b5GAqgmXmXzB4WPaTH26ppk9Sl7AA9WSQX7yfdM+gJ1rFROiWcVbi97gFuN/yVCojOcbcvop2sfLL+fjxW0JVg==}
|
||||||
|
engines: {node: '>=12.20.0'}
|
||||||
|
peerDependencies:
|
||||||
|
'@babel/core': '>=7.0.0'
|
||||||
|
'@babel/template': '>=7.0.0'
|
||||||
|
'@types/react': '>=17.0.0'
|
||||||
|
react: '>=17.0.0'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@babel/core':
|
||||||
|
optional: true
|
||||||
|
'@babel/template':
|
||||||
|
optional: true
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
react:
|
||||||
|
optional: true
|
||||||
|
|
||||||
js-tokens@4.0.0:
|
js-tokens@4.0.0:
|
||||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||||
|
|
||||||
@@ -3559,6 +3580,13 @@ snapshots:
|
|||||||
|
|
||||||
jiti@2.7.0: {}
|
jiti@2.7.0: {}
|
||||||
|
|
||||||
|
jotai@2.20.0(@babel/core@7.29.7)(@babel/template@7.29.7)(@types/react@19.2.15)(react@19.2.6):
|
||||||
|
optionalDependencies:
|
||||||
|
'@babel/core': 7.29.7
|
||||||
|
'@babel/template': 7.29.7
|
||||||
|
'@types/react': 19.2.15
|
||||||
|
react: 19.2.6
|
||||||
|
|
||||||
js-tokens@4.0.0: {}
|
js-tokens@4.0.0: {}
|
||||||
|
|
||||||
js-yaml@4.1.1:
|
js-yaml@4.1.1:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const LichessButton = ({ onClickHandler }: IProps) => {
|
|||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
>
|
>
|
||||||
|
<title>Lichess Logo</title>
|
||||||
<path d="M38.956.5c-3.53.418-6.452.902-9.286 2.984C5.534 1.786-.692 18.533.68 29.364 3.493 50.214 31.918 55.785 41.329 41.7c-7.444 7.696-19.276 8.752-28.323 3.084C3.959 39.116-.506 27.392 4.683 17.567 9.873 7.742 18.996 4.535 29.03 6.405c2.43-1.418 5.225-3.22 7.655-3.187l-1.694 4.86 12.752 21.37c-.439 5.654-5.459 6.112-5.459 6.112-.574-1.47-1.634-2.942-4.842-6.036-3.207-3.094-17.465-10.177-15.788-16.207-2.001 6.967 10.311 14.152 14.04 17.663 3.73 3.51 5.426 6.04 5.795 6.756 0 0 9.392-2.504 7.838-8.927L37.4 7.171z" />
|
<path d="M38.956.5c-3.53.418-6.452.902-9.286 2.984C5.534 1.786-.692 18.533.68 29.364 3.493 50.214 31.918 55.785 41.329 41.7c-7.444 7.696-19.276 8.752-28.323 3.084C3.959 39.116-.506 27.392 4.683 17.567 9.873 7.742 18.996 4.535 29.03 6.405c2.43-1.418 5.225-3.22 7.655-3.187l-1.694 4.86 12.752 21.37c-.439 5.654-5.459 6.112-5.459 6.112-.574-1.47-1.634-2.942-4.842-6.036-3.207-3.094-17.465-10.177-15.788-16.207-2.001 6.967 10.311 14.152 14.04 17.663 3.73 3.51 5.426 6.04 5.795 6.756 0 0 9.392-2.504 7.838-8.927L37.4 7.171z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import LichessPgnViewer from "lichess-pgn-viewer";
|
||||||
|
import type PgnViewer from "lichess-pgn-viewer/pgnViewer";
|
||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
pgn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PgnViewerComponent = ({ pgn }: IProps) => {
|
||||||
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const viewerRef = useRef<PgnViewer | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!containerRef.current) return;
|
||||||
|
|
||||||
|
viewerRef.current = LichessPgnViewer(containerRef.current, {
|
||||||
|
pgn,
|
||||||
|
scrollToMove: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (containerRef.current) {
|
||||||
|
containerRef.current.innerHTML = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [pgn]);
|
||||||
|
|
||||||
|
return <div ref={containerRef} className="lpv-board" />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PgnViewerComponent;
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
import LichessButton from "#/components/LichessButton.tsx";
|
import LichessButton from "#/components/LichessButton.tsx";
|
||||||
|
import PgnViewerComponent from "#/components/LichessPgnViewerComponent.tsx";
|
||||||
import Section from "#/components/Section.tsx";
|
import Section from "#/components/Section.tsx";
|
||||||
|
|
||||||
const Chessboard = () => (
|
const Chessboard = () => {
|
||||||
|
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">
|
||||||
<LichessButton /> or{" "}
|
<LichessButton /> or{" "}
|
||||||
<input type="file" id="file-input" className="file-input max-w-xs" />
|
<input type="file" id="file-input" className="file-input max-w-xs" />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
<PgnViewerComponent pgn="" />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default Chessboard;
|
export default Chessboard;
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@import "./styles/_accordion.css";
|
@import "styles/_accordion.css";
|
||||||
@import "./styles/_file-input.css";
|
@import "./styles/_file-input.css";
|
||||||
|
@import './styles/_pgn-viewer.css';
|
||||||
|
|
||||||
@plugin "@tailwindcss/typography";
|
@plugin "@tailwindcss/typography";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@import "./vendor/lichess-pgn-viewer.css";
|
||||||
|
|
||||||
|
.lpv-board {
|
||||||
|
max-width: 600px;
|
||||||
|
--board-color: #b58863;
|
||||||
|
font-family: "Noto Sans", sans-serif;
|
||||||
|
}
|
||||||
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user