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:
46
src/lib/features/new-game/README.md
Normal file
46
src/lib/features/new-game/README.md
Normal 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 */}
|
||||
</>
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user