diff --git a/components/Board.tsx b/components/Board.tsx index aea1761..018ce71 100644 --- a/components/Board.tsx +++ b/components/Board.tsx @@ -34,17 +34,27 @@ const Board = ({ cells }: BoardProps) => { (acc, { coord }) => (acc = Math.min(acc, -(coord.y - coord.z))), +Infinity ) + const maxYZCoordinate = cells.reduce( + (acc, { coord }) => (acc = Math.max(acc, -(coord.y - coord.z))), + -Infinity + ) const maxXCoordinate = cells.reduce( (acc, { coord }) => (acc = Math.max(acc, coord.x)), -Infinity ) const totalCols = maxXCoordinate - minXCoordinate + 1 + const totalRows = maxYZCoordinate - minYZCoordinate + 1 + + const screenWidth = window.innerWidth + const screenHeight = window.innerHeight + const yUnit = screenWidth < screenHeight ? totalCols : totalRows + const unit = Math.min(screenWidth, screenHeight) / ((yUnit + 24) * 3) return (