Accessibility pass, WCAG 2.2 AA (1.50.0)

Public pages, auth, registration, payment, My Events and the kiosk: skip
link, focus ring, labels tied to fields, named quantity buttons, announced
errors, ModalOverlay popups (focus trap, Escape, focus return), contrast
and underlined in-text links, reduced motion. Branding warns about a primary
colour too light for white text and offers a darker shade. axe-core and
keyboard checks in e2e/accessibility.spec.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 15:41:19 +02:00
co-authored by Claude Opus 5.5
parent eac21f3860
commit 9548efdb45
57 changed files with 793 additions and 256 deletions
@@ -120,6 +120,40 @@ export function contrastForeground(hex: string): "#ffffff" | "#0a0a0a" {
return luminance > 0.45 ? "#0a0a0a" : "#ffffff";
}
function relativeLuminance(hex: string): number {
const h6 = normalizeHex(hex);
const chan = (v: number) => {
const c = v / 255;
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
};
return 0.2126 * chan(parseInt(h6.slice(1, 3), 16)) + 0.7152 * chan(parseInt(h6.slice(3, 5), 16)) + 0.0722 * chan(parseInt(h6.slice(5, 7), 16));
}
/** WCAG contrast ratio between two colours (1 to 21). */
export function contrastRatio(a: string, b: string): number {
const [hi, lo] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x);
return (hi + 0.05) / (lo + 0.05);
}
/** WCAG AA for normal-size text. */
export const MIN_TEXT_CONTRAST = 4.5;
/**
* The site puts white text on the primary colour (buttons, chips) and uses it for links
* on white, so it needs 4.5:1 against white. Returns the picked colour if it has that, or
* the closest darker shade (same hue and saturation) that does.
*/
export function accessiblePrimary(hex: string): string {
const picked = normalizeHex(hex);
if (contrastRatio(picked, "#ffffff") >= MIN_TEXT_CONTRAST) return picked;
const { h, s, l } = hexToHsl(picked);
for (let ll = Math.floor(l); ll >= 0; ll--) {
const shade = hslToHex(h, s, ll);
if (contrastRatio(shade, "#ffffff") >= MIN_TEXT_CONTRAST) return shade;
}
return "#000000";
}
/** Matches the shadcn-token foreground convention used elsewhere in globals.css (near-white / near-black HSL triples, not pure #fff/#000). */
export function contrastForegroundTriple(hex: string): string {
return contrastForeground(hex) === "#ffffff" ? "210 40% 98%" : "222.2 47.4% 11.2%";