feat(ui): accessibility pass — WCAG 2.2 AA for login/lobby/shell (F2)
Tests · UI / test (push) Waiting to run
Tests · UI / test (pull_request) Successful in 2m9s

Add the a11y foundation and bring login, lobby, and the in-game shell to
WCAG 2.2 AA:

- Primitives: .sr-only + .skip-link (base.css), trapFocus (modal focus
  trap + restore) and restoreFocus (menu focus restore) actions, the
  --color-focus visible ring.
- In-game shell: skip link + focusable main landmark; WAI-ARIA sidebar
  tabs (roving tabindex, arrow/Home/End, tabpanel wiring); menu Escape +
  focus restore (account / view / turn-navigator / map-toggles /
  bottom-tabs); mail compose as a role=dialog modal with a focus trap.
- login / lobby / lobby-create: skip link + main landmark, field labels,
  role=alert / role=status live regions.
- Map canvas: aria-label naming it a visual overview, with its data
  reachable by keyboard via the sidebar inspector and tables (accessible
  alternative; in-canvas keyboard nav deferred).

Gates (chromium-desktop): tests/e2e/a11y-axe.spec.ts scans every
top-level view for WCAG 2.2 AA violations (zero); a11y-keyboard.spec.ts
covers the skip link, menu Escape+restore, and tab roving. Adds
@axe-core/playwright. Docs: ui/docs/a11y.md (+ index). Marks F1 and F2
done in ui/PLAN-finalize.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-22 08:25:14 +02:00
parent dcc655c7c4
commit 642c5b7322
25 changed files with 559 additions and 46 deletions
@@ -10,6 +10,7 @@ surfaces the resulting 403 inline.
import { getContext } from "svelte";
import { i18n } from "$lib/i18n/index.svelte";
import { trapFocus } from "$lib/a11y/focus-trap";
import { mailStore } from "$lib/mail-store.svelte";
import {
RENDERED_REPORT_CONTEXT_KEY,
@@ -51,6 +52,10 @@ surfaces the resulting 403 inline.
}
});
function onWindowKeydown(event: KeyboardEvent): void {
if (event.key === "Escape") onClose();
}
async function submit(event: SubmitEvent): Promise<void> {
event.preventDefault();
error = null;
@@ -84,16 +89,30 @@ surfaces the resulting 403 inline.
}
</script>
<div class="overlay" data-testid="mail-compose">
<svelte:window onkeydown={onWindowKeydown} />
<div
class="overlay"
data-testid="mail-compose"
role="dialog"
aria-modal="true"
aria-labelledby="mail-compose-title"
use:trapFocus
>
<form class="dialog" onsubmit={submit}>
<header>
<h3>{i18n.t("game.mail.compose_action")}</h3>
<button type="button" class="close" onclick={onClose}>×</button>
<h3 id="mail-compose-title">{i18n.t("game.mail.compose_action")}</h3>
<button
type="button"
class="close"
aria-label={i18n.t("common.dismiss")}
onclick={onClose}>×</button
>
</header>
<label>
{i18n.t("game.mail.compose.target_label")}
<select bind:value={kind} data-testid="mail-compose-kind">
<select bind:value={kind} data-testid="mail-compose-kind" data-autofocus>
<option value="personal">{i18n.t("game.mail.compose.target_personal")}</option>
<option value="broadcast">{i18n.t("game.mail.compose.target_broadcast")}</option>
</select>
@@ -111,7 +130,7 @@ surfaces the resulting 403 inline.
{/if}
<label>
<span class="visually-hidden">{i18n.t("game.mail.subject_placeholder")}</span>
<span class="sr-only">{i18n.t("game.mail.subject_placeholder")}</span>
<input
type="text"
bind:value={subject}
@@ -121,7 +140,7 @@ surfaces the resulting 403 inline.
</label>
<label>
<span class="visually-hidden">{i18n.t("game.mail.body_placeholder")}</span>
<span class="sr-only">{i18n.t("game.mail.body_placeholder")}</span>
<textarea
bind:value={body}
placeholder={i18n.t("game.mail.body_placeholder")}
@@ -229,12 +248,4 @@ surfaces the resulting 403 inline.
font-size: 0.85rem;
margin: 0;
}
.visually-hidden {
position: absolute;
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
width: 1px;
overflow: hidden;
}
</style>
@@ -14,6 +14,7 @@ bottom-tabs bar.
<script lang="ts">
import { onMount } from "svelte";
import { i18n } from "$lib/i18n/index.svelte";
import { restoreFocus } from "$lib/a11y/restore-focus";
import type { MapToggles, GameStateStore } from "$lib/game-state.svelte";
import type { WrapMode } from "../../map/world";
@@ -83,7 +84,12 @@ bottom-tabs bar.
<span aria-hidden="true"></span>
</button>
{#if open}
<div class="surface" role="menu" data-testid="map-toggles-surface">
<div
class="surface"
role="menu"
data-testid="map-toggles-surface"
use:restoreFocus
>
<fieldset>
<legend>{i18n.t("game.map.toggles.section.objects")}</legend>
<label>
+6 -1
View File
@@ -706,7 +706,12 @@ preference the store already manages.
data-planet-count={store?.report?.planets.length ?? 0}
bind:this={containerEl}
>
<canvas bind:this={canvasEl}></canvas>
<canvas
bind:this={canvasEl}
aria-label={i18n.t("game.map.aria_label", {
count: String(store?.report?.planets.length ?? 0),
})}
></canvas>
{#if store !== undefined && store.status === "ready"}
<MapTogglesControl {store} />
{/if}