diff --git a/src/hooks/useScreenSize.ts b/src/hooks/useScreenSize.ts index 7e8f8ff..d381329 100644 --- a/src/hooks/useScreenSize.ts +++ b/src/hooks/useScreenSize.ts @@ -39,12 +39,12 @@ export const useScreenSize = () => { const width = screenSize.width; const height = screenSize.height; - // 900 is the md layout breakpoint - if (width < 900) { - return Math.min(width, height) * 0.95; + // 1200 is the lg layout breakpoint + if (window?.innerWidth < 1200) { + return Math.min(width, height - 150); } - return Math.min(width - 500, height) * 0.95; + return Math.min(width - 600, height); }; return { ...screenSize, boardSize: getBoardSize() }; diff --git a/src/lib/chess.ts b/src/lib/chess.ts index a5320f8..d3be364 100644 --- a/src/lib/chess.ts +++ b/src/lib/chess.ts @@ -85,8 +85,8 @@ export const getEvaluationBarValue = ( ): { whiteBarPercentage: number; label: string } => { if (bestLine.mate) { return { - whiteBarPercentage: whiteToPlay ? 100 : 0, - label: `M${bestLine.mate}`, + whiteBarPercentage: whiteToPlay && bestLine.mate > 0 ? 100 : 0, + label: `M${Math.abs(bestLine.mate)}`, }; } diff --git a/src/lib/engine/uciEngine.ts b/src/lib/engine/uciEngine.ts index b0ab525..b2f3232 100644 --- a/src/lib/engine/uciEngine.ts +++ b/src/lib/engine/uciEngine.ts @@ -207,6 +207,7 @@ export abstract class UciEngine { parsedResults.lines = parsedResults.lines.map((line) => ({ ...line, cp: line.cp ? -line.cp : line.cp, + mate: line.mate ? -line.mate : line.mate, })); } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 04de08d..09597ce 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -17,7 +17,7 @@ import { useEffect } from "react"; export default function GameReport() { const theme = useTheme(); - const isMdOrGreater = useMediaQuery(theme.breakpoints.up("md")); + const isLgOrGreater = useMediaQuery(theme.breakpoints.up("lg")); const { reset: resetBoard } = useChessActions(boardAtom); const { setPgn: setGamePgn } = useChessActions(gameAtom); @@ -43,26 +43,26 @@ export default function GameReport() { - {isMdOrGreater ? : } + {isLgOrGreater ? : } @@ -70,7 +70,7 @@ export default function GameReport() { - {isMdOrGreater ? : } + {isLgOrGreater ? : } ); diff --git a/src/sections/analysis/board/evaluationBar.tsx b/src/sections/analysis/board/evaluationBar.tsx index 51bba65..52a078f 100644 --- a/src/sections/analysis/board/evaluationBar.tsx +++ b/src/sections/analysis/board/evaluationBar.tsx @@ -44,7 +44,9 @@ export default function EvaluationBar({ height }: Props) { : evalBar.whiteBarPercentage }%`} width="100%" - borderRadius="5px 5px 0 0" + borderRadius={ + evalBar.whiteBarPercentage === 100 ? "5px" : "5px 5px 0 0" + } > 0 ? "" : "-"}M${Math.abs(line.mate)}` : "?"; const showSkeleton = line.depth < 6; return ( - + {showSkeleton ? ( - + {showSkeleton ? ( - + ) : ( - line.pv.slice(0, 10).map(moveLineUciToSan(board.fen())).join(", ") + line.pv.map(moveLineUciToSan(board.fen())).join(", ") )}