Design a SPA accessibility cage fight evaluating routing announcements, focus traps, and…
- User
Design a SPA accessibility cage fight evaluating routing announcements, focus traps, and skip links.
Assistant
The user wants me to create a Single Page Application (SPA) accessibility "cage fight" - a competitive/comparative evaluation interface that tests and demonstrates different accessibility features:
- Routing announcements - How screen readers announce route changes in SPAs
- Focus traps - Keeping focus within modals/dialogs
- Skip links - Links that allow keyboard users to skip to main content
This is a creative technical demo/educational tool. I'll design it as an interactive "battle arena" where these three accessibility concepts "compete" or are demonstrated/tested in a visually engaging way.
Let me think about the design:
Concept: A dark, cyberpunk/arena-style interface where each accessibility feature has its own "fighter" or section. Users can interact with each to see how properly implemented accessibility works vs poorly implemented.
Sections:
- Routing Announcements Arena - Demo of route changes with proper aria-live regions
- Focus Trap Chamber - Interactive modal demo showing focus containment
- Skip Links Showdown - Demo of skip navigation that appears on focus
Visual Style:
- Dark arena/cage fight aesthetic
- Neon accents (maybe cyan/orange for contrast)
- Gritty, industrial feel
- Bold typography
- Animated elements to make it feel dynamic
Interactive Elements:
- Tab navigation demos
- Modal focus trap testing
- Route change simulation with announcements
- Skip link activation
Color Palette:
- Background: Deep dark blue/black (#0a0a0f)
- Primary accent: Electric cyan (#00fff7)
- Secondary accent: Hot orange/red (#ff4d00)
- Text: Off-white (#e8e8e8)
- Muted: Gray tones
Let me build this out with real functionality and educational value.
SPA Accessibility Cage Fight
A dramatic, interactive evaluation arena where three accessibility heavyweights battle it out: Routing Announcements, Focus Traps, and Skip Links. Each contender demonstrates proper implementation with live testing capabilities.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SPA Accessibility Cage Fight</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=IBM+Plex+Mono:wght@400;600&display=swap" rel="stylesheet"> <style> :root { --bg: #07070a; --bg-elevated: #0f0f14; --fg: #e8e6e3; --muted: #5a5a66; --accent-cyan: #00e5df; --accent-orange: #ff5722; --accent-violet: #9d4edd; --card: #13131a; --border: #2a2a35; --glow-cyan: rgba(0, 229, 223, 0.4); --glow-orange: rgba(255, 87, 34, 0.4); } * { box-sizing: border-box; } html { scroll-behavior: smooth; } @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } } body { font-family: 'IBM Plex Mono', monospace; background: var(--bg); color: var(--fg); margin: 0; min-height: 100vh; } .font-display { font-family: 'Bebas Neue', sans-serif; } .skip-link { position: absolute; top: -100px; left: 50%; transform: translateX(-50%); background: var(--accent-cyan); color: var(--bg); padding: 1rem 2rem; z-index: 9999; transition: top 0.3s ease; font-weight: 600; text-decoration: none; } .skip-link:focus { top: 1rem; outline: 3px solid var(--accent-orange); outline-offset: 2px; } .bg-pattern { background-image: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 229, 223, 0.08) 0%, transparent 60%), radial-gradient(circle at 20% 80%, rgba(157, 78, 221, 0.06) 0%, transparent 40%), linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%); } .arena-border { border: 2px solid var(--border); position: relative; } .arena-border::before { content: ''; position: absolute; inset: -4px; border: 1px solid rgba(255,255,255,0.05); pointer-events: none; } .fighter-card { background: var(--card); border: 1px solid var(--border); transition: transform 0.3s ease, box-shadow 0.3s ease; } .fighter-card:hover { transform: translateY(-4px); } .fighter-card:focus-within { outline: 2px solid var(--accent-cyan); outline-offset: 4px; } .btn-fight { background: linear-gradient(135deg, var(--accent-orange) 0%, #ff8a50 100%); color: var(--bg); border: none; padding: 0.875rem 2rem; font-family: 'Bebas Neue', sans-serif; font-size: 1.25rem; letter-spacing: 0.1em; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; position: relative; overflow: hidden; } .btn-fight:hover { transform: scale(1.02); box-shadow: 0 8px 30px var(--glow-orange); } .btn-fight:focus-visible { outline: 3px solid var(--accent-cyan); outline-offset: 3px; } .btn-fight:active { transform: scale(0.98); } .btn-secondary { background: transparent; border: 2px solid var(--accent-cyan); color: var(--accent-cyan); padding: 0.75rem 1.5rem; font-family: 'IBM Plex Mono', monospace; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; } .btn-secondary:hover { background: rgba(0, 229, 223, 0.1); } .btn-secondary:focus-visible { outline: 2px solid var(--accent-orange); outline-offset: 2px; } .nav-link { color: var(--muted); text-decoration: none; padding: 0.5rem 1rem; transition: color 0.2s ease; position: relative; } .nav-link:hover, .nav-link:focus { color: var(--fg); } .nav-link:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; } .nav-link[aria-current="page"] { color: var(--accent-cyan); } .nav-link[aria-current="page"]::after { content: ''; position: absolute; bottom: 0; left: 1rem; right: 1rem; height: 2px; background: var(--accent-cyan); } .score-meter { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; } .score-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; } .modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px); z-index: 100; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; } .modal-backdrop.active { opacity: 1; visibility: visible; } .modal-content { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); background: var(--card); border: 2px solid var(--border); padding: 2rem; max-width: 90vw; width: 480px; z-index: 101; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; } .modal-backdrop.active .modal-content { opacity: 1; transform: translate(-50%, -50%) scale(1); } .live-region { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; } .terminal-text { background: rgba(0, 229, 223, 0.1); border: 1px solid rgba(0, 229, 223, 0.3); padding: 1rem; font-size: 0.8rem; overflow-x: auto; } .tag { display: inline-block; padding: 0.25rem 0.75rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; border: 1px solid; } .tag-win { border-color: #22c55e; color: #22c55e; } .tag-warn { border-color: #eab308; color: #eab308; } .tag-fail { border-color: #ef4444; color: #ef4444; } @keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } .animate-slide-up { animation: slideUp 0.6s ease forwards; } .animate-fade-in { animation: fadeIn 0.4s ease forwards; } .stagger-1 { animation-delay: 0.1s; opacity: 0; } .stagger-2 { animation-delay: 0.2s; opacity: 0; } .stagger-3 { animation-delay: 0.3s; opacity: 0; } .stagger-4 { animation-delay: 0.4s; opacity: 0; } .focus-visible-ring:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; } .demo-section { display: none; } .demo-section.active { display: block; } .route-indicator { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; background: var(--bg); border: 1px solid var(--border); } .route-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-cyan); animation: pulse 2s infinite; } </style> </head> <body class="bg-pattern"> <!-- Skip Links --> <a href="#main-content" class="skip-link">Skip to main content</a> <a href="#arena-section" class="skip-link" style="left: 25%;">Skip to arena</a> <a href="#scoreboard" class="skip-link" style="left: 75%;">Skip to scoreboard</a> <!-- Live Region for Route Announcements --> <div id="route-announcer" class="live-region" role="status" aria-live="polite" aria-atomic="true"></div> <!-- Header --> <header class="border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-sm sticky top-0 z-50"> <nav class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between" role="navigation" aria-label="Main navigation"> <div class="flex items-center gap-3"> <div class="w-10 h-10 bg-gradient-to-br from-[var(--accent-cyan)] to-[var(--accent-violet)] flex items-center justify-center"> <span class="font-display text-xl text-[var(--bg)]">AC</span> </div> <span class="font-display text-2xl tracking-wider">A11Y CAGE</span> </div> <ul class="hidden md:flex items-center gap-2"> <li><a href="#routing" class="nav-link" data-route="routing" aria-current="page">Routing</a></li> <li><a href="#focus-trap" class="nav-link" data-route="focus-trap">Focus Trap</a></li> <li><a href="#skip-links" class="nav-link" data-route="skip-links">Skip Links</a></li> <li><a href="#scoreboard" class="nav-link" data-route="scoreboard">Scoreboard</a></li> </ul> <div class="route-indicator"> <span class="dot" aria-hidden="true"></span> <span id="current-route">/routing</span> </div> </nav> </header> <!-- Main Content --> <main id="main-content" tabindex="-1"> <!-- Hero Section --> <section class="max-w-7xl mx-auto px-4 py-16 md:py-24"> <div class="text-center animate-slide-up"> <p class="text-[var(--muted)] uppercase tracking-[0.3em] text-sm mb-4">Accessibility Battle Arena</p> <h1 class="font-display text-6xl md:text-8xl lg:text-9xl tracking-tight mb-6"> <span class="text-[var(--accent-cyan)]">CAGE</span> <span class="text-[var(--fg)]">FIGHT</span> </h1> <p class="text-[var(--muted)] max-w-2xl mx-auto text-lg mb-8"> Three contenders enter. One accessibility pattern emerges victorious. Test real implementations of SPA routing announcements, focus traps, and skip links. </p> <button class="btn-fight" onclick="scrollToArena()"> ENTER THE ARENA </button> </div> <!-- Fighter Cards --> <div id="arena-section" class="grid md:grid-cols-3 gap-6 mt-20" aria-labelledby="fighters-heading"> <h2 id="fighters-heading" class="sr-only">Accessibility Contenders</h2> <!-- Routing Announcements --> <article class="fighter-card p-6 animate-slide-up stagger-1" aria-labelledby="routing-title"> <div class="flex items-center justify-between mb-4"> <span class="tag tag-win">WCAG 4.2.1</span> <span class="text-[var(--muted)] text-sm">#1</span> </div> <h3 id="routing-title" class="font-display text-3xl text-[var(--accent-cyan)] mb-2">ROUTING ANNOUNCER</h3> <p class="text-[var(--muted)] text-sm mb-4"> Screen reader announces page changes in SPAs using aria-live regions. </p> <div class="terminal-text mb-4"> <code>role="status"<br>aria-live="polite"</code> </div> <div class="flex justify-between items-center"> <span class="text-sm text-[var(--muted)]">Win Rate</span> <span class="font-display text-2xl text-[var(--accent-cyan)]">87%</span> </div> </article> <!-- Focus Trap --> <article class="fighter-card p-6 animate-slide-up stagger-2" aria-labelledby="focus-title"> <div class="flex items-center justify-between mb-4"> <span class="tag tag-warn">WCAG 2.4.3</span> <span class="text-[var(--muted)] text-sm">#2</span> </div> <h3 id="focus-title" class="font-display text-3xl text-[var(--accent-orange)] mb-2">FOCUS TRAP</h3> <p class="text-[var(--muted)] text-sm mb-4"> Contains focus within modals and dialogs until intentionally closed. </p> <div class="terminal-text mb-4"> <code>inert=""<br>aria-modal="true"</code> </div> <div class="flex justify-between items-center"> <span class="text-sm text-[var(--muted)]">Win Rate</span> <span class="font-display text-2xl text-[var(--accent-orange)]">92%</span> </div> </article> <!-- Skip Links --> <article class="fighter-card p-6 animate-slide-up stagger-3" aria-labelledby="skip-title"> <div class="flex items-center justify-between mb-4"> <span class="tag tag-win">WCAG 2.4.1</span> <span class="text-[var(--muted)] text-sm">#3</span> </div> <h3 id="skip-title" class="font-display text-3xl text-[var(--accent-violet)] mb-2">SKIP LINKS</h3> <p class="text-[var(--muted)] text-sm mb-4"> Keyboard users bypass repetitive content and navigate to main areas. </p> <div class="terminal-text mb-4"> <code>href="#main"<br>tabindex="-1"</code> </div> <div class="flex justify-between items-center"> <span class="text-sm text-[var(--muted)]">Win Rate</span> <span class="font-display text-2xl text-[var(--accent-violet)]">78%</span> </div> </article> </div> </section> <!-- Interactive Demo Arena --> <section class="border-t border-[var(--border)] py-16" aria-labelledby="demo-heading"> <div class="max-w-7xl mx-auto px-4"> <h2 id="demo-heading" class="font-display text-4xl md:text-5xl text-center mb-12"> INTERACTIVE <span class="text-[var(--accent-cyan)]">DEMO ARENA</span> </h2> <!-- Tab Controls --> <div role="tablist" aria-label="Accessibility demo categories" class="flex flex-wrap justify-center gap-2 mb-8"> <button role="tab" id="tab-routing" aria-selected="true" aria-controls="panel-routing" class="btn-secondary" onclick="switchDemo('routing')" > Routing Demo </button> <button role="tab" id="tab-focus" aria-selected="false" aria-controls="panel-focus" class="btn-secondary" onclick="switchDemo('focus')" > Focus Trap Demo </button> <button role="tab" id="tab-skip" aria-selected="false" aria-controls="panel-skip" class="btn-secondary" onclick="switchDemo('skip')" > Skip Links Demo </button> </div> <!-- Demo Panels --> <div class="arena-border p-8 bg-[var(--card)]"> <!-- Routing Demo Panel --> <div role="tabpanel" id="panel-routing" aria-labelledby="tab-routing" class="demo-section active" > <h3 class="font-display text-2xl mb-4">Route Change Announcements</h3> <p class="text-[var(--muted)] mb-6"> Navigate between routes. Screen readers will announce page changes via aria-live regions. Press the buttons below to simulate SPA navigation. </p> <div class="flex flex-wrap gap-3 mb-6"> <button class="btn-secondary" onclick="simulateRoute('/home')">Navigate Home</button> <button class="btn-secondary" onclick="simulateRoute('/dashboard')">Go to Dashboard</button> <button class="btn-secondary" onclick="simulateRoute('/settings')">Open Settings</button> <button class="btn-secondary" onclick="simulateRoute('/profile?tab=security')">Profile Security</button> </div> <div class="bg-[var(--bg)] p-4 border border-[var(--border)]"> <p class="text-sm text-[var(--muted)] mb-2">Announcement Log:</p> <div id="route-log" class="font-mono text-sm text-[var(--accent-cyan)]" aria-live="polite"> <p>Waiting for navigation...</p> </div> </div> <div class="mt-6 p-4 border-l-4 border-[var(--accent-cyan)] bg-[var(--bg)]"> <h4 class="font-semibold mb-2">Implementation Notes</h4> <ul class="text-sm text-[var(--muted)] space-y-1"> <li>Uses <code>role="status"</code> with <code>aria-live="polite"</code></li> <li>Announces page title + optional context</li> <li>Delays announcement until after DOM update</li> <li>Moves focus to main content heading</li> </ul> </div> </div> <!-- Focus Trap Demo Panel --> <div role="tabpanel" id="panel-focus" aria-labelledby="tab-focus" class="demo-section" hidden > <h3 class="font-display text-2xl mb-4">Modal Focus Trap</h3> <p class="text-[var(--muted)] mb-6"> Open the modal and try to Tab out of it. Focus will cycle within the modal boundaries. Press Escape or the close button to release the trap. </p> <button class="btn-fight" onclick="openModal()" aria-haspopup="dialog" > OPEN MODAL </button> <div class="mt-6 grid md:grid-cols-2 gap-4"> <div class="p-4 border border-[var(--border)] bg-[var(--bg)]"> <h4 class="font-semibold text-[var(--accent-orange)] mb-2">Correct Implementation</h4> <ul class="text-sm text-[var(--muted)] space-y-1"> <li>Focus moves to modal on open</li> <li>Tab cycles through modal elements only</li> <li>Escape key closes modal</li> <li>Focus returns to trigger element</li> <li>Background content has <code>inert</code></li> </ul> </div> <div class="p-4 border border-[var(--border)] bg-[var(--bg)]"> <h4 class="font-semibold text-[#ef4444] mb-2">Common Failures</h4> <ul class="text-sm text-[var(--muted)] space-y-1"> <li>Focus escapes to background</li> <li>No initial focus set</li> <li>Focus not returned on close</li> <li>Screen reader can navigate away</li> <li>Modal not announced properly</li> </ul> </div> </div> </div> <!-- Skip Links Demo Panel --> <div role="tabpanel" id="panel-skip" aria-labelledby="tab-skip" class="demo-section" hidden > <h3 class="font-display text-2xl mb-4">Skip Link Demonstration</h3> <p class="text-[var(--muted)] mb-6"> This page has three skip links at the top. Press Tab now to reveal them. They appear when focused and allow jumping to key sections. </p> <div class="bg-[var(--bg)] p-6 border border-[var(--border)] mb-6"> <h4 class="font-semibold mb-4">Available Skip Links:</h4> <ol class="space-y-3 text-sm"> <li class="flex items-center gap-3"> <span class="w-8 h-8 bg-[var(--accent-cyan)] text-[var(--bg)] flex items-center justify-center font-bold">1</span> <div> <strong>Skip to main content</strong> <p class="text-[var(--muted)]">Jumps to #main-content landmark</p> </div> </li> <li class="flex items-center gap-3"> <span class="w-8 h-8 bg-[var(--accent-orange)] text-[var(--bg)] flex items-center justify-center font-bold">2</span> <div> <strong>Skip to arena</strong> <p class="text-[var(--muted)]">Jumps to #arena-section for fighter cards</p> </div> </li> <li class="flex items-center gap-3"> <span class="w-8 h-8 bg-[var(--accent-violet)] text-[var(--bg)] flex items-center justify-center font-bold">3</span> <div> <strong>Skip to scoreboard</strong> <p class="text-[var(--muted)]">Jumps to #scoreboard section</p> </div> </li> </ol> </div> <div class="terminal-text"> <p class="text-[var(--muted)] mb-2">Try it now:</p> <ol class="space-y-1"> <li>1. Press Shift+Tab to move focus backwards</li> <li>2. Skip links will appear when focused</li> <li>3. Press Enter to activate a skip link</li> <li>4. Focus moves to the target section</li> </ol> </div> </div> </div> </div> </section> <!-- Scoreboard --> <section id="scoreboard" class="border-t border-[var(--border)] py-16 bg-[var(--bg)]" aria-labelledby="scoreboard-heading" tabindex="-1"> <div class="max-w-7xl mx-auto px-4"> <h2 id="scoreboard-heading" class="font-display text-4xl md:text-5xl text-center mb-12"> FIGHTER <span class="text-[var(--accent-orange)]">SCOREBOARD</span> </h2> <div class="space-y-6"> <!-- Focus Trap Score --> <div class="arena-border p-6 bg-[var(--card)] animate-slide-up stagger-1"> <div class="flex items-center justify-between mb-4"> <div class="flex items-center gap-4"> <div class="w-12 h-12 bg-[var(--accent-orange)] flex items-center justify-center"> <span class="font-display text-2xl text-[var(--bg)]">FT</span> </div> <div> <h3 class="font-display text-xl">FOCUS TRAP</h3> <p class="text-sm text-[var(--muted)]">WCAG 2.4.3 Focus Order</p> </div> </div> <div class="text-right"> <span class="font-display text-4xl text-[var(--accent-orange)]">92</span> <span class="text-[var(--muted)]">/100</span> </div> </div> <div class="score-meter" role="progressbar" aria-valuenow="92" aria-valuemin="0" aria-valuemax="100" aria-label="Focus Trap score"> <div class="score-fill bg-[var(--accent-orange)]" style="width: 92%"></div> </div> <div class="flex justify-between mt-3 text-sm"> <span class="tag tag-win">WINNER</span> <span class="text-[var(--muted)]">+15 pts from last match</span> </div> </div> <!-- Routing Score --> <div class="arena-border p-6 bg-[var(--card)] animate-slide-up stagger-2"> <div class="flex items-center justify-between mb-4"> <div class="flex items-center gap-4"> <div class="w-12 h-12 bg-[var(--accent-cyan)] flex items-center justify-center"> <span class="font-display text-2xl text-[var(--bg)]">RA</span> </div> <div> <h3 class="font-display text-xl">ROUTING ANNOUNCER</h3> <p class="text-sm text-[var(--muted)]">WCAG 4.2.1 Name, Role, Value</p> </div> </div> <div class="text-right"> <span class="font-display text-4xl text-[var(--accent-cyan)]">87</span> <span class="text-[var(--muted)]">/100</span> </div> </div> <div class="score-meter" role="progressbar" aria-valuenow="87" aria-valuemin="0" aria-valuemax="100" aria-label="Routing Announcer score"> <div class="score-fill bg-[var(--accent-cyan)]" style="width: 87%"></div> </div> <div class="flex justify-between mt-3 text-sm"> <span class="tag tag-warn">CONTENDER</span> <span class="text-[var(--muted)]">+8 pts from last match</span> </div> </div> <!-- Skip Links Score --> <div class="arena-border p-6 bg-[var(--card)] animate-slide-up stagger-3"> <div class="flex items-center justify-between mb-4"> <div class="flex items-center gap-4"> <div class="w-12 h-12 bg-[var(--accent-violet)] flex items-center justify-center"> <span class="font-display text-2xl text-[var(--bg)]">SL</span> </div> <div> <h3 class="font-display text-xl">SKIP LINKS</h3> <p class="text-sm text-[var(--muted)]">WCAG 2.4.1 Bypass Blocks</p> </div> </div> <div class="text-right"> <span class="font-display text-4xl text-[var(--accent-violet)]">78</span> <span class="text-[var(--muted)]">/100</span> </div> </div> <div class="score-meter" role="progressbar" aria-valuenow="78" aria-valuemin="0" aria-valuemax="100" aria-label="Skip Links score"> <div class="score-fill bg-[var(--accent-violet)]" style="width: 78%"></div> </div> <div class="flex justify-between mt-3 text-sm"> <span class="tag tag-warn">CONTENDER</span> <span class="text-[var(--muted)]">+3 pts from last match</span> </div> </div> </div> <!-- Judge's Notes --> <div class="mt-12 p-6 border border-[var(--border)] bg-[var(--card)]"> <h3 class="font-display text-2xl mb-4">JUDGE'S NOTES</h3> <div class="grid md:grid-cols-3 gap-6 text-sm"> <div> <h4 class="text-[var(--accent-cyan)] font-semibold mb-2">Routing Criteria</h4> <ul class="text-[var(--muted)] space-y-1"> <li>- Page title announced</li> <li>- Landmark changes detected</li> <li>- Focus management correct</li> <li>- History state updated</li> </ul> </div> <div> <h4 class="text-[var(--accent-orange)] font-semibold mb-2">Focus Trap Criteria</h4> <ul class="text-[var(--muted)] space-y-1"> <li>- Tab cycle contained</li> <li>- Initial focus correct</li> <li>- Escape closes modal</li> <li>- Return focus on close</li> </ul> </div> <div> <h4 class="text-[var(--accent-violet)] font-semibold mb-2">Skip Link Criteria</h4> <ul class="text-[var(--muted)] space-y-1"> <li>- Visible on focus</li> <li>- Target is focusable</li> <li>- Multiple skip options</li> <li>- Works in all browsers</li> </ul> </div> </div> </div> </div> </section> </main> <!-- Focus Trap Modal --> <div id="modal-backdrop" class="modal-backdrop" role="presentation" aria-hidden="true" ></div> <div id="focus-modal" class="modal-content" role="dialog" aria-modal="true" aria-labelledby="modal-title" aria-describedby="modal-desc" > <h2 id="modal-title" class="font-display text-3xl mb-4 text-[var(--accent-orange)]">FOCUS TRAP ACTIVE</h2> <p id="modal-desc" class="text-[var(--muted)] mb-6"> You are now trapped! Try pressing Tab to cycle through elements. Focus will not escape this modal. Press Escape or Close to exit. </p> <form class="space-y-4 mb-6" onsubmit="return false;"> <div> <label for="modal-input-1" class="block text-sm mb-1">First Field</label> <input type="text" id="modal-input-1" class="w-full p-3 bg-[var(--bg)] border border-[var(--border)] text-[var(--fg)] focus-visible-ring" placeholder="Tab here..." > </div> <div> <label for="modal-input-2" class="block text-sm mb-1">Second Field</label> <input type="text" id="modal-input-2" class="w-full p-3 bg-[var(--bg)] border border-[var(--border)] text-[var(--fg)] focus-visible-ring" placeholder="Keep tabbing..." > </div> <fieldset> <legend class="text-sm mb-2">Trap Options</legend> <div class="flex gap-4"> <label class="flex items-center gap-2 cursor-pointer"> <input type="radio" name="trap-option" value="strict" checked class="focus-visible-ring"> <span>Strict</span> </label> <label class="flex items-center gap-2 cursor-pointer"> <input type="radio" name="trap-option" value="flexible" class="focus-visible-ring"> <span>Flexible</span> </label> </div> </fieldset> </form> <div class="flex justify-end gap-3"> <button class="btn-secondary" onclick="closeModal()" > Close (Escape) </button> <button class="btn-fight" onclick="closeModal()"> CONFIRM </button> </div> </div> <!-- Footer --> <footer class="border-t border-[var(--border)] py-8 bg-[var(--bg)]"> <div class="max-w-7xl mx-auto px-4 text-center"> <p class="text-[var(--muted)] text-sm"> SPA Accessibility Cage Fight - Testing WCAG compliance since 2024 </p> <p class="text-[var(--muted)] text-xs mt-2"> Press Tab to navigate. All interactive elements are keyboard accessible. </p> </div> </footer> <script> // Initialize state let modalOpen = false; let previousFocus = null; let focusableElements = []; // Route titles mapping const routeTitles = { '/home': 'Home - Accessibility Cage Fight', '/dashboard': 'Dashboard - Accessibility Cage Fight', '/settings': 'Settings - Accessibility Cage Fight', '/profile?tab=security': 'Profile Security - Accessibility Cage Fight', '#routing': 'Routing Demo - Accessibility Cage Fight', '#focus-trap': 'Focus Trap Demo - Accessibility Cage Fight', '#skip-links': 'Skip Links Demo - Accessibility Cage Fight', '#scoreboard': 'Scoreboard - Accessibility Cage Fight' }; // Announce route change to screen readers function announceRoute(route) { const announcer = document.getElementById('route-announcer'); const title = routeTitles[route] || `Page changed to ${route}`; announcer.textContent = ''; // Small delay to ensure screen readers pick up the change setTimeout(() => { announcer.textContent = `Navigated to: ${title}`; }, 100); } // Simulate SPA route change function simulateRoute(route) { const routeDisplay = document.getElementById('current-route'); const routeLog = document.getElementById('route-log'); routeDisplay.textContent = route; const timestamp = new Date().toLocaleTimeString(); const title = routeTitles[route] || route; routeLog.innerHTML += `<p>[${timestamp}] Navigated to <strong>${route}</strong></p>`; routeLog.innerHTML += `<p class="text-[var(--muted)]">Announced: "${title}"</p>`; routeLog.scrollTop = routeLog.scrollHeight; announceRoute(route); } // Switch demo panels function switchDemo(panel) { const tabs = document.querySelectorAll('[role="tab"]'); const panels = document.querySelectorAll('[role="tabpanel"]'); tabs.forEach(tab => { const isActive = tab.id === `tab-${panel}`; tab.setAttribute('aria-selected', isActive); if (isActive) { tab.style.background = 'rgba(0, 229, 223, 0.2)'; } else { tab.style.background = 'transparent'; } }); panels.forEach(p => { if (p.id === `panel-${panel}`) { p.classList.add('active'); p.removeAttribute('hidden'); } else { p.classList.remove('active'); p.setAttribute('hidden', ''); } }); // Announce panel change const panelNames = { 'routing': 'Routing Announcements Demo', 'focus': 'Focus Trap Demo', 'skip': 'Skip Links Demo' }; announceRoute(`#${panel}`); } // Open modal with focus trap function openModal() { const backdrop = document.getElementById('modal-backdrop'); const modal = document.getElementById('focus-modal'); previousFocus = document.activeElement; modalOpen = true; backdrop.classList.add('active'); backdrop.setAttribute('aria-hidden', 'false'); // Make background inert document.querySelectorAll('body > *:not(#modal-backdrop):not(#focus-modal)').forEach(el => { el.setAttribute('inert', ''); }); // Get all focusable elements in modal focusableElements = modal.querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' ); // Focus first element setTimeout(() => { if (focusableElements.length > 0) { focusableElements[0].focus(); } }, 100); } // Close modal and restore focus function closeModal() { const backdrop = document.getElementById('modal-backdrop'); const modal = document.getElementById('focus-modal'); backdrop.classList.remove('active'); backdrop.setAttribute('aria-hidden', 'true'); modalOpen = false; // Remove inert from background document.querySelectorAll('[inert]').forEach(el => { el.removeAttribute('inert'); }); // Restore focus if (previousFocus) { previousFocus.focus(); } } // Focus trap handler function handleTabInModal(e) { if (!modalOpen || e.key !== 'Tab') return; const firstEl = focusableElements[0]; const lastEl = focusableElements[focusableElements.length - 1]; if (e.shiftKey && document.activeElement === firstEl) { e.preventDefault(); lastEl.focus(); } else if (!e.shiftKey && document.activeElement === lastEl) { e.preventDefault(); firstEl.focus(); } } // Escape key handler function handleEscape(e) { if (e.key === 'Escape' && modalOpen) { closeModal(); } } // Scroll to arena function scrollToArena() { const arena = document.getElementById('arena-section'); if (arena) { arena.scrollIntoView({ behavior: 'smooth' }); arena.focus(); } } // Update nav links for SPA-style behavior function updateNavLinks() { const navLinks = document.querySelectorAll('.nav-link[data-route]'); navLinks.forEach(link => { link.addEventListener('click', (e) => { navLinks.forEach(l => l.removeAttribute('aria-current')); link.setAttribute('aria-current', 'page'); const route = link.getAttribute('data-route'); const routeDisplay = document.getElementById('current-route'); if (routeDisplay && route) { routeDisplay.textContent = `/${route}`; } announceRoute(`#${route}`); }); }); } // Intersection Observer for scroll animations function initScrollAnimations() { const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; if (prefersReducedMotion) return; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, { threshold: 0.1 }); document.querySelectorAll('.animate-slide-up').forEach(el => { observer.observe(el); }); } // Initialize document.addEventListener('DOMContentLoaded', () => { updateNavLinks(); initScrollAnimations(); // Global keyboard handlers document.addEventListener('keydown', handleTabInModal); document.addEventListener('keydown', handleEscape); // Set initial tab state const firstTab = document.getElementById('tab-routing'); if (firstTab) { firstTab.style.background = 'rgba(0, 229, 223, 0.2)'; } }); </script> </body> </html>Design Decisions
Visual Identity: Dark, industrial arena aesthetic with cyan/orange/violet accent trinity representing each "fighter". Uses Bebas Neue for bold headlines and IBM Plex Mono for technical credibility.
Accessibility Features Implemented:
-
Routing Announcements - Live region with
aria-live="polite"announces simulated route changes. Log panel shows real-time announcements. -
Focus Trap - Fully functional modal with proper
aria-modal,inerton background, Tab cycling, Escape key closure, and focus restoration. -
Skip Links - Three visible-on-focus skip links at document top targeting main content, arena section, and scoreboard.
Interactive Elements:
- Tab-based demo switcher with proper ARIA roles
- Route simulation buttons with announcement logging
- Modal focus trap test environment
- Score progress bars with ARIA attributes
Motion: Respects
prefers-reduced-motion. Staggered entrance animations for fighter cards.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.