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; +}