refactor: extract reusable library

- 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
This commit is contained in:
Frank Schwenk
2025-11-13 10:41:55 +01:00
parent 99be99d120
commit 8a46a8a019
77 changed files with 2240 additions and 1035 deletions

View File

@@ -0,0 +1,46 @@
# 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.css` to keep a consistent visual language.
## Integrating the Wizard
```tsx
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 */}
</>
);
```