Skip to content

fix: improve language switcher contrast for WCAG AA in both light and dark mode#2441

Merged
pethers merged 1 commit into
mainfrom
copilot/fix-contrast-issues-in-all-languages
May 12, 2026
Merged

fix: improve language switcher contrast for WCAG AA in both light and dark mode#2441
pethers merged 1 commit into
mainfrom
copilot/fix-contrast-issues-in-all-languages

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Language switcher links (🇬🇧 EN, etc.) in the header failed WCAG contrast checks in both light and dark mode. The .site-language-switcher a selector only set color via CSS variable without explicit fallbacks, padding, or interactive states — unlike the article-level .lang-link styling.

Changes

  • Header language links (.site-language-switcher a): Added pill-style styling with hardcoded high-contrast colors (#1a1a1a light / #f0f0f0 dark), padding, border-radius, and hover/focus-visible states
  • Footer language grid dark mode: Added explicit #f0f0f0 text color for .site-footer .language-grid a in dark mode (was relying on var(--text-color) which could fail to resolve)
  • Both dark mode mechanisms: Covers @media (prefers-color-scheme: dark) and html[data-theme="dark"] toggle

Contrast ratios: 15.3:1 (light), 14.1:1 (dark) — well above WCAG AA 4.5:1 minimum. Active state uses yellow #ffbe0b bg with #0a0e27 text in both modes.

Applies automatically to all 14 language variants (markup generated by normalize-static-html-chrome.ts).

…ss 14 languages

- Add explicit pill-style styling to .site-language-switcher a with padding,
  border-radius, and high-contrast colors (#1a1a1a light / #f0f0f0 dark)
- Add proper hover/focus-visible states for header language links
- Add dark-mode overrides for both header and footer language links
- Use hardcoded color values instead of CSS variables to ensure contrast
  regardless of theme variable resolution
- Support both prefers-color-scheme: dark and data-theme="dark" toggles

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/289d0f92-d033-45df-a137-a0f0a2e6c8ed

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@pethers pethers marked this pull request as ready for review May 12, 2026 23:29
Copilot AI review requested due to automatic review settings May 12, 2026 23:29
@pethers pethers merged commit 05b6758 into main May 12, 2026
11 checks passed
@pethers pethers deleted the copilot/fix-contrast-issues-in-all-languages branch May 12, 2026 23:29
@github-actions github-actions Bot added html-css HTML/CSS changes size-m Medium change (50-250 lines) labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: html-css,size-m

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves WCAG AA contrast and interaction styling for the header language switcher links (and related footer language links) across both OS dark-mode (prefers-color-scheme) and the manual html[data-theme] theme toggle, applied uniformly to all static language variants.

Changes:

  • Adds pill-style layout, spacing, and hover/focus-visible states for .site-language-switcher a with explicit light/dark text colors.
  • Introduces/adjusts dark-mode overrides for footer language grid link colors and hover states.
  • Updates active language link styling to use a yellow background with dark text across header and footer.
Comments suppressed due to low confidence (1)

styles.css:13739

  • Same issue as the prefers-color-scheme: dark block: in the explicit html[data-theme="dark"] theme, the later :hover/:focus-visible rules override the .active styling, so active language links can lose the yellow active background on hover/focus. Add .active:hover/.active:focus-visible (or reorder) to keep active styling dominant.
html[data-theme="dark"] .site-language-switcher a:hover,
html[data-theme="dark"] .site-language-switcher a:focus-visible {
  background: var(--primary-color, #00cc66);
  color: #001a1a;
  border-color: var(--primary-color, #00cc66);
}

Comment thread styles.css
Comment on lines +13707 to +13712
.site-language-switcher a:hover,
.site-language-switcher a:focus-visible {
background: var(--primary-color, #00cc66);
color: #001a1a;
border-color: var(--primary-color, #00cc66);
}
Comment thread styles.css
Comment on lines 13693 to 13697
.site-footer .language-grid a.active,
.site-language-switcher a.active {
color: var(--dark-bg, #0a0e27);
color: #0a0e27;
border-color: var(--primary-yellow, #ffbe0b);
background: var(--primary-yellow, #ffbe0b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

html-css HTML/CSS changes size-m Medium change (50-250 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants