Add game selection screen and new run wizard
Build a 3-step wizard at /runs/new: select game (themed gradient cards grouped by generation with filter tabs), configure rules (reuses existing RulesConfiguration), and name/create run. Remove standalone Games and Rules pages since they're now integrated into the wizard flow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
79
frontend/src/components/GameCard.tsx
Normal file
79
frontend/src/components/GameCard.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { Game } from '../types'
|
||||
|
||||
const GAME_GRADIENTS: Record<string, string> = {
|
||||
firered: 'from-red-500 to-orange-500',
|
||||
leafgreen: 'from-green-500 to-emerald-500',
|
||||
emerald: 'from-emerald-500 to-teal-500',
|
||||
heartgold: 'from-amber-400 to-yellow-500',
|
||||
soulsilver: 'from-gray-400 to-slate-500',
|
||||
}
|
||||
|
||||
const DEFAULT_GRADIENT = 'from-blue-500 to-indigo-500'
|
||||
|
||||
interface GameCardProps {
|
||||
game: Game
|
||||
selected: boolean
|
||||
onSelect: (game: Game) => void
|
||||
}
|
||||
|
||||
export function GameCard({ game, selected, onSelect }: GameCardProps) {
|
||||
const gradient = GAME_GRADIENTS[game.slug] ?? DEFAULT_GRADIENT
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onSelect(game)}
|
||||
className={`relative w-full rounded-lg overflow-hidden transition-all duration-200 hover:scale-105 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900 ${
|
||||
selected ? 'ring-2 ring-blue-500 scale-105 shadow-lg' : 'shadow'
|
||||
}`}
|
||||
>
|
||||
{game.boxArtUrl ? (
|
||||
<img
|
||||
src={game.boxArtUrl}
|
||||
alt={game.name}
|
||||
className="w-full h-48 object-cover"
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className={`w-full h-48 bg-gradient-to-br ${gradient} flex items-center justify-center`}
|
||||
>
|
||||
<span className="text-white text-2xl font-bold text-center px-4 drop-shadow-md">
|
||||
{game.name.replace('Pokemon ', '')}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="p-3 bg-white dark:bg-gray-800 text-left">
|
||||
<h3 className="font-semibold text-gray-900 dark:text-gray-100">
|
||||
{game.name}
|
||||
</h3>
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
<span className="text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400">
|
||||
{game.region}
|
||||
</span>
|
||||
{game.releaseYear && (
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400">
|
||||
{game.releaseYear}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{selected && (
|
||||
<div className="absolute top-2 right-2 w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center">
|
||||
<svg
|
||||
className="w-4 h-4 text-white"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
strokeWidth={3}
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M5 13l4 4L19 7"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
94
frontend/src/components/GameGrid.tsx
Normal file
94
frontend/src/components/GameGrid.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import type { Game } from '../types'
|
||||
import { GameCard } from './GameCard'
|
||||
|
||||
const GENERATION_LABELS: Record<number, string> = {
|
||||
1: 'Generation I',
|
||||
2: 'Generation II',
|
||||
3: 'Generation III',
|
||||
4: 'Generation IV',
|
||||
5: 'Generation V',
|
||||
6: 'Generation VI',
|
||||
7: 'Generation VII',
|
||||
8: 'Generation VIII',
|
||||
9: 'Generation IX',
|
||||
}
|
||||
|
||||
interface GameGridProps {
|
||||
games: Game[]
|
||||
selectedId: number | null
|
||||
onSelect: (game: Game) => void
|
||||
}
|
||||
|
||||
export function GameGrid({ games, selectedId, onSelect }: GameGridProps) {
|
||||
const [filter, setFilter] = useState<number | null>(null)
|
||||
|
||||
const generations = useMemo(
|
||||
() => [...new Set(games.map((g) => g.generation))].sort(),
|
||||
[games],
|
||||
)
|
||||
|
||||
const filtered = filter
|
||||
? games.filter((g) => g.generation === filter)
|
||||
: games
|
||||
|
||||
const grouped = useMemo(() => {
|
||||
const groups: Record<number, Game[]> = {}
|
||||
for (const game of filtered) {
|
||||
;(groups[game.generation] ??= []).push(game)
|
||||
}
|
||||
return Object.entries(groups)
|
||||
.map(([gen, games]) => ({ generation: Number(gen), games }))
|
||||
.sort((a, b) => a.generation - b.generation)
|
||||
}, [filtered])
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFilter(null)}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-full transition-colors ${
|
||||
filter === null
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
All
|
||||
</button>
|
||||
{generations.map((gen) => (
|
||||
<button
|
||||
key={gen}
|
||||
type="button"
|
||||
onClick={() => setFilter(gen)}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-full transition-colors ${
|
||||
filter === gen
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
Gen {gen}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{grouped.map(({ generation, games }) => (
|
||||
<div key={generation}>
|
||||
<h3 className="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3">
|
||||
{GENERATION_LABELS[generation] ?? `Generation ${generation}`}
|
||||
</h3>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{games.map((game) => (
|
||||
<GameCard
|
||||
key={game.id}
|
||||
game={game}
|
||||
selected={game.id === selectedId}
|
||||
onSelect={onSelect}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -13,16 +13,10 @@ export function Layout() {
|
||||
</div>
|
||||
<div className="flex items-center space-x-4">
|
||||
<Link
|
||||
to="/games"
|
||||
to="/runs/new"
|
||||
className="px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-700"
|
||||
>
|
||||
Games
|
||||
</Link>
|
||||
<Link
|
||||
to="/rules"
|
||||
className="px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-700"
|
||||
>
|
||||
Rules
|
||||
New Run
|
||||
</Link>
|
||||
<Link
|
||||
to="/dashboard"
|
||||
|
||||
78
frontend/src/components/StepIndicator.tsx
Normal file
78
frontend/src/components/StepIndicator.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
const STEPS = ['Select Game', 'Configure Rules', 'Create Run']
|
||||
|
||||
interface StepIndicatorProps {
|
||||
currentStep: number
|
||||
onStepClick: (step: number) => void
|
||||
}
|
||||
|
||||
export function StepIndicator({ currentStep, onStepClick }: StepIndicatorProps) {
|
||||
return (
|
||||
<nav aria-label="Progress" className="mb-8">
|
||||
<ol className="flex items-center">
|
||||
{STEPS.map((label, i) => {
|
||||
const step = i + 1
|
||||
const isCompleted = step < currentStep
|
||||
const isCurrent = step === currentStep
|
||||
|
||||
return (
|
||||
<li
|
||||
key={label}
|
||||
className={`flex items-center ${i < STEPS.length - 1 ? 'flex-1' : ''}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => isCompleted && onStepClick(step)}
|
||||
disabled={!isCompleted}
|
||||
className={`flex items-center gap-2 text-sm font-medium ${
|
||||
isCompleted
|
||||
? 'text-blue-600 dark:text-blue-400 cursor-pointer hover:text-blue-700 dark:hover:text-blue-300'
|
||||
: isCurrent
|
||||
? 'text-gray-900 dark:text-gray-100'
|
||||
: 'text-gray-400 dark:text-gray-500 cursor-default'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`flex items-center justify-center w-8 h-8 rounded-full text-sm font-bold shrink-0 ${
|
||||
isCompleted
|
||||
? 'bg-blue-600 text-white'
|
||||
: isCurrent
|
||||
? 'border-2 border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400'
|
||||
: 'border-2 border-gray-300 dark:border-gray-600 text-gray-400 dark:text-gray-500'
|
||||
}`}
|
||||
>
|
||||
{isCompleted ? (
|
||||
<svg
|
||||
className="w-4 h-4"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
strokeWidth={3}
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M5 13l4 4L19 7"
|
||||
/>
|
||||
</svg>
|
||||
) : (
|
||||
step
|
||||
)}
|
||||
</span>
|
||||
<span className="hidden sm:inline">{label}</span>
|
||||
</button>
|
||||
{i < STEPS.length - 1 && (
|
||||
<div
|
||||
className={`flex-1 h-0.5 mx-3 ${
|
||||
step < currentStep
|
||||
? 'bg-blue-600'
|
||||
: 'bg-gray-300 dark:bg-gray-600'
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ol>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
export { GameCard } from './GameCard'
|
||||
export { GameGrid } from './GameGrid'
|
||||
export { Layout } from './Layout'
|
||||
export { RuleToggle } from './RuleToggle'
|
||||
export { RulesConfiguration } from './RulesConfiguration'
|
||||
export { StepIndicator } from './StepIndicator'
|
||||
|
||||
Reference in New Issue
Block a user