Modular menu pages have been introduced under src/pages.
Each page exports a lightweight object consumed by the registry (src/pages/registry.js):
{
id: 'first' | 'local' | 'online' | 'host' | 'practice',
selector: '#domElementId',
init(ctx) { /* optional one-time setup */ },
show(ctx) { /* optional when page becomes active */ },
hide(ctx) { /* optional when page hides */ }
}
Shared context (ctx) currently provides:
onlineConnectionshowConnBanner,hideConnBannerupdateStartButtonStatesetMainMenuModeaiStrengthTileplayerColors,startingColorIndex
Pages are registered and initialized inside script.js:
pageRegistry.register([firstPage, localPage, onlinePage, hostPage, practicePage]);
pageRegistry.initAll(sharedCtx);Navigation now delegates to the registry via showMenuFor(menuKey) -> pageRegistry.open(menuKey, ctx).
- Create
src/pages/yourPage.jsexporting the object above. - Import it in
script.jsand add to thepageRegistry.register([...])array. - Reference with
navigateToMenu('yourPageId').
Existing menu DOM manipulation remains for compatibility. The registry hides non-active pages (skipping duplicate selectors) and runs lifecycle hooks.
- Move remaining menu-specific logic from
script.jsinto individual page modules. - Add unit tests for page transitions.
- Consolidate duplicate selector pages (local/host/practice) into a single dynamic module if useful.