Skip to content

Commit c8007e4

Browse files
committed
design : improve board responsiveness
1 parent fd1ec3d commit c8007e4

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/components/board/evaluationBar.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ export default function EvaluationBar({
3535
container
3636
justifyContent="center"
3737
alignItems="center"
38-
width="2rem"
38+
width={{ xs: "1.6rem", sm: "2rem" }}
3939
height={height}
4040
border="1px solid black"
41-
borderRadius="5px"
41+
borderRadius={{ xs: "3px", sm: "5px" }}
4242
>
4343
<Box
4444
sx={{
@@ -53,13 +53,16 @@ export default function EvaluationBar({
5353
}%`}
5454
width="100%"
5555
borderRadius={
56-
evalBar.whiteBarPercentage === 100 ? "5px" : "5px 5px 0 0"
56+
evalBar.whiteBarPercentage === 100
57+
? { xs: "3px", sm: "5px" }
58+
: { xs: "3px 3px 0 0", sm: "5px 5px 0 0" }
5759
}
5860
>
5961
<Typography
6062
color={boardOrientation === Color.White ? "white" : "black"}
6163
textAlign="center"
6264
width="100%"
65+
fontSize={{ xs: "0.9rem", sm: "1rem" }}
6366
>
6467
{(evalBar.whiteBarPercentage < 50 &&
6568
boardOrientation === Color.White) ||
@@ -80,17 +83,20 @@ export default function EvaluationBar({
8083
? evalBar.whiteBarPercentage
8184
: 100 - evalBar.whiteBarPercentage
8285
}%`}
83-
width={"100%"}
86+
width="100%"
8487
display="flex"
8588
alignItems="flex-end"
8689
borderRadius={
87-
evalBar.whiteBarPercentage === 100 ? "5px" : "0 0 5px 5px"
90+
evalBar.whiteBarPercentage === 100
91+
? { xs: "3px", sm: "5px" }
92+
: { xs: "0 0 3px 3px", sm: "0 0 5px 5px" }
8893
}
8994
>
9095
<Typography
9196
color={boardOrientation === Color.White ? "black" : "white"}
9297
textAlign="center"
9398
width="100%"
99+
fontSize={{ xs: "0.9rem", sm: "1rem" }}
94100
>
95101
{(evalBar.whiteBarPercentage >= 50 &&
96102
boardOrientation === Color.White) ||

src/components/board/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,14 @@ export default function Board({
239239
clickedSquaresAtom,
240240
playableSquaresAtom,
241241
showPlayerMoveIconAtom,
242+
boardSize: boardSize || 400,
242243
});
243244
}, [
244245
currentPositionAtom,
245246
clickedSquaresAtom,
246247
playableSquaresAtom,
247248
showPlayerMoveIconAtom,
249+
boardSize,
248250
]);
249251

250252
const customPieces = useMemo(
@@ -303,7 +305,7 @@ export default function Board({
303305
rowGap={1.5}
304306
justifyContent="center"
305307
alignItems="center"
306-
paddingLeft={showEvaluationBar ? 2 : 0}
308+
paddingLeft={{ xs: 0.5, sm: showEvaluationBar ? 2 : 0 }}
307309
size="grow"
308310
>
309311
<PlayerHeader

src/components/board/squareRenderer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ export interface Props {
1515
clickedSquaresAtom: PrimitiveAtom<Square[]>;
1616
playableSquaresAtom: PrimitiveAtom<Square[]>;
1717
showPlayerMoveIconAtom?: PrimitiveAtom<boolean>;
18+
boardSize: number;
1819
}
1920

2021
export function getSquareRenderer({
2122
currentPositionAtom,
2223
clickedSquaresAtom,
2324
playableSquaresAtom,
2425
showPlayerMoveIconAtom = atom(false),
26+
boardSize,
2527
}: Props) {
2628
const squareRenderer = forwardRef<HTMLDivElement, CustomSquareProps>(
2729
(props, ref) => {
@@ -68,14 +70,12 @@ export function getSquareRenderer({
6870
<Image
6971
src={`/icons/${moveClassification}.png`}
7072
alt="move-icon"
71-
width={35}
72-
height={35}
73+
width={Math.min(40, boardSize * 0.06)}
74+
height={Math.min(40, boardSize * 0.06)}
7375
style={{
7476
position: "absolute",
75-
top: "max(-12px, -1.8vw)",
76-
right: "max(-12px, -1.8vw)",
77-
maxWidth: "3.6vw",
78-
maxHeight: "3.6vw",
77+
top: Math.max(-13.5, boardSize * -0.03) + "px",
78+
right: Math.max(-13.5, boardSize * -0.03) + "px",
7979
zIndex: 100,
8080
}}
8181
/>

src/sections/analysis/board/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function BoardContainer() {
2525

2626
// 1200 is the lg layout breakpoint
2727
if (window?.innerWidth < 1200) {
28-
return Math.min(width - 15, height - 150);
28+
return Math.min(width, height - 150);
2929
}
3030

3131
return Math.min(width - 700, height * 0.92);

0 commit comments

Comments
 (0)