Skip to content

Commit 9bf1408

Browse files
fix: make tours responsive on mobile
1 parent 1087c40 commit 9bf1408

4 files changed

Lines changed: 53 additions & 39 deletions

File tree

src/components/Misc/GameInfo.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export const GameInfo: React.FC<Props> = ({
3131
const { startTour } = useTour()
3232

3333
return (
34-
<div className="flex w-full flex-col items-start justify-start gap-1 overflow-hidden bg-background-1 p-3 md:rounded">
34+
<div
35+
id="analysis-game-list"
36+
className="flex w-full flex-col items-start justify-start gap-1 overflow-hidden bg-background-1 p-3 md:rounded"
37+
>
3538
<div className="flex w-full items-center justify-between">
3639
<div className="flex items-center justify-start gap-1.5">
3740
<span className="material-symbols-outlined text-xl">{icon}</span>

src/components/Openings/OpeningSelectionModal.tsx

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { useState, useMemo, useEffect } from 'react'
1+
import React, { useState, useMemo, useEffect, useContext } from 'react'
22
import Image from 'next/image'
3-
import { AnimatePresence, motion } from 'framer-motion'
3+
import { motion } from 'framer-motion'
44
import Chessground from '@react-chess/chessground'
55
import {
66
Opening,
@@ -11,6 +11,7 @@ import {
1111
import { ModalContainer } from '../Misc/ModalContainer'
1212
import { useTour } from 'src/contexts'
1313
import { tourConfigs } from 'src/config/tours'
14+
import { WindowSizeContext } from 'src/contexts/WindowSizeContext'
1415

1516
const MAIA_VERSIONS = [
1617
{ id: 'maia_kdd_1100', name: 'Maia 1100' },
@@ -37,40 +38,47 @@ const TabNavigation: React.FC<{
3738
activeTab: MobileTab
3839
setActiveTab: (tab: MobileTab) => void
3940
selectionsCount: number
40-
}> = ({ activeTab, setActiveTab, selectionsCount }) => (
41-
<div className="flex w-full border-b border-white/10 md:hidden">
42-
<button
43-
onClick={() => setActiveTab('browse')}
44-
className={`flex-1 py-3 text-sm font-medium transition-colors ${
45-
activeTab === 'browse'
46-
? 'border-b-2 border-human-4 text-primary'
47-
: 'text-secondary hover:text-primary'
48-
}`}
49-
>
50-
Browse
51-
</button>
52-
<button
53-
onClick={() => setActiveTab('preview')}
54-
className={`flex-1 py-3 text-sm font-medium transition-colors ${
55-
activeTab === 'preview'
56-
? 'border-b-2 border-human-4 text-primary'
57-
: 'text-secondary hover:text-primary'
58-
}`}
59-
>
60-
Preview
61-
</button>
62-
<button
63-
onClick={() => setActiveTab('selected')}
64-
className={`flex-1 py-3 text-sm font-medium transition-colors ${
65-
activeTab === 'selected'
66-
? 'border-b-2 border-human-4 text-primary'
67-
: 'text-secondary hover:text-primary'
68-
}`}
69-
>
70-
Selected ({selectionsCount})
71-
</button>
72-
</div>
73-
)
41+
}> = ({ activeTab, setActiveTab, selectionsCount }) => {
42+
const { isMobile } = useContext(WindowSizeContext)
43+
44+
return (
45+
<div className="flex w-full border-b border-white/10 md:hidden">
46+
<button
47+
{...(isMobile ? { id: 'opening-drill-browse' } : {})}
48+
onClick={() => setActiveTab('browse')}
49+
className={`flex-1 py-3 text-sm font-medium transition-colors ${
50+
activeTab === 'browse'
51+
? 'border-b-2 border-human-4 text-primary'
52+
: 'text-secondary hover:text-primary'
53+
}`}
54+
>
55+
Browse
56+
</button>
57+
<button
58+
{...(isMobile ? { id: 'opening-drill-preview' } : {})}
59+
onClick={() => setActiveTab('preview')}
60+
className={`flex-1 py-3 text-sm font-medium transition-colors ${
61+
activeTab === 'preview'
62+
? 'border-b-2 border-human-4 text-primary'
63+
: 'text-secondary hover:text-primary'
64+
}`}
65+
>
66+
Preview
67+
</button>
68+
<button
69+
{...(isMobile ? { id: 'opening-drill-selected' } : {})}
70+
onClick={() => setActiveTab('selected')}
71+
className={`flex-1 py-3 text-sm font-medium transition-colors ${
72+
activeTab === 'selected'
73+
? 'border-b-2 border-human-4 text-primary'
74+
: 'text-secondary hover:text-primary'
75+
}`}
76+
>
77+
Selected ({selectionsCount})
78+
</button>
79+
</div>
80+
)
81+
}
7482

7583
// Left Panel - Opening Selection - moved outside main component
7684
const BrowsePanel: React.FC<{

src/pages/analysis/[...id].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ const Analysis: React.FC<Props> = ({
881881
>
882882
<NestedGameInfo />
883883
</GameInfo>
884-
<div className="relative flex h-[100vw] w-screen">
884+
<div id="analysis" className="relative flex h-[100vw] w-screen">
885885
<GameBoard
886886
game={analyzedGame}
887887
availableMoves={controller.moves}

src/pages/train.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,10 @@ const Train: React.FC<Props> = ({
11301130
</div>
11311131
<StatsDisplay stats={stats} />
11321132
<ContinueAgainstMaia launchContinue={launchContinue} />
1133-
<div className="flex w-full flex-col gap-1 overflow-hidden">
1133+
<div
1134+
id="analysis"
1135+
className="flex w-full flex-col gap-1 overflow-hidden"
1136+
>
11341137
<div className="relative">
11351138
<BlunderMeter
11361139
hover={showAnalysis ? hover : mockHover}

0 commit comments

Comments
 (0)