Skip to content

Feature/hljs contrast fix#277

Draft
FilisLiu wants to merge 21 commits into
mainfrom
feature/hljs-contrast-fix
Draft

Feature/hljs contrast fix#277
FilisLiu wants to merge 21 commits into
mainfrom
feature/hljs-contrast-fix

Conversation

@FilisLiu

@FilisLiu FilisLiu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What?

Fixes accessibility issues in the code example components:

  • Colour contrast: Darkens the syntax-highlight colour used for namespaces and literals (#b75501#b25301) so it meets the WCAG AA contrast threshold against the code block background.
  • Keyboard access: Makes the scrollable code container focusable (tabindex="0") and adds a visible focus outline, so keyboard-only users can reach and scroll the code examples.

Why?

Scrollable regions must be keyboard-operable and all text must meet minimum contrast ratios to satisfy WCAG 2.1 AA. The previous syntax colour fell just short of the required ratio, and the scroll container could not be reached or scrolled without a mouse.

How?

  • Updated the --highlight-namespace and --highlight-literal colours in _hljs.scss.
  • Added tabindex: 0 to the .app-example__scroll container in the code builder.
  • Added a :focus outline (3px solid #fd0, the standard NHS/GOV.UK focus yellow) to .app-example__scroll in both govuk.scss and nhsuk.scss.

Testing?

Manual verification: code examples can now be focused and scrolled via keyboard, show a clear focus indicator, and the updated colour passes an AA contrast check. Covered by the existing pa11y accessibility suite across component and style pages.

FilisLiu and others added 21 commits May 18, 2026 17:32
- Rename nhsuk keys checkboxes_single/radios_collection/select_collection
  to checkboxes/radios/select so brand-default previews (which fall back to
  @component) resolve a heading + reference link under NHS, matching govuk
- component_preview_config returns [nil, nil] on miss for a consistent
  return type instead of {}
- Drop dead `fragment: :component` no-op arg in inset_text preview
- Use single quotes for 'View documentation' (rubocop Style/StringLiterals)
- Strip trailing whitespace from nhsuk locale block
- Simplify button_tag block call (drop redundant options = nil)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Restores lib/design_system/generic/builders/button.rb to match main; the
button_tag cleanup is unrelated to the component_preview rejig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Wire Chrome executable path from setup-chrome action to puppeteer/pa11y
  so pa11y-ci can launch Chrome in CI (was failing with "Could not find Chrome")
- Fix sidebar HTML structure: move headings outside <ul> and split into
  per-section lists (was invalid: <ul> contained <h4> directly)
- Expand pa11y test coverage from 3 to 9 pages: add component/style indexes
  and individual preview pages that now pass AA after sidebar fix
- Sidebar fix resolves the systemic "list must only contain li/script/template"
  violation that affected every preview page

Remaining failures on component preview pages are due to low-contrast syntax
highlighting in the ds_code library component (hljs theme colors), which
requires library-level fixes outside this PR's scope.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- #803378 → #2d0d2a (attributes - dark purple)
- #b75501 → #331a00 (names/literals - dark brown)
- #54790d → #1a2800 (strings/symbols - dark green)
- #535a60 → #2d3338 (punctuation - dark gray)
- Add keyboard focus outline to code scroll container
- Make scroll container keyboard-focusable with tabindex="0"

These colors now meet 4.5:1 WCAG AA contrast on light background.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Comments: #656e77 → #3d4449
- Keywords/meta: #015692 → #000f47
- Attributes: #015692 → #000f47
- Selector-pseudo: #015692 → #000f47
- Meta strings: #54790d → #1a2800

Reduces test errors on component preview pages from ~46 to 10.
Remaining errors may require even darker colors or revisiting
the overall color scheme for code highlighting.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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