From 8eb61136ea55505f1700984121e66cfd32c5f968 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 24 Sep 2026 10:41:36 +0000 Subject: [PATCH 1/2] Initial plan From 2f56f29fa95deb9383894b3d9d96b14e3f4388aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 24 Sep 2026 10:46:21 +0000 Subject: [PATCH 2/2] Add high contrast mode toggle with persisted preference Co-authored-by: Samrudh9 <84171396+Samrudh9@users.noreply.github.com> --- e2e-tests/home.spec.ts | 16 +++++++++++ src/components/Header.astro | 57 +++++++++++++++++++++++++++++++++++-- src/layouts/Layout.astro | 9 ++++++ src/styles/global.css | 48 +++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 2 deletions(-) diff --git a/e2e-tests/home.spec.ts b/e2e-tests/home.spec.ts index f6edafc..6fa9627 100644 --- a/e2e-tests/home.spec.ts +++ b/e2e-tests/home.spec.ts @@ -24,4 +24,20 @@ test.describe('Home Page', () => { // Check that the welcome message is present using more specific locator await expect(page.getByText('Find your next game! And maybe even back one! Explore our collection!')).toBeVisible(); }); + + test('should toggle high contrast mode and persist preference', async ({ page }) => { + const contrastToggle = page.getByTestId('contrast-toggle'); + + await expect(contrastToggle).toHaveAttribute('aria-pressed', 'false'); + + await contrastToggle.click(); + + await expect(contrastToggle).toHaveAttribute('aria-pressed', 'true'); + await expect(page.locator('html')).toHaveClass(/high-contrast/); + + await page.reload(); + + await expect(page.locator('html')).toHaveClass(/high-contrast/); + await expect(page.getByTestId('contrast-toggle')).toHaveAttribute('aria-pressed', 'true'); + }); }); diff --git a/src/components/Header.astro b/src/components/Header.astro index 9969e6a..34321fd 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -2,11 +2,11 @@ import Menu from '../assets/icons/menu.svg'; --- -
+
-
+
diff --git a/src/styles/global.css b/src/styles/global.css index f1d8c73..8a8768d 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -1 +1,49 @@ @import "tailwindcss"; + +html.high-contrast { + color-scheme: dark; +} + +html.high-contrast body, +html.high-contrast .bg-white, +html.high-contrast .bg-slate-100, +html.high-contrast .bg-slate-700, +html.high-contrast .bg-slate-800, +html.high-contrast .bg-slate-900, +html.high-contrast .bg-blue-500, +html.high-contrast .bg-blue-600, +html.high-contrast .bg-blue-700, +html.high-contrast .bg-blue-900, +html.high-contrast .bg-purple-900, +html.high-contrast .dark\:bg-slate-700, +html.high-contrast .dark\:bg-slate-800, +html.high-contrast .dark\:bg-blue-700 { + background-color: #000 !important; +} + +html.high-contrast, +html.high-contrast .text-slate-100, +html.high-contrast .text-slate-200, +html.high-contrast .text-slate-300, +html.high-contrast .text-slate-400, +html.high-contrast .text-slate-800, +html.high-contrast .text-white, +html.high-contrast .text-blue-300, +html.high-contrast .text-blue-400, +html.high-contrast .text-purple-300, +html.high-contrast .text-yellow-400, +html.high-contrast .dark\:text-white { + color: #fff !important; +} + +html.high-contrast a { + color: #ff0 !important; + text-decoration: underline; +} + +html.high-contrast button, +html.high-contrast .border-slate-600, +html.high-contrast .border-slate-700, +html.high-contrast .border-blue-500 { + border-color: #fff !important; +}