'use client' import * as Select from '@radix-ui/react-select' import { useTheme } from '@/contexts/ThemeContext' import { css } from '../../../../styled-system/css' import { useStartPracticeModal } from '../StartPracticeModalContext' export function GameBreakSettings() { const { resolvedTheme } = useTheme() const isDark = resolvedTheme === 'dark' const { showGameBreakSettings, gameBreakEnabled, setGameBreakEnabled, gameBreakMinutes, setGameBreakMinutes, gameBreakSelectionMode, setGameBreakSelectionMode, gameBreakSelectedGame, setGameBreakSelectedGame, practiceApprovedGames, hasSingleGame, singleGame, } = useStartPracticeModal() if (!showGameBreakSettings) { return null } // Simplified UI for single-game scenario if (hasSingleGame && singleGame) { return (
{/* Header with toggle */}
Game Breaks
{gameBreakEnabled && ( <> {/* Game info + duration in one row */}
{/* Game icon and name */}
{singleGame.manifest.icon} {singleGame.manifest.shortName || singleGame.manifest.displayName}
{/* Duration selector - compact */}
{[2, 3, 5].map((mins) => { const isSelected = gameBreakMinutes === mins return ( ) })}
{/* Helper text + coming soon */}
Starts automatically between parts More games coming soon!
)}
) } // Full UI for multiple games return (
{/* Header with toggle */}
Game Breaks
{/* Duration options */} {gameBreakEnabled && (
{[2, 3, 5, 10].map((mins) => { const isSelected = gameBreakMinutes === mins return ( ) })}
)} {/* Selection Mode Toggle */} {gameBreakEnabled && (
How to start
{[ { mode: 'auto-start' as const, emoji: '🚀', label: 'Auto-start' }, { mode: 'kid-chooses' as const, emoji: '🎯', label: 'Kid picks' }, ].map(({ mode, emoji, label }) => { const isSelected = gameBreakSelectionMode === mode return ( ) })}
)} {/* Game Selection Dropdown */} {gameBreakEnabled && (
{gameBreakSelectionMode === 'auto-start' ? 'Game' : 'Default'}
setGameBreakSelectedGame(value === '__none__' ? null : (value as string | 'random')) } > {(() => { if (gameBreakSelectedGame === 'random') return '🎲 Random' if (gameBreakSelectedGame === null) return '✨ No default' const game = practiceApprovedGames.find( (g) => g.manifest.name === gameBreakSelectedGame ) return game ? `${game.manifest.icon} ${game.manifest.shortName || game.manifest.displayName}` : 'Select game' })()} {/* Random option */} 🎲 Random {/* Practice-approved games */} {practiceApprovedGames.map((game) => ( {game.manifest.icon} {game.manifest.shortName || game.manifest.displayName} ))} {/* "No default" option for kid-chooses mode only */} {gameBreakSelectionMode === 'kid-chooses' && ( ✨ No default )}
)} {/* Helper text */} {gameBreakEnabled && (
{gameBreakSelectionMode === 'auto-start' ? gameBreakSelectedGame === 'random' ? 'A random game will start automatically' : 'This game will start automatically (kid can skip)' : gameBreakSelectedGame === null ? 'Kid chooses from full list' : 'This game will be highlighted as suggested'}
)}
) }