Skip to content

fix(ui): fix Dark Mode/WCAG contrast, keyboard/a11y, sanitizer, and spread layout - #4

Merged
willtmc merged 1 commit into
mainfrom
fix/reader-ui-contrast-keyboard-a11y-and-perf
Nov 25, 2026
Merged

willtmc merged 1 commit into
mainfrom
fix/reader-ui-contrast-keyboard-a11y-and-perf

Conversation

@willtmc

@willtmc willtmc commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Summary

Improves Resources/reader.html UI/UX, WCAG contrast across all themes, keyboard workflows, VoiceOver/ARIA accessibility, HTML sanitization security, and spread layout/render performance, and syncs README.md.

Changes

  • Dark Mode & WCAG AA Contrast (Resources/reader.html)
    • Replaced bright gray dark-mode input surface with color-mix(in srgb, var(--fg) 5%, var(--bg)).
    • Added dedicated --err (#a83220 paper/sepia, #f07a65 dark) and --border tokens (>= 3.16:1 against both page and input surfaces), darkened --muted (>= 5.35:1 across all 3 themes), and set color-scheme + <meta name="color-scheme" content="light dark">.
    • Defaulted unset first-run theme from prefers-color-scheme with live change listener; added safe light canvas backdrop for transparent images/SVGs in Dark mode.
  • Keyboard Workflows, Focus Rings & Modal #help
    • Unified global keydown handler across start, loading, error, and article modes for Escape, ?, and T while respecting text inputs.
    • Made #help strictly modal (role="dialog" aria-modal="true", inert background, Tab trap, backdrop/Esc/? dismiss, focus restoration).
    • Supported D.focusUrl (⌘L), stateless deterministic queue focus restoration (including tab switching and post-archive), ArrowLeft/ArrowRight/Home/End on role="tablist", docs.length > 0 arrow guard, two-click confirmation on #disconnect, 0 + window.twoupZoom font zoom/reset, :focus-visible rings, mousedown selection tracking, pinch-zoom (e.ctrlKey) wheel pass-through, and mode-safe window.flash().
  • Spread Layout, Safe-Area Insets, RTL & Perf
    • Switched #clip to overflow: clip, clamped top/bottom safe-area insets (preserving PR Show completion actions on the last spread #1's #reader-footer clearance), added #panel top safe-area padding, narrow-viewport 1-column fallback (vw < 900 or < 20em), 2-up measure cap (31 * fontSize), ragged alignment below 40ch, RTL support via D.dir, scrollable tables / overflow-wrap: anywhere inline code, safe broken-image handling, normalized duplicate-title comparison, requestAnimationFrame layout coalescing (scheduleLayout), and cached DOM references.
    • Preserved all PR Show completion actions on the last spread #1 last-spread completion UI and actions (#mark-read, #read-another, window.archiveFailed, archive retry).
  • Hardened sanitize()
    • Prefixed end sentinel to #twoup-end and stripped all untrusted id attributes.
    • Stripped unsafe tags (script, style, iframe, object, embed, form, base, meta, link, noscript, SVG/MathML animation/external elements) and event/external attributes (on*, xlink:href, srcdoc, formaction, foreign href/src).
    • Stripped ASCII control chars before URL protocol checks (http:, https:, mailto:, # on href; http:, https:, data:image/(png|jpeg|jpg|gif|webp|avif); on src, blocking data:image/svg+xml).
  • VoiceOver/ARIA, Reduced Motion & Docs (Resources/reader.html, README.md)
    • Added <title>, <main>, <article>, aria-label on <section id="queue">, role="tablist"/role="tab"/aria-selected, role="list" on queue <ol>, role="status" aria-live="polite", role="alert" on errors, .sr-only labels on #u/#tok, aria-hidden="true" on decorative elements, idle-fading article shortcut hint, and prefers-reduced-motion: reduce.
    • Updated README.md with new shortcuts (0, ⌘+/⌘−/⌘0, Esc) and ./build.sh --build-only.

Verification

  • node --check on extracted inline <script>: pass
  • Programmatic WCAG contrast check (24 color pairs across paper, sepia, dark): all pass (>= 4.5:1 text/muted/link/err, >= 3.0:1 borders)
  • Sanitizer URL/protocol test suite (21 cases incl. control-char smuggling & data:image/svg+xml): all pass
  • ./build.sh --build-only (macOS Swift + codesign verify): built cleanly (build/ trashed afterward)
  • git diff --stat origin/main...HEAD: only Resources/reader.html and README.md touched

@willtmc
willtmc merged commit f4646d6 into main Nov 25, 2026
1 check passed
@willtmc
willtmc deleted the fix/reader-ui-contrast-keyboard-a11y-and-perf branch November 25, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant