clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

Unify world-card screen-reader narration

Dami committed c00fc51
commit
c00fc51be3c0fc4b65b5d727d0997b4306ff164b
parent
2dd42fc28864aa8a3031ba340f02d3ef33f22e52
author
Dami <dami.etoile@gmail.com>
3 files changed, +21 -9
Msrc/render/world-card.js9+++++++++
Msrc/stage.js11+++--------
Mtests/world-card.test.js10+++++++++-
M src/render/world-card.js +9 -0
M src/stage.js +3 -8
@@ -13,7 +13,7 @@ import { pauseMenuItems } from "./stage/dispatch.js";
1313 import { createWinFlow, WIN_ENTRANCE_END } from './stage/win-flow.js';1414 import { SCENE_MOTION_TIMING, sceneMotionPhase } from './stage/scene-motion.js';1515 import { installStageEvents } from './stage/events.js';16-import { drawWorldCard } from './render/world-card.js';16+import { drawWorldCard, worldCardDescription } from './render/world-card.js';1717 1818 const SCENES = {1919 title: titleScene,
@@ -295,7 +295,7 @@ export function createStage(options = {}) {
295295 if (!world?.id || worldCardsSeen.has(world.id)) return false;296296 worldCardsSeen.add(world.id);297297 worldCard = { world, origin, openedAt: visualNow(), geometry: null };298- announce(`${world.name || 'World'}. ${world.tagline || ''} by ${world.author || 'unknown author'}. Press Enter to enter.`.trim());298+ announce(worldCardDescription(world));299299 render();300300 if (!reducedMotion) visualFrame(animateVisuals);301301 return true;
@@ -461,12 +461,7 @@ export function createStage(options = {}) {
461461 reducedMotion,462462 coarsePointer: globalThis.matchMedia?.("(pointer: coarse)").matches ?? false,463463 });464- const cardDescription = [465- worldCard.world.name || 'World',466- worldCard.world.tagline,467- worldCard.world.author ? `by ${worldCard.world.author}` : null,468- ].filter(Boolean).join('. ');469- canvas.setAttribute("aria-label", `${cardDescription}. Press Enter to enter.`);464+ canvas.setAttribute("aria-label", worldCardDescription(worldCard.world));470465 }471466 } else if (scene === "pause") {472467 renderPauseScene(ctx, {
M tests/world-card.test.js +9 -1