import { useState, type ReactNode } from 'react'; import { Link } from 'react-router'; import type { CatalogEntry } from '@bg/shared/lite'; import { GAME_GROUPS, GAME_ICON } from '../lib/catalog-ui'; /** * Game picker (docs/07 §3.3): small tiles with icon, name and one meta line. The one-line blurb and * difficulty live on the game page, so 26 games fit on a phone in a few screens. A tab row narrows the list. */ export function GameGrid({ games, heading }: { games: CatalogEntry[]; heading?: ReactNode }) { const [group, setGroup] = useState('all'); const groups = GAME_GROUPS.filter((g) => games.some((x) => g.ids.includes(x.id))); const shown = group === 'all' ? games : games.filter((g) => GAME_GROUPS.find((x) => x.key === group)?.ids.includes(g.id)); return (
{/* The heading and the tabs share one line on PC (wraps under it on phones). */}
{heading} {groups.length > 1 && (
{groups.map((g) => ( ))}
)}
{shown.map((g) => ( {GAME_ICON[g.id] ?? '🎲'} {g.nameKo} {g.minPlayers === g.maxPlayers ? `${g.minPlayers}명` : `${g.minPlayers}~${g.maxPlayers}명`} · {g.minutes}분 ))}
); }