99 DrillConfiguration ,
1010} from 'src/types'
1111import { ModalContainer } from '../Misc/ModalContainer'
12+ import { useTour } from 'src/contexts'
13+ import { tourConfigs } from 'src/config/tours'
1214
1315const MAIA_VERSIONS = [
1416 { id : 'maia_kdd_1100' , name : 'Maia 1100' } ,
@@ -103,6 +105,7 @@ const BrowsePanel: React.FC<{
103105 setSearchTerm,
104106} ) => (
105107 < div
108+ id = "opening-drill-browse"
106109 className = { `flex w-full flex-col overflow-y-scroll ${ activeTab !== 'browse' ? 'hidden md:flex' : 'flex' } md:border-r md:border-white/10` }
107110 >
108111 < div className = "hidden h-20 flex-col justify-center gap-1 border-b border-white/10 p-4 md:flex" >
@@ -288,6 +291,7 @@ const PreviewPanel: React.FC<{
288291 isDuplicateSelection,
289292} ) => (
290293 < div
294+ id = "opening-drill-preview"
291295 className = { `flex w-full flex-col overflow-hidden ${ activeTab !== 'preview' ? 'hidden md:flex' : 'flex' } ` }
292296 >
293297 < div className = "hidden h-20 flex-col justify-center gap-1 border-b border-white/10 p-4 md:flex" >
@@ -441,6 +445,7 @@ const SelectedPanel: React.FC<{
441445 handleStartDrilling,
442446} ) => (
443447 < div
448+ id = "opening-drill-selected"
444449 className = { `flex w-full flex-col overflow-hidden ${ activeTab !== 'selected' ? 'hidden md:flex' : 'flex' } md:border-l md:border-white/10` }
445450 >
446451 < div className = "hidden h-20 flex-col justify-center gap-1 border-b border-white/10 p-4 md:flex" >
@@ -570,6 +575,7 @@ export const OpeningSelectionModal: React.FC<Props> = ({
570575 onComplete,
571576 onClose,
572577} ) => {
578+ const { startTour } = useTour ( )
573579 const [ selections , setSelections ] =
574580 useState < OpeningSelection [ ] > ( initialSelections )
575581 const [ previewOpening , setPreviewOpening ] = useState < Opening > ( openings [ 0 ] )
@@ -583,6 +589,31 @@ export const OpeningSelectionModal: React.FC<Props> = ({
583589 const [ drillCount , setDrillCount ] = useState ( 5 )
584590 const [ searchTerm , setSearchTerm ] = useState ( '' )
585591 const [ activeTab , setActiveTab ] = useState < MobileTab > ( 'browse' )
592+ const [ initialTourCheck , setInitialTourCheck ] = useState ( false )
593+
594+ // Check if user has completed the tour on initial load
595+ useEffect ( ( ) => {
596+ if ( ! initialTourCheck ) {
597+ setInitialTourCheck ( true )
598+ if ( typeof window !== 'undefined' ) {
599+ const completedTours = JSON . parse (
600+ localStorage . getItem ( 'maia-completed-tours' ) || '[]' ,
601+ )
602+
603+ if ( ! completedTours . includes ( 'openingDrill' ) ) {
604+ startTour (
605+ tourConfigs . openingDrill . id ,
606+ tourConfigs . openingDrill . steps ,
607+ false ,
608+ )
609+ }
610+ }
611+ }
612+ } , [ initialTourCheck , startTour ] )
613+
614+ const handleStartTour = ( ) => {
615+ startTour ( tourConfigs . openingDrill . id , tourConfigs . openingDrill . steps , true )
616+ }
586617
587618 const previewFen = useMemo ( ( ) => {
588619 return previewVariation ? previewVariation . fen : previewOpening . fen
@@ -717,14 +748,32 @@ export const OpeningSelectionModal: React.FC<Props> = ({
717748 </ button >
718749
719750 { /* Header Section */ }
720- < div className = "flex w-full flex-col gap-1 border-b border-white/10 p-4" >
721- < h1 className = "text-xl font-bold text-primary md:text-2xl" >
722- Opening Drills
723- </ h1 >
724- < p className = "text-xs text-secondary md:text-sm" >
725- Practice openings against Maia. Select openings to drill, choose
726- your color and opponent strength.
727- </ p >
751+ < div
752+ id = "opening-drill-modal"
753+ className = "flex w-full flex-col gap-1 border-b border-white/10 p-4"
754+ >
755+ < div className = "flex items-center justify-between" >
756+ < div className = "flex flex-col gap-1" >
757+ < div className = "flex flex-row items-center gap-3" >
758+ < h1 className = "text-xl font-bold text-primary md:text-2xl" >
759+ Opening Drills
760+ </ h1 >
761+ < button
762+ type = "button"
763+ className = "material-symbols-outlined text-lg text-secondary duration-200 hover:text-human-3 focus:outline-none"
764+ onClick = { handleStartTour }
765+ title = "Start tour"
766+ >
767+ help
768+ </ button >
769+ </ div >
770+
771+ < p className = "text-xs text-secondary md:text-sm" >
772+ Practice openings against Maia. Select openings to drill, choose
773+ your color and opponent strength.
774+ </ p >
775+ </ div >
776+ </ div >
728777 </ div >
729778
730779 { /* Mobile Tab Navigation */ }
0 commit comments