- move reusable domain, data, state, ui code into src/lib - update host screens to consume new library exports - document architecture and configure path aliases - bump astro integration dependencies for compatibility Refs #30
1.3 KiB
1.3 KiB
New Game Wizard (@lib/features/new-game)
Composable building blocks for the multi-step "start a new game" workflow.
Exports
Player1Step,Player2Step,Player3Step– Player name capture with history + quick picks.GameTypeStep– Game type selector.RaceToStep– Numeric race-to chooser with infinity support.BreakRuleStep,BreakOrderStep– Break configuration helpers.PlayerSelectModal– Modal surface for long player lists.
All exports are surfaced via @lib/features/new-game.
Props & Contracts
- Steps expect pure callbacks (
onNext,onCancel) and derive their own UI state. - Player history arrays control quick-pick ordering. Empty arrays fall back gracefully.
- Styling is shared via
NewGame.module.cssto keep a consistent visual language.
Integrating the Wizard
import { Player1Step, Player2Step } from '@lib/features/new-game';
import { useNewGameWizard } from '@lib/state';
const wizard = useNewGameWizard();
return (
<>
{wizard.newGameStep === 'player1' && (
<Player1Step
playerNameHistory={playerHistory}
onNext={(name) => {
wizard.updateGameData({ player1: name });
wizard.nextStep('player2');
}}
onCancel={wizard.resetWizard}
/>
)}
{/* render subsequent steps analogously */}
</>
);