commit 4810de3b94b0ec0d7e9b8570de58f85792dffa80 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Sat Apr 6 01:37:42 2024 +0200 fix : lint commit 59e0b571e6089da6c086ab6340ec6a966b2e9739 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Sat Apr 6 01:36:17 2024 +0200 feat : UI refacto commit 56806a89dca5c7fb2c229b5a57404f9a856fac09 Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Fri Apr 5 03:56:08 2024 +0200 feat : add moves list commit 9e3d2347882074c38ab183e642ecef8153dbfcde Author: GuillaumeSD <gsd.lfny@gmail.com> Date: Thu Apr 4 02:18:52 2024 +0200 feat : init branch, wip
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { useAtomValue } from "jotai";
|
|
import {
|
|
boardAtom,
|
|
boardOrientationAtom,
|
|
currentPositionAtom,
|
|
gameAtom,
|
|
showBestMoveArrowAtom,
|
|
showPlayerMoveIconAtom,
|
|
} from "../states";
|
|
import { useMemo } from "react";
|
|
import { useScreenSize } from "@/hooks/useScreenSize";
|
|
import { Color } from "@/types/enums";
|
|
import Board from "@/components/board";
|
|
import { usePlayersNames } from "@/hooks/usePlayerNames";
|
|
|
|
export default function BoardContainer() {
|
|
const screenSize = useScreenSize();
|
|
const boardOrientation = useAtomValue(boardOrientationAtom);
|
|
const showBestMoveArrow = useAtomValue(showBestMoveArrowAtom);
|
|
const { whiteName, whiteElo, blackName, blackElo } =
|
|
usePlayersNames(gameAtom);
|
|
|
|
const boardSize = useMemo(() => {
|
|
const width = screenSize.width;
|
|
const height = screenSize.height;
|
|
|
|
// 1200 is the lg layout breakpoint
|
|
if (window?.innerWidth < 1200) {
|
|
return Math.min(width, height - 150);
|
|
}
|
|
|
|
return Math.min(width - 700, height * 0.95);
|
|
}, [screenSize]);
|
|
|
|
return (
|
|
<Board
|
|
id="AnalysisBoard"
|
|
boardSize={boardSize}
|
|
canPlay={true}
|
|
gameAtom={boardAtom}
|
|
whitePlayer={`${whiteName} (${whiteElo})`}
|
|
blackPlayer={`${blackName} (${blackElo})`}
|
|
boardOrientation={boardOrientation ? Color.White : Color.Black}
|
|
currentPositionAtom={currentPositionAtom}
|
|
showBestMoveArrow={showBestMoveArrow}
|
|
showPlayerMoveIconAtom={showPlayerMoveIconAtom}
|
|
showEvaluationBar={true}
|
|
/>
|
|
);
|
|
}
|