feat : add board hue

This commit is contained in:
GuillaumeSD
2025-05-10 18:21:19 +02:00
parent bde565abff
commit 10935c72c5
5 changed files with 42 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import {
Square,
} from "react-chessboard/dist/chessboard/types";
import { moveClassificationColors } from "@/lib/chess";
import { boardHueAtom } from "./states";
export interface Props {
currentPositionAtom: PrimitiveAtom<CurrentPosition>;
@@ -29,6 +30,7 @@ export function getSquareRenderer({
const position = useAtomValue(currentPositionAtom);
const clickedSquares = useAtomValue(clickedSquaresAtom);
const playableSquares = useAtomValue(playableSquaresAtom);
const boardHue = useAtomValue(boardHueAtom);
const fromSquare = position.lastMove?.from;
const toSquare = position.lastMove?.to;
@@ -45,7 +47,14 @@ export function getSquareRenderer({
playableSquares.includes(square) ? playableSquareStyles : undefined;
return (
<div ref={ref} style={{ ...style, position: "relative" }}>
<div
ref={ref}
style={{
...style,
position: "relative",
filter: `hue-rotate(-${boardHue}deg)`,
}}
>
{children}
{highlightSquareStyle && <div style={highlightSquareStyle} />}
{playableSquareStyle && <div style={playableSquareStyle} />}