diff --git a/src/components/Analysis/BroadcastAnalysis.tsx b/src/components/Analysis/BroadcastAnalysis.tsx index 7b912902..0a14e551 100644 --- a/src/components/Analysis/BroadcastAnalysis.tsx +++ b/src/components/Analysis/BroadcastAnalysis.tsx @@ -10,7 +10,7 @@ import type { Key } from 'chessground/types' import { Chess, PieceSymbol } from 'chess.ts' import type { DrawShape } from 'chessground/draw' -import { WindowSizeContext } from 'src/contexts' +import { TABLET_BREAKPOINT_PX, WindowSizeContext } from 'src/contexts' import { MAIA_MODELS } from 'src/constants/common' import { GameInfo } from 'src/components/Common/GameInfo' import { GameBoard } from 'src/components/Board/GameBoard' @@ -38,7 +38,10 @@ export const BroadcastAnalysis: React.FC = ({ analysisController, }) => { const { width } = useContext(WindowSizeContext) - const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + const isMobile = useMemo( + () => width > 0 && width <= TABLET_BREAKPOINT_PX, + [width], + ) const [hoverArrow, setHoverArrow] = useState(null) const [currentSquare, setCurrentSquare] = useState(null) diff --git a/src/components/Analysis/StreamAnalysis.tsx b/src/components/Analysis/StreamAnalysis.tsx index b9cf765b..d2030e2c 100644 --- a/src/components/Analysis/StreamAnalysis.tsx +++ b/src/components/Analysis/StreamAnalysis.tsx @@ -10,7 +10,7 @@ import type { Key } from 'chessground/types' import { Chess, PieceSymbol } from 'chess.ts' import type { DrawShape } from 'chessground/draw' -import { WindowSizeContext } from 'src/contexts' +import { TABLET_BREAKPOINT_PX, WindowSizeContext } from 'src/contexts' import { MAIA_MODELS } from 'src/constants/common' import { GameInfo } from 'src/components/Common/GameInfo' import { GameBoard } from 'src/components/Board/GameBoard' @@ -41,7 +41,10 @@ export const StreamAnalysis: React.FC = ({ analysisController, }) => { const { width } = useContext(WindowSizeContext) - const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + const isMobile = useMemo( + () => width > 0 && width <= TABLET_BREAKPOINT_PX, + [width], + ) const [hoverArrow, setHoverArrow] = useState(null) const [currentSquare, setCurrentSquare] = useState(null) diff --git a/src/components/Board/GameplayInterface.tsx b/src/components/Board/GameplayInterface.tsx index 917323b3..b4481df9 100644 --- a/src/components/Board/GameplayInterface.tsx +++ b/src/components/Board/GameplayInterface.tsx @@ -269,7 +269,7 @@ export const GameplayInterface: React.FC> = (
{
{showMenu && ( -
+
@@ -347,26 +348,38 @@ export const Header: React.FC = () => {
-
+
- - setShowMenu(false)} > Play Maia on Lichess @@ -393,6 +406,15 @@ export const Header: React.FC = () => { Maia Blog + setShowMenu(false)} + > + Discord + {/* = ({ makeMove: parentMakeMove, }) => { const { width } = useContext(WindowSizeContext) - const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + const isMobile = useMemo( + () => width > 0 && width <= TABLET_BREAKPOINT_PX, + [width], + ) const hover = useCallback( (move?: string) => { diff --git a/src/contexts/WindowSizeContext.tsx b/src/contexts/WindowSizeContext.tsx index e3537d85..a40a5f08 100644 --- a/src/contexts/WindowSizeContext.tsx +++ b/src/contexts/WindowSizeContext.tsx @@ -1,6 +1,9 @@ import { useWindowSize } from 'src/hooks' import React, { ReactNode, useMemo } from 'react' +export const PHONE_BREAKPOINT_PX = 670 +export const TABLET_BREAKPOINT_PX = 1024 + interface IWindowSizeContext { height: number width: number @@ -19,7 +22,12 @@ export const WindowSizeContextProvider: React.FC<{ children: ReactNode }> = ({ children: ReactNode }) => { const { width, height } = useWindowSize() - const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + // `isMobile` is used by many layouts as the "stacked" layout trigger. + // Include tablets so iPad widths do not fall into cramped desktop layouts. + const isMobile = useMemo( + () => width > 0 && width <= TABLET_BREAKPOINT_PX, + [width], + ) return ( {children} diff --git a/src/pages/puzzles.tsx b/src/pages/puzzles.tsx index 1221727e..84832151 100644 --- a/src/pages/puzzles.tsx +++ b/src/pages/puzzles.tsx @@ -48,7 +48,7 @@ import { useAnalysisController } from 'src/hooks/useAnalysisController' import { AllStats, useStats } from 'src/hooks/useStats' import { PuzzleGame, Status } from 'src/types/puzzle' import { AnalyzedGame, MaiaEvaluation, StockfishEvaluation } from 'src/types' -import { WindowSizeContext, useTour } from 'src/contexts' +import { TABLET_BREAKPOINT_PX, WindowSizeContext, useTour } from 'src/contexts' import { TrainingControllerContext } from 'src/contexts/TrainingControllerContext' import { getCurrentPlayer, @@ -316,7 +316,10 @@ const Train: React.FC = ({ ) const { width } = useContext(WindowSizeContext) - const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + const isMobile = useMemo( + () => width > 0 && width <= TABLET_BREAKPOINT_PX, + [width], + ) const [hoverArrow, setHoverArrow] = useState(null) const analysisSyncedRef = useRef(false) const [promotionFromTo, setPromotionFromTo] = useState<