diff --git a/aidlc-docs/features/redesign-modern-timetravel/audit.md b/aidlc-docs/features/redesign-modern-timetravel/audit.md index 049c954..7412252 100644 --- a/aidlc-docs/features/redesign-modern-timetravel/audit.md +++ b/aidlc-docs/features/redesign-modern-timetravel/audit.md @@ -502,3 +502,15 @@ **Context**: Code Generation U1 Part 2 starts. --- + +## Builder CMS-U3 Accepted + +**Timestamp**: 2026-11-10T05:10:00Z + +**User Input**: "(cross-session message from SLS Software - CMS: CMS-U3 contact-core done, commit b9af7df; summary at K:\Development\Projects\SlpModularCms-contact-forms\aidlc-docs\features\contact-forms-module\construction\cms-u3-contact-core\code\summary.md)" + +**AI Response**: "Accepted on the basis of the builder's report (not yet read in full): Modules.Contact + Tests, migration InitialCreate, public routes with [PublicSiteEndpoint], 404 gate behind IContactFormGate, spam path, idempotency, retention job; tests against a temporary MariaDB (Contact.Tests 113, Core 205, Availability 95, Offerings 86, Identity 37, Master 57, Api 4 passed). Contract deviations adopted: hpCheck JSON name fixed, missing hpCheck counts as empty, unbindable body gives 400 errors.body=['invalid']. Sentry events contain the IP (SendDefaultPii) but no form data; no IP in the database (to mention in the privacy statement review). Builder may send CMS-U3b and CMS-U4 plans together." + +**Context**: Leading the builder. Summary file to be read when preparing the frontend handoff (U4). + +--- diff --git a/aidlc-docs/features/redesign-modern-timetravel/construction/plans/theme-foundation-code-generation-plan.md b/aidlc-docs/features/redesign-modern-timetravel/construction/plans/theme-foundation-code-generation-plan.md index c743ab2..7a90fb9 100644 --- a/aidlc-docs/features/redesign-modern-timetravel/construction/plans/theme-foundation-code-generation-plan.md +++ b/aidlc-docs/features/redesign-modern-timetravel/construction/plans/theme-foundation-code-generation-plan.md @@ -22,19 +22,19 @@ Single source of truth for U1 Code Generation. Inputs: `unit-of-work.md` (U1), F - Docs: C `aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/code/summary.md` ## Steps -- [ ] **Step 0 — Preparation**: commit the AI-DLC inception/design documents separately (`aidlc-docs/`) on the branch so code commits stay clean. Verify the baseline: `pnpm test`, `pnpm lint`, `pnpm build` are green before changes (record the numbers). -- [ ] **Step 1 — Dependency and fonts**: add `@fontsource-variable/archivo` (variable weight + width axis) respecting the repo's pnpm settings; if the package is blocked by the release-age policy or missing, stop and report instead of working around it. Import it in `src/fonts.ts` next to the existing fonts (old fonts are removed in U2); add Tailwind `fontFamily.archivo`. -- [ ] **Step 2 — Tokens (pure logic)**: rewrite `src/theme/tokens.ts`: types `Variant`, `Mode`, `ModeSource`; constants `MODE_STORAGE_KEY = 'slp-software-mode'`, `LEGACY_THEME_STORAGE_KEY = 'slp-software-theme'`; pure functions `isValidMode`, `resolveInitialMode(stored, systemPrefersDark)` returning `{ mode, source }`. (BR-U1-1, 2, 11) -- [ ] **Step 3 — Media-query hooks**: `usePrefersReducedMotion`, `usePrefersDark` (SSR-safe, subscribe/unsubscribe, jsdom-safe when `matchMedia` is missing → defaults false). (BR-U1-3, 9) -- [ ] **Step 4 — CSS tokens**: in `src/index.css` replace `.theme-red/.theme-purple` with `html[data-variant='b'][data-mode='light'|'dark']` and E placeholders (`'e'`, light/dark, accent `#AC0000`) with the semantic variables; B accent `#7A1414`; transitions guarded by `prefers-reduced-motion`; add the dither overlay classes (checker mask + `steps()` keyframes, accent colored), all disabled under reduced motion. (FR-3, BR-U1-9) -- [ ] **Step 5 — No-flash script**: create `public/theme-init.js` (plain ES5, guarded storage access, sets `data-variant="b"` and `data-mode` on ``, mirrors `resolveInitialMode`); add `` (blocking, in ``) in `index.html`. No inline script. (BR-U1-5) -- [ ] **Step 6 — ThemeProvider**: rewrite with `variant`, `mode`, `modeSource`, `toggleMode`, `toggleVariant`, `transition`, `announce`; follow system changes while source is `system`; persist mode on user toggle (guarded); remove the legacy key once; apply data attributes in an effect; `toggleVariant` runs the phases cover → swap → reveal (timers, ~300 ms each), scrolls to top and moves focus to `#main` after the swap, immediate under reduced motion. (BR-U1-1..10, FR-5) -- [ ] **Step 7 — UI components**: `ModeToggle` (aria-pressed = dark, label "Donkere weergave", ≥44px target on mobile, `data-testid="mode-toggle-button"`), icon-only `VariantToggle` (label "Tijdreis: bekijk de site zoals vroeger" / "Terug naar nu", tooltip = label, `data-testid="variant-toggle-button"`), `TransitionOverlay`, `LiveRegion`, `EBoundary`, `VariantRenderer` (B eager, E via `React.lazy(() => import('../../variants/e/LandingE'))`, `Suspense` fallback = cover, error → B + alert + retry). Delete `ThemeToggle.tsx`. (FR-4, FR-6, BR-U1-6..8, 12) -- [ ] **Step 8 — Layout integration**: `Nav.tsx` shows `ModeToggle` then `VariantToggle` (desktop and mobile bar); `RootLayout.tsx` wraps content in `
`, renders `VariantRenderer` (B shell = Nav + page + Footer), `TransitionOverlay`, `LiveRegion`; `LandingE` is a minimal placeholder ("Tijdreis — in aanbouw") with its own nav containing the two toggles so the round trip is testable. `src/routes/__root.tsx` composition order unchanged. -- [ ] **Step 9 — Tests**: per the acceptance list in `frontend-components.md` (8 items): table-driven `resolveInitialMode`; ThemeProvider (first render, legacy key removal, system change following, user click stops following, persistence, storage failure, variant never persisted); variant switch (scroll to top, focus on `#main`, announcement, reduced-motion path with no overlay, failure path with alert + retry); accessibility attributes of both buttons; Nav test updates. Replace obsolete red/purple assertions. -- [ ] **Step 10 — Build and test (automatic, Step 13.5)**: `pnpm lint`, `pnpm test`, `pnpm build` (runs `tsc -b`). Fix and retry until green; report real counts. Manual smoke check of both modes via `pnpm build` output is not required. -- [ ] **Step 11 — Docs**: write `construction/theme-foundation/code/summary.md` (files, behaviour, how to use the hooks, notes for U2..U5, the `/theme-init.js` CSP/nginx note for Operations: must be served same-origin and not cached long). -- [ ] **Step 12 — Commit**: one commit for U1 code (Dutch message in the repo's style, `Co-Authored-By` line as required). No push. +- [x] **Step 0 — Preparation**: commit the AI-DLC inception/design documents separately (`aidlc-docs/`) on the branch so code commits stay clean. Verify the baseline: `pnpm test`, `pnpm lint`, `pnpm build` are green before changes (record the numbers). +- [x] **Step 1 — Dependency and fonts**: add `@fontsource-variable/archivo` (variable weight + width axis) respecting the repo's pnpm settings; if the package is blocked by the release-age policy or missing, stop and report instead of working around it. Import it in `src/fonts.ts` next to the existing fonts (old fonts are removed in U2); add Tailwind `fontFamily.archivo`. +- [x] **Step 2 — Tokens (pure logic)**: rewrite `src/theme/tokens.ts`: types `Variant`, `Mode`, `ModeSource`; constants `MODE_STORAGE_KEY = 'slp-software-mode'`, `LEGACY_THEME_STORAGE_KEY = 'slp-software-theme'`; pure functions `isValidMode`, `resolveInitialMode(stored, systemPrefersDark)` returning `{ mode, source }`. (BR-U1-1, 2, 11) +- [x] **Step 3 — Media-query hooks**: `usePrefersReducedMotion`, `usePrefersDark` (SSR-safe, subscribe/unsubscribe, jsdom-safe when `matchMedia` is missing → defaults false). (BR-U1-3, 9) +- [x] **Step 4 — CSS tokens**: in `src/index.css` replace `.theme-red/.theme-purple` with `html[data-variant='b'][data-mode='light'|'dark']` and E placeholders (`'e'`, light/dark, accent `#AC0000`) with the semantic variables; B accent `#7A1414`; transitions guarded by `prefers-reduced-motion`; add the dither overlay classes (checker mask + `steps()` keyframes, accent colored), all disabled under reduced motion. (FR-3, BR-U1-9) +- [x] **Step 5 — No-flash script**: create `public/theme-init.js` (plain ES5, guarded storage access, sets `data-variant="b"` and `data-mode` on ``, mirrors `resolveInitialMode`); add `` (blocking, in ``) in `index.html`. No inline script. (BR-U1-5) +- [x] **Step 6 — ThemeProvider**: rewrite with `variant`, `mode`, `modeSource`, `toggleMode`, `toggleVariant`, `transition`, `announce`; follow system changes while source is `system`; persist mode on user toggle (guarded); remove the legacy key once; apply data attributes in an effect; `toggleVariant` runs the phases cover → swap → reveal (timers, ~300 ms each), scrolls to top and moves focus to `#main` after the swap, immediate under reduced motion. (BR-U1-1..10, FR-5) +- [x] **Step 7 — UI components**: `ModeToggle` (aria-pressed = dark, label "Donkere weergave", ≥44px target on mobile, `data-testid="mode-toggle-button"`), icon-only `VariantToggle` (label "Tijdreis: bekijk de site zoals vroeger" / "Terug naar nu", tooltip = label, `data-testid="variant-toggle-button"`), `TransitionOverlay`, `LiveRegion`, `EBoundary`, `VariantRenderer` (B eager, E via `React.lazy(() => import('../../variants/e/LandingE'))`, `Suspense` fallback = cover, error → B + alert + retry). Delete `ThemeToggle.tsx`. (FR-4, FR-6, BR-U1-6..8, 12) +- [x] **Step 8 — Layout integration**: `Nav.tsx` shows `ModeToggle` then `VariantToggle` (desktop and mobile bar); `RootLayout.tsx` wraps content in `
`, renders `VariantRenderer` (B shell = Nav + page + Footer), `TransitionOverlay`, `LiveRegion`; `LandingE` is a minimal placeholder ("Tijdreis — in aanbouw") with its own nav containing the two toggles so the round trip is testable. `src/routes/__root.tsx` composition order unchanged. +- [x] **Step 9 — Tests**: per the acceptance list in `frontend-components.md` (8 items): table-driven `resolveInitialMode`; ThemeProvider (first render, legacy key removal, system change following, user click stops following, persistence, storage failure, variant never persisted); variant switch (scroll to top, focus on `#main`, announcement, reduced-motion path with no overlay, failure path with alert + retry); accessibility attributes of both buttons; Nav test updates. Replace obsolete red/purple assertions. +- [x] **Step 10 — Build and test (automatic, Step 13.5)**: `pnpm lint`, `pnpm test`, `pnpm build` (runs `tsc -b`). Fix and retry until green; report real counts. Manual smoke check of both modes via `pnpm build` output is not required. +- [x] **Step 11 — Docs**: write `construction/theme-foundation/code/summary.md` (files, behaviour, how to use the hooks, notes for U2..U5, the `/theme-init.js` CSP/nginx note for Operations: must be served same-origin and not cached long). +- [x] **Step 12 — Commit**: one commit for U1 code (Dutch message in the repo's style, `Co-Authored-By` line as required). No push. ## Explicitly NOT touched in U1 Section content and layout (Hero, About, Packages, Process, Contact), `content.ts`, `usePackagesQuery`, Sentry/Umami wiring, nginx configs, router. Old fonts stay until U2. The E variant's real content is U5. diff --git a/aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/code/summary.md b/aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/code/summary.md new file mode 100644 index 0000000..91a13dd --- /dev/null +++ b/aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/code/summary.md @@ -0,0 +1,29 @@ +# Code Summary — theme-foundation (U1) + +## What was built +- **Theme model**: variant (`b` | `e`) × mode (`light` | `dark`). The old red/purple themes are gone. The variant is always `b` at startup and never stored or in the URL; the mode follows the system preference until the first click, after which it is persisted under `slp-software-mode`. The legacy key `slp-software-theme` is removed once (BR-U1-1..4, 10, 11). +- **No theme flash**: `public/theme-init.js` is a blocking same-origin script (no inline script) that sets `data-variant` and `data-mode` on `` before first paint; `ThemeProvider` keeps them in sync (BR-U1-5). +- **Tokens**: `src/index.css` defines the semantic CSS variables for B light, B dark (accent `#7A1414` light / `#E5524A` dark for text contrast), and base tokens for E light/dark (accent `#AC0000` light, a lighter red in dark; refined per era in U5). Tailwind color names are unchanged. +- **Buttons**: `ModeToggle` (aria-pressed, label "Donkere weergave") and icon-only `VariantToggle` (label changes: "Tijdreis: bekijk de site zoals vroeger" / "Terug naar nu"), both real buttons with 44px touch targets on mobile, in the nav of B and in the E placeholder (BR-U1-12). +- **Variant switching**: `ThemeProvider.toggleVariant` runs the time-travel transition (cover → swap → reveal, 300 ms phases, zero under reduced motion): E is preloaded via `loadVariant` (lazy chunk `LandingE`), the page scrolls to the top, focus moves to `#main`, and a live region announces the result. A load failure keeps B and shows `VariantAlert` with retry; a crash in E is caught by `EBoundary` (BR-U1-6..9). +- **Transition effect**: `TransitionOverlay` + `.tt-overlay` CSS (pixel-dither checker, `steps()` animation); not rendered under `prefers-reduced-motion`. +- **Layout**: `RootLayout` renders `VariantRenderer` (B shell = Nav + `
` + Footer), `TransitionOverlay`, `LiveRegion`, `VariantAlert`. +- **Font**: `@fontsource-variable/archivo` (weight + width axes) added and imported; Tailwind `fontFamily.archivo`. The old families stay until U2. +- **E placeholder**: `src/variants/e/LandingE.tsx` (own nav with the two toggles, "in aanbouw" content). Real content is U5. + +## Files +- Modified: `index.html`, `package.json`, `pnpm-lock.yaml`, `tailwind.config.ts`, `src/fonts.ts`, `src/index.css`, `src/theme/tokens.ts`, `src/theme/ThemeProvider.tsx`, `src/components/layout/Nav.tsx`, `src/components/layout/RootLayout.tsx`, `src/routes/__root.tsx`, `src/test/setup.ts`, tests `ThemeProvider.test.tsx`, `Nav.test.tsx`. +- Created: `public/theme-init.js`, `src/theme/loadVariant.ts`, `src/shared/hooks/{mediaQuery,usePrefersDark,usePrefersReducedMotion}.ts`, `src/components/ui/{ModeToggle,VariantToggle}.tsx`, `src/components/layout/{VariantRenderer,TransitionOverlay,LiveRegion,VariantAlert,EBoundary}.tsx`, `src/variants/e/LandingE.tsx`, `src/test/matchMedia.ts`, tests `tokens.test.ts`, `mediaQueryHooks.test.tsx`, `Toggles.test.tsx`, `VariantRenderer.test.tsx`. +- Deleted: `src/components/ui/ThemeToggle.tsx`. + +## Verification (Step 13.5, real output) +- Baseline before changes: 6 test files / 24 tests passed, lint 0 errors (2 existing warnings), build OK. +- After: **10 test files / 56 tests passed**, `pnpm lint` 0 errors (same 2 warnings: `react-refresh/only-export-components` in `SentryTestButton.tsx` and `ThemeProvider.tsx`, the latter existed before as well), `pnpm build` OK (tsc -b + vite). E is a separate chunk (`LandingE-*.js`, 0.9 kB); main bundle 444.8 kB (baseline 438.3 kB, +Archivo CSS). +- `pnpm-lock.yaml` also contains peer-suffix (`supports-color`) churn produced by the local pnpm 12; the only real addition is `@fontsource-variable/archivo@5.3.0`. + +## Notes for the next units +- Use `useTheme()` for `variant`/`mode`; use semantic Tailwind colors (`bg-bg`, `text-text`, `border-line`, `text-accent`...) so both modes and variants work. U2 restyles the sections to design B and then removes the old font families. +- **Interim look**: until U2 the existing sections use the new B tokens (light by default for many visitors). +- **Operations notes**: `/theme-init.js` must be served same-origin (CSP `script-src 'self'`) and must not be cached for long; the E chunk file name changes per build. +- jsdom helpers: `src/test/matchMedia.ts` (`mockMatchMedia`, `clearMatchMedia`) and a global `window.scrollTo` mock in `src/test/setup.ts`. +- Not done on purpose: mobile menu keeps the two toggles in the top bar (they are always visible); icons are inline SVG. diff --git a/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/contact-api-contract.md b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/contact-api-contract.md index a63876e..5c444a0 100644 --- a/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/contact-api-contract.md +++ b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/contact-api-contract.md @@ -50,7 +50,7 @@ Request body: | `email` | string | yes | trimmed, 1–254 chars, regex `^[^\s@]+@[^\s@]+\.[^\s@]{2,}$`, no control characters | | `subject` | string | yes | trimmed, 1–100 chars; **opaque value** chosen by the site (a package id, slug, or `other`); no slug regex; stored as given, never validated against offerings. The label of `other` is per site (ASF: "Overig"). | | `message` | string | yes | trimmed, 1–2000 chars | -| `hpCheck` | string | yes (key present) | **honeypot**; must be empty. Deliberately implausible name (not `website`/`url`) to avoid password-manager autofill; field is configurable per site; render with `autocomplete="off"`, `tabindex="-1"`, `aria-hidden`, off-screen | +| `hpCheck` | string | no (a missing key counts as empty; CMS-U3) | **honeypot**; must be empty. The JSON name is fixed `hpCheck`; the DOM name/id in the site is free. Deliberately implausible name (not `website`/`url`) to avoid password-manager autofill; render with `autocomplete="off"`, `tabindex="-1"`, `aria-hidden`, off-screen | | `token` | string | yes | from 2.1 | | `captchaToken` | string \| null | when `captcha` enabled | verified server-side | @@ -71,7 +71,7 @@ Responses: "errors": { "name": ["required"], "email": ["invalid"], "message": ["tooLong"] } } ``` -The `type` URI is configurable per host (`Contact:ProblemTypeBase`), default `about:blank`, so no site domain is hard-coded in a module used by two sites; clients map on `errors`, never on `type`. Codes: `required`, `tooLong`, `invalid`, `expired` (token only; also for forged/other-site tokens). The `errors` mapping is custom (not the default ASP.NET `ValidationProblemDetails`). Messages are **not** localized by the API; the client maps `messages[field][code]`. Client-side validation uses the same limits and codes. +The `type` URI is configurable per host (`Contact:ProblemTypeBase`), default `about:blank`, so no site domain is hard-coded in a module used by two sites; clients map on `errors`, never on `type`. Codes: `required`, `tooLong`, `invalid`, `expired` (token only; also for forged/other-site tokens). A body that cannot be bound (broken JSON, wrong types) answers `400` with `errors.body = ["invalid"]` in the same problem shape, without echoing values (implemented in CMS-U3). The `errors` mapping is custom (not the default ASP.NET `ValidationProblemDetails`). Messages are **not** localized by the API; the client maps `messages[field][code]`. Client-side validation uses the same limits and codes. ## 4. Server behaviour agreements 1. **Store first, mail after commit.** Validate → store and commit (`status: new`, `mailStatus: pending`) → respond 202. Mail is **not fire-and-forget** in the request scope: a `BackgroundService`/queue picks up `pending` rows, sends via `IEmailSender`/`IMailAvailability` (returns `MailSendResult`, does not throw) and updates `mailStatus` and `mailAttempts`. A short sweep (every few minutes) catches `pending` rows left by a crash; `failed` rows are retried with **backoff** up to a configurable max attempts (so a first outage does not mean 24 h delay). A mail failure never fails the request. If `Email:Smtp:Host` is not configured: store only, show a notice in the admin. diff --git a/index.html b/index.html index f69f31b..895099b 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ name="description" content="SLP Software bouwt landingspagina's, websites en maatwerk .NET-oplossingen. Vaste prijzen, heldere afspraken." /> +
diff --git a/package.json b/package.json index 454ff70..909c218 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "format": "prettier --write ." }, "dependencies": { + "@fontsource-variable/archivo": "^5.3.0", "@fontsource/instrument-sans": "^5.1.0", "@fontsource/jetbrains-mono": "^5.1.1", "@fontsource/sora": "^5.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66043af..60d3b47 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@fontsource-variable/archivo': + specifier: ^5.3.0 + version: 5.3.0 '@fontsource/instrument-sans': specifier: ^5.1.0 version: 5.2.8 @@ -53,25 +56,25 @@ importers: version: 18.3.7(@types/react@18.3.31) '@vitejs/plugin-react': specifier: ^4.3.2 - version: 4.7.0(vite@5.4.21) + version: 4.7.0(supports-color@7.2.0)(vite@5.4.21) autoprefixer: specifier: ^10.4.20 version: 10.5.4(postcss@8.5.19) eslint: specifier: ^9.13.0 - version: 9.39.5(jiti@1.21.7) + version: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) eslint-plugin-react-hooks: specifier: ^5.0.0 - version: 5.2.0(eslint@9.39.5(jiti@1.21.7)) + version: 5.2.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)) eslint-plugin-react-refresh: specifier: ^0.4.12 - version: 0.4.26(eslint@9.39.5(jiti@1.21.7)) + version: 0.4.26(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)) globals: specifier: ^15.9.0 version: 15.15.0 jsdom: specifier: ^25.0.1 - version: 25.0.1 + version: 25.0.1(supports-color@7.2.0) postcss: specifier: ^8.4.47 version: 8.5.19 @@ -86,13 +89,13 @@ importers: version: 5.9.3 typescript-eslint: specifier: ^8.8.0 - version: 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) + version: 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) vite: specifier: ^5.4.8 version: 5.4.21 vitest: specifier: ^2.1.2 - version: 2.1.9(jsdom@25.0.1) + version: 2.1.9(jsdom@25.0.1(supports-color@7.2.0))(supports-color@7.2.0) packages: @@ -397,6 +400,9 @@ packages: resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@fontsource-variable/archivo@5.3.0': + resolution: {integrity: sha512-HogK8FJelrD1o7TlZlkIVtHgc20bO5PZRWE7mUeUTdMN055alznQV6/00J00IBeu8FQAH4s3zW9UJNvKExXf+g==} + '@fontsource/instrument-sans@5.2.8': resolution: {integrity: sha512-TJRYVbjZPx4DGMMU5lb5eFKrP3iLe9h7rz8Pk+dP958IZKiyHjYGXXwQZapVbBXcQN+YOiviVhAWxrjv8g6Z6g==} @@ -1105,6 +1111,7 @@ packages: eslint@9.39.5: resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true peerDependencies: jiti: '*' @@ -1946,20 +1953,20 @@ snapshots: '@babel/compat-data@7.29.7': {} - '@babel/core@7.29.7': + '@babel/core@7.29.7(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.7 '@babel/generator': 7.29.7 '@babel/helper-compilation-targets': 7.29.7 - '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helpers': 7.29.7 '@babel/parser': 7.29.7 '@babel/template': 7.29.7 - '@babel/traverse': 7.29.7 + '@babel/traverse': 7.29.7(supports-color@7.2.0) '@babel/types': 7.29.7 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -1984,19 +1991,19 @@ snapshots: '@babel/helper-globals@7.29.7': {} - '@babel/helper-module-imports@7.29.7': + '@babel/helper-module-imports@7.29.7(supports-color@7.2.0)': dependencies: - '@babel/traverse': 7.29.7 + '@babel/traverse': 7.29.7(supports-color@7.2.0) '@babel/types': 7.29.7 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7 - '@babel/helper-module-imports': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) '@babel/helper-validator-identifier': 7.29.7 - '@babel/traverse': 7.29.7 + '@babel/traverse': 7.29.7(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -2017,14 +2024,14 @@ snapshots: dependencies: '@babel/types': 7.29.7 - '@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7)': + '@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.29.7 - '@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7)': + '@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.29.7 '@babel/runtime@7.29.7': {} @@ -2035,7 +2042,7 @@ snapshots: '@babel/parser': 7.29.7 '@babel/types': 7.29.7 - '@babel/traverse@7.29.7': + '@babel/traverse@7.29.7(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.7 '@babel/generator': 7.29.7 @@ -2043,7 +2050,7 @@ snapshots: '@babel/parser': 7.29.7 '@babel/template': 7.29.7 '@babel/types': 7.29.7 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -2141,17 +2148,17 @@ snapshots: '@esbuild/win32-x64@0.21.5': optional: true - '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5(jiti@1.21.7))': + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))': dependencies: - eslint: 9.39.5(jiti@1.21.7) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.21.2': + '@eslint/config-array@0.21.2(supports-color@7.2.0)': dependencies: '@eslint/object-schema': 2.1.7 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 3.1.5 transitivePeerDependencies: - supports-color @@ -2164,10 +2171,10 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/eslintrc@3.3.6': + '@eslint/eslintrc@3.3.6(supports-color@7.2.0)': dependencies: ajv: 6.15.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) espree: 10.4.0 globals: 14.0.0 ignore: 5.3.2 @@ -2187,6 +2194,8 @@ snapshots: '@eslint/core': 0.17.0 levn: 0.4.1 + '@fontsource-variable/archivo@5.3.0': {} + '@fontsource/instrument-sans@5.2.8': {} '@fontsource/jetbrains-mono@5.2.8': {} @@ -2464,15 +2473,15 @@ snapshots: '@types/prop-types': 15.7.15 csstype: 3.2.3 - '@typescript-eslint/eslint-plugin@8.64.0(@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3)': + '@typescript-eslint/eslint-plugin@8.64.0(@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) + '@typescript-eslint/parser': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.64.0 - '@typescript-eslint/type-utils': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) - '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) + '@typescript-eslint/type-utils': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.64.0 - eslint: 9.39.5(jiti@1.21.7) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) ignore: 7.0.6 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@5.9.3) @@ -2480,23 +2489,23 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3)': + '@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.64.0 '@typescript-eslint/types': 8.64.0 - '@typescript-eslint/typescript-estree': 8.64.0(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.64.0(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.64.0 - debug: 4.4.3 - eslint: 9.39.5(jiti@1.21.7) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.64.0(typescript@5.9.3)': + '@typescript-eslint/project-service@8.64.0(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.64.0(typescript@5.9.3) '@typescript-eslint/types': 8.64.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -2510,13 +2519,13 @@ snapshots: dependencies: typescript: 5.9.3 - '@typescript-eslint/type-utils@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3)': + '@typescript-eslint/type-utils@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.64.0 - '@typescript-eslint/typescript-estree': 8.64.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) - debug: 4.4.3 - eslint: 9.39.5(jiti@1.21.7) + '@typescript-eslint/typescript-estree': 8.64.0(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) ts-api-utils: 2.5.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: @@ -2524,13 +2533,13 @@ snapshots: '@typescript-eslint/types@8.64.0': {} - '@typescript-eslint/typescript-estree@8.64.0(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.64.0(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.64.0(typescript@5.9.3) + '@typescript-eslint/project-service': 8.64.0(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/tsconfig-utils': 8.64.0(typescript@5.9.3) '@typescript-eslint/types': 8.64.0 '@typescript-eslint/visitor-keys': 8.64.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 10.2.5 semver: 7.8.5 tinyglobby: 0.2.17 @@ -2539,13 +2548,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3)': + '@typescript-eslint/utils@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@1.21.7)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)) '@typescript-eslint/scope-manager': 8.64.0 '@typescript-eslint/types': 8.64.0 - '@typescript-eslint/typescript-estree': 8.64.0(typescript@5.9.3) - eslint: 9.39.5(jiti@1.21.7) + '@typescript-eslint/typescript-estree': 8.64.0(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -2555,11 +2564,11 @@ snapshots: '@typescript-eslint/types': 8.64.0 eslint-visitor-keys: 5.0.1 - '@vitejs/plugin-react@4.7.0(vite@5.4.21)': + '@vitejs/plugin-react@4.7.0(supports-color@7.2.0)(vite@5.4.21)': dependencies: - '@babel/core': 7.29.7 - '@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7) - '@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7) + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0)) '@rolldown/pluginutils': 1.0.0-beta.27 '@types/babel__core': 7.20.5 react-refresh: 0.17.0 @@ -2769,9 +2778,11 @@ snapshots: whatwg-mimetype: 4.0.0 whatwg-url: 14.2.0 - debug@4.4.3: + debug@4.4.3(supports-color@7.2.0): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 decimal.js@10.6.0: {} @@ -2848,13 +2859,13 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-plugin-react-hooks@5.2.0(eslint@9.39.5(jiti@1.21.7)): + eslint-plugin-react-hooks@5.2.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)): dependencies: - eslint: 9.39.5(jiti@1.21.7) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) - eslint-plugin-react-refresh@0.4.26(eslint@9.39.5(jiti@1.21.7)): + eslint-plugin-react-refresh@0.4.26(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)): dependencies: - eslint: 9.39.5(jiti@1.21.7) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) eslint-scope@8.4.0: dependencies: @@ -2867,14 +2878,14 @@ snapshots: eslint-visitor-keys@5.0.1: {} - eslint@9.39.5(jiti@1.21.7): + eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0): dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@1.21.7)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0)) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.21.2 + '@eslint/config-array': 0.21.2(supports-color@7.2.0) '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 - '@eslint/eslintrc': 3.3.6 + '@eslint/eslintrc': 3.3.6(supports-color@7.2.0) '@eslint/js': 9.39.5 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.8 @@ -2884,7 +2895,7 @@ snapshots: ajv: 6.15.0 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1 @@ -3039,17 +3050,17 @@ snapshots: dependencies: whatwg-encoding: 3.1.1 - http-proxy-agent@7.0.2: + http-proxy-agent@7.0.2(supports-color@7.2.0): dependencies: agent-base: 7.1.4 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color - https-proxy-agent@7.0.6: + https-proxy-agent@7.0.6(supports-color@7.2.0): dependencies: agent-base: 7.1.4 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -3100,15 +3111,15 @@ snapshots: dependencies: argparse: 2.0.1 - jsdom@25.0.1: + jsdom@25.0.1(supports-color@7.2.0): dependencies: cssstyle: 4.6.0 data-urls: 5.0.0 decimal.js: 10.6.0 form-data: 4.0.6 html-encoding-sniffer: 4.0.0 - http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.6 + http-proxy-agent: 7.0.2(supports-color@7.2.0) + https-proxy-agent: 7.0.6(supports-color@7.2.0) is-potential-custom-element-name: 1.0.1 nwsapi: 2.2.24 parse5: 7.3.0 @@ -3532,13 +3543,13 @@ snapshots: dependencies: prelude-ls: 1.2.1 - typescript-eslint@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3): + typescript-eslint@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.64.0(@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) - '@typescript-eslint/parser': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) - '@typescript-eslint/typescript-estree': 8.64.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7))(typescript@5.9.3) - eslint: 9.39.5(jiti@1.21.7) + '@typescript-eslint/eslint-plugin': 8.64.0(@typescript-eslint/parser@8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/parser': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.64.0(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.64.0(eslint@9.39.5(jiti@1.21.7)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.5(jiti@1.21.7)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -3561,10 +3572,10 @@ snapshots: util-deprecate@1.0.2: {} - vite-node@2.1.9: + vite-node@2.1.9(supports-color@7.2.0): dependencies: cac: 6.7.14 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) es-module-lexer: 1.7.0 pathe: 1.1.2 vite: 5.4.21 @@ -3587,7 +3598,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - vitest@2.1.9(jsdom@25.0.1): + vitest@2.1.9(jsdom@25.0.1(supports-color@7.2.0))(supports-color@7.2.0): dependencies: '@vitest/expect': 2.1.9 '@vitest/mocker': 2.1.9(vite@5.4.21) @@ -3597,7 +3608,7 @@ snapshots: '@vitest/spy': 2.1.9 '@vitest/utils': 2.1.9 chai: 5.3.3 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) expect-type: 1.4.0 magic-string: 0.30.21 pathe: 1.1.2 @@ -3607,10 +3618,10 @@ snapshots: tinypool: 1.1.1 tinyrainbow: 1.2.0 vite: 5.4.21 - vite-node: 2.1.9 + vite-node: 2.1.9(supports-color@7.2.0) why-is-node-running: 2.3.0 optionalDependencies: - jsdom: 25.0.1 + jsdom: 25.0.1(supports-color@7.2.0) transitivePeerDependencies: - less - lightningcss diff --git a/public/theme-init.js b/public/theme-init.js new file mode 100644 index 0000000..34182ea --- /dev/null +++ b/public/theme-init.js @@ -0,0 +1,23 @@ +/* + * Runs (blocking, same origin, no inline script) before first paint so the page never flashes the + * wrong theme. Mirrors resolveInitialMode() in src/theme/tokens.ts (BR-U1-2, BR-U1-5): + * variant is always "b"; mode = valid stored mode, else the system preference. + */ +(function () { + var mode = 'light'; + try { + var stored = window.localStorage.getItem('slp-software-mode'); + if (stored === 'light' || stored === 'dark') { + mode = stored; + } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + mode = 'dark'; + } + } catch (e) { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + mode = 'dark'; + } + } + var root = document.documentElement; + root.setAttribute('data-variant', 'b'); + root.setAttribute('data-mode', mode); +})(); diff --git a/src/components/layout/EBoundary.tsx b/src/components/layout/EBoundary.tsx new file mode 100644 index 0000000..259700f --- /dev/null +++ b/src/components/layout/EBoundary.tsx @@ -0,0 +1,29 @@ +import { Component } from 'react'; +import type { ErrorInfo, ReactNode } from 'react'; + +interface EBoundaryProps { + children: ReactNode; + /** Falls back to variant B and shows the alert (BR-U1-8). */ + onError: () => void; +} + +/** Error boundary around the lazy E variant: a crash in E never takes the whole site down. */ +export class EBoundary extends Component { + state = { failed: false }; + + static getDerivedStateFromError() { + return { failed: true }; + } + + componentDidCatch(error: Error, info: ErrorInfo) { + console.error('Variant E crashed', error, info.componentStack); + this.props.onError(); + } + + render() { + if (this.state.failed) { + return null; + } + return this.props.children; + } +} diff --git a/src/components/layout/LiveRegion.tsx b/src/components/layout/LiveRegion.tsx new file mode 100644 index 0000000..549ffee --- /dev/null +++ b/src/components/layout/LiveRegion.tsx @@ -0,0 +1,12 @@ +import { useTheme } from '../../theme/ThemeProvider'; + +/** Polite live region that announces variant changes to screen readers (BR-U1-7). */ +export function LiveRegion() { + const { announcement } = useTheme(); + + return ( +
+ {announcement} +
+ ); +} diff --git a/src/components/layout/Nav.tsx b/src/components/layout/Nav.tsx index cbbc70d..7126888 100644 --- a/src/components/layout/Nav.tsx +++ b/src/components/layout/Nav.tsx @@ -1,6 +1,7 @@ import { useState } from 'react'; import { navLinks } from '../../features/landing/data/content'; -import { ThemeToggle } from '../ui/ThemeToggle'; +import { ModeToggle } from '../ui/ModeToggle'; +import { VariantToggle } from '../ui/VariantToggle'; import { handleAnchorClick } from '../../utils/scrollToHash'; export function Nav() { @@ -21,7 +22,7 @@ export function Nav() { > SLP.Software -
    +
      {navLinks.map((link) => link.isCta ? (
    • @@ -47,7 +48,10 @@ export function Nav() { ), )}
    • - + +
    • +
    • +
    • + + + ); +} diff --git a/src/components/layout/VariantRenderer.tsx b/src/components/layout/VariantRenderer.tsx new file mode 100644 index 0000000..7fd2232 --- /dev/null +++ b/src/components/layout/VariantRenderer.tsx @@ -0,0 +1,28 @@ +import { lazy, Suspense } from 'react'; +import type { ReactNode } from 'react'; +import { useTheme } from '../../theme/ThemeProvider'; +import { EBoundary } from './EBoundary'; + +// Variant E is its own chunk (FR-6): visitors who never use the easter egg never download it. +const LandingE = lazy(() => import('../../variants/e/LandingE')); + +/** + * Renders the eager B shell or the lazy E landing depending on the current variant. The + * transition (see ThemeProvider) preloads the E chunk before the swap, so the Suspense fallback is + * only a safety net. + */ +export function VariantRenderer({ b }: { b: ReactNode }) { + const { variant, reportVariantError } = useTheme(); + + if (variant === 'b') { + return <>{b}; + } + + return ( + + + + + + ); +} diff --git a/src/components/layout/__tests__/Nav.test.tsx b/src/components/layout/__tests__/Nav.test.tsx index d0ebb44..d6062aa 100644 --- a/src/components/layout/__tests__/Nav.test.tsx +++ b/src/components/layout/__tests__/Nav.test.tsx @@ -14,7 +14,6 @@ function renderNav() { describe('Nav', () => { beforeEach(() => { window.localStorage.clear(); - document.documentElement.className = ''; }); it('renders all nav links including the CTA', () => { @@ -25,14 +24,24 @@ describe('Nav', () => { expect(screen.getByTestId('nav-cta-link')).toHaveTextContent('Start project'); }); - it('renders the theme toggle with a Dutch accessible label', () => { + it('renders the mode toggle and the icon-only variant toggle with Dutch labels', () => { renderNav(); - expect(screen.getByRole('button', { name: 'Wissel kleurthema' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Donkere weergave' })).toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'Tijdreis: bekijk de site zoals vroeger' }), + ).toBeInTheDocument(); }); - it('toggles the theme when the toggle button is clicked', () => { + it('puts the variant toggle right after the mode toggle', () => { renderNav(); - const toggle = screen.getByTestId('theme-toggle-button'); + const mode = screen.getByTestId('mode-toggle-button'); + const variant = screen.getByTestId('variant-toggle-button'); + expect(mode.compareDocumentPosition(variant) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + }); + + it('toggles the mode when the mode toggle is clicked', () => { + renderNav(); + const toggle = screen.getByTestId('mode-toggle-button'); expect(toggle).toHaveAttribute('aria-pressed', 'false'); fireEvent.click(toggle); expect(toggle).toHaveAttribute('aria-pressed', 'true'); @@ -58,11 +67,10 @@ describe('Nav', () => { renderNav(); fireEvent.click(screen.getByTestId('nav-mobile-toggle')); const mobileMenu = screen.getByTestId('nav-mobile-menu'); - - const link = mobileMenu.querySelector('a[href="#pakketten"]'); + expect(mobileMenu).toBeInTheDocument(); + const link = mobileMenu.querySelector('a'); expect(link).not.toBeNull(); fireEvent.click(link as HTMLAnchorElement); - expect(screen.queryByTestId('nav-mobile-menu')).not.toBeInTheDocument(); }); }); diff --git a/src/components/layout/__tests__/VariantRenderer.test.tsx b/src/components/layout/__tests__/VariantRenderer.test.tsx new file mode 100644 index 0000000..aa78be1 --- /dev/null +++ b/src/components/layout/__tests__/VariantRenderer.test.tsx @@ -0,0 +1,131 @@ +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { VariantRenderer } from '../VariantRenderer'; +import { TransitionOverlay } from '../TransitionOverlay'; +import { LiveRegion } from '../LiveRegion'; +import { VariantAlert } from '../VariantAlert'; +import { EBoundary } from '../EBoundary'; +import { ThemeProvider } from '../../../theme/ThemeProvider'; +import { VariantToggle } from '../../ui/VariantToggle'; +import { clearMatchMedia, mockMatchMedia } from '../../../test/matchMedia'; +import { REDUCED_MOTION_QUERY } from '../../../shared/hooks/usePrefersReducedMotion'; + +function renderApp(loadVariant: (v: 'b' | 'e') => Promise = () => Promise.resolve()) { + return render( + + + +
      + Moderne weergave +
      + + } + /> + + + +
      , + ); +} + +describe('VariantRenderer and transition UI', () => { + beforeEach(() => window.localStorage.clear()); + afterEach(() => { + clearMatchMedia(); + vi.restoreAllMocks(); + }); + + it('renders B first', () => { + renderApp(); + expect(screen.getByText('Moderne weergave')).toBeInTheDocument(); + expect(screen.queryByRole('heading', { name: 'Tijdreis' })).not.toBeInTheDocument(); + }); + + it('shows the lazy E landing after the switch and announces it (FR-6, BR-U1-7)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderApp(); + fireEvent.click(screen.getByTestId('variant-toggle-button')); + expect(await screen.findByRole('heading', { name: 'Tijdreis' })).toBeInTheDocument(); + expect(screen.queryByText('Moderne weergave')).not.toBeInTheDocument(); + await waitFor(() => + expect(screen.getByTestId('live-region')).toHaveTextContent('Tijdreis-weergave geladen.'), + ); + + // The way back to B exists inside E. + fireEvent.click(screen.getAllByTestId('variant-toggle-button')[0]); + expect(await screen.findByText('Moderne weergave')).toBeInTheDocument(); + }); + + it('shows the dither overlay during the transition (BR-U1-6)', async () => { + mockMatchMedia(); + renderApp(); + expect(screen.queryByTestId('transition-overlay')).not.toBeInTheDocument(); + fireEvent.click(screen.getByTestId('variant-toggle-button')); + expect(screen.getByTestId('transition-overlay')).toHaveAttribute('data-phase', 'cover'); + expect(screen.getByTestId('transition-overlay')).toHaveAttribute('aria-hidden', 'true'); + await waitFor( + () => expect(screen.queryByTestId('transition-overlay')).not.toBeInTheDocument(), + { + timeout: 2000, + }, + ); + }); + + it('renders no overlay at all under reduced motion (BR-U1-9)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderApp(); + fireEvent.click(screen.getByTestId('variant-toggle-button')); + expect(screen.queryByTestId('transition-overlay')).not.toBeInTheDocument(); + await screen.findByRole('heading', { name: 'Tijdreis' }); + expect(screen.queryByTestId('transition-overlay')).not.toBeInTheDocument(); + }); + + it('stays in B with an alert when E cannot be loaded, and retry recovers (BR-U1-8)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + const load = vi + .fn<(v: 'b' | 'e') => Promise>() + .mockRejectedValueOnce(new Error('offline')) + .mockResolvedValue(undefined); + renderApp(load); + fireEvent.click(screen.getByTestId('variant-toggle-button')); + + expect(await screen.findByRole('alert')).toHaveTextContent( + 'De tijdreis kon niet worden geladen.', + ); + expect(screen.getByText('Moderne weergave')).toBeInTheDocument(); + + fireEvent.click(screen.getByTestId('variant-alert-retry')); + expect(await screen.findByRole('heading', { name: 'Tijdreis' })).toBeInTheDocument(); + expect(screen.queryByRole('alert')).not.toBeInTheDocument(); + }); + + it('lets the visitor dismiss the alert', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderApp(() => Promise.reject(new Error('offline'))); + fireEvent.click(screen.getByTestId('variant-toggle-button')); + await screen.findByRole('alert'); + fireEvent.click(screen.getByTestId('variant-alert-dismiss')); + expect(screen.queryByRole('alert')).not.toBeInTheDocument(); + }); +}); + +describe('EBoundary', () => { + afterEach(() => vi.restoreAllMocks()); + + it('calls onError and renders nothing when the child throws (BR-U1-8)', () => { + vi.spyOn(console, 'error').mockImplementation(() => {}); + const onError = vi.fn(); + function Bomb(): never { + throw new Error('boom'); + } + const { container } = render( + + + , + ); + expect(onError).toHaveBeenCalledTimes(1); + expect(container).toBeEmptyDOMElement(); + }); +}); diff --git a/src/components/ui/ModeToggle.tsx b/src/components/ui/ModeToggle.tsx new file mode 100644 index 0000000..d95ac6d --- /dev/null +++ b/src/components/ui/ModeToggle.tsx @@ -0,0 +1,44 @@ +import { useTheme } from '../../theme/ThemeProvider'; + +/** + * Light/dark switch (requirements FR-4, BR-U1-4, BR-U1-12). Two states; starts from the system + * preference and remembers the visitor's choice after the first click. + */ +export function ModeToggle() { + const { mode, toggleMode } = useTheme(); + const isDark = mode === 'dark'; + + return ( + + ); +} diff --git a/src/components/ui/ThemeToggle.tsx b/src/components/ui/ThemeToggle.tsx deleted file mode 100644 index 76627f2..0000000 --- a/src/components/ui/ThemeToggle.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { useTheme } from '../../theme/ThemeProvider'; - -/** - * Visible theme switcher (requirements FR-3, Functional Design Q1/Q7). - * Rendered as a small icon/swatch button in the nav. - */ -export function ThemeToggle() { - const { theme, toggleTheme } = useTheme(); - const isPurple = theme === 'purple'; - - return ( - - ); -} diff --git a/src/components/ui/VariantToggle.tsx b/src/components/ui/VariantToggle.tsx new file mode 100644 index 0000000..a6a8e22 --- /dev/null +++ b/src/components/ui/VariantToggle.tsx @@ -0,0 +1,40 @@ +import { useTheme } from '../../theme/ThemeProvider'; + +/** + * Icon-only button next to the mode toggle that switches between B and E (FR-4, BR-U1-6, + * BR-U1-12). The label changes with the current variant; the tooltip equals the label. + */ +export function VariantToggle() { + const { variant, toggleVariant, transition } = useTheme(); + const inE = variant === 'e'; + const label = inE ? 'Terug naar nu' : 'Tijdreis: bekijk de site zoals vroeger'; + + return ( + + ); +} diff --git a/src/components/ui/__tests__/Toggles.test.tsx b/src/components/ui/__tests__/Toggles.test.tsx new file mode 100644 index 0000000..b6b5eab --- /dev/null +++ b/src/components/ui/__tests__/Toggles.test.tsx @@ -0,0 +1,63 @@ +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { ModeToggle } from '../ModeToggle'; +import { VariantToggle } from '../VariantToggle'; +import { ThemeProvider } from '../../../theme/ThemeProvider'; +import { clearMatchMedia, mockMatchMedia } from '../../../test/matchMedia'; +import { REDUCED_MOTION_QUERY } from '../../../shared/hooks/usePrefersReducedMotion'; + +function renderToggles() { + return render( + Promise.resolve()}> + + +
      + , + ); +} + +describe('ModeToggle', () => { + beforeEach(() => window.localStorage.clear()); + afterEach(() => clearMatchMedia()); + + it('has a Dutch accessible name and reflects the mode in aria-pressed (BR-U1-12)', () => { + renderToggles(); + const button = screen.getByRole('button', { name: 'Donkere weergave' }); + expect(button).toHaveAttribute('aria-pressed', 'false'); + fireEvent.click(button); + expect(button).toHaveAttribute('aria-pressed', 'true'); + }); + + it('is a real button with a touch target of at least 44px on mobile (BR-U1-12)', () => { + renderToggles(); + const button = screen.getByTestId('mode-toggle-button'); + expect(button.tagName).toBe('BUTTON'); + expect(button).toHaveClass('h-11', 'w-11'); + }); +}); + +describe('VariantToggle', () => { + beforeEach(() => window.localStorage.clear()); + afterEach(() => clearMatchMedia()); + + it('is icon-only with a label that changes with the variant (BR-U1-12)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderToggles(); + const button = screen.getByTestId('variant-toggle-button'); + expect(button).toHaveAccessibleName('Tijdreis: bekijk de site zoals vroeger'); + expect(button).toHaveAttribute('title', 'Tijdreis: bekijk de site zoals vroeger'); + expect(button.textContent).toBe(''); + expect(button).toHaveClass('h-11', 'w-11'); + + fireEvent.click(button); + await waitFor(() => expect(button).toHaveAccessibleName('Terug naar nu')); + }); + + it('is disabled while a switch is running', async () => { + renderToggles(); + const button = screen.getByTestId('variant-toggle-button'); + fireEvent.click(button); + expect(button).toBeDisabled(); + await waitFor(() => expect(button).toBeEnabled(), { timeout: 2000 }); + }); +}); diff --git a/src/fonts.ts b/src/fonts.ts index c191b5a..19e2139 100644 --- a/src/fonts.ts +++ b/src/fonts.ts @@ -6,6 +6,9 @@ * Weights match the reference designs' Google Fonts request: * Sora: 400;600;700;800 — Instrument Sans: 400;500;600 — JetBrains Mono: 400;500;700 */ +// Archivo (variable: weight 100-900, width 62-125%) is the display/body face of design B. +// The three families below are removed when the B sections are restyled (unit U2). +import '@fontsource-variable/archivo/wdth.css'; import '@fontsource/sora/400.css'; import '@fontsource/sora/600.css'; import '@fontsource/sora/700.css'; diff --git a/src/index.css b/src/index.css index 060269d..18c4959 100644 --- a/src/index.css +++ b/src/index.css @@ -2,36 +2,73 @@ @tailwind components; @tailwind utilities; -/* Theme tokens — values ported 1-to-1 from References/slp-software-rood.html (red, default) - and References/slp-software.html (purple, alternate). See - aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/domain-entities.md - (ThemeTokens) for the data model these mirror. */ -.theme-red { - --color-bg: #140c0e; - --color-surface: #1f1315; - --color-surface-2: #291719; - --color-line: #402226; - --color-text: #f5eaeb; - --color-muted: #b69c9f; - --color-accent: #e04848; - --color-accent-soft: rgba(224, 72, 72, 0.16); - --color-accent-line: rgba(224, 72, 72, 0.4); - --color-accent-hover: #ea6161; - --color-accent-contrast: #140c0e; +/* Theme tokens: variant (b | e) x mode (light | dark), selected by + (set before first paint by public/theme-init.js and kept in sync by ThemeProvider). + Semantic names stay the same so the Tailwind colors in tailwind.config.ts keep working. + B values follow the canvas design B (accent #7A1414); E values are base tokens, refined per era + in unit U5 (accent #AC0000). See + aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/functional-design/domain-entities.md */ + +/* Default (also used when the attributes are missing): B light. */ +:root, +html[data-variant='b'][data-mode='light'] { + color-scheme: light; + --color-bg: #ffffff; + --color-surface: #f1efec; + --color-surface-2: #faf8f5; + --color-line: #e4e0dc; + --color-text: #0e0d0d; + --color-muted: #5c5753; + --color-accent: #7a1414; + --color-accent-soft: rgba(122, 20, 20, 0.1); + --color-accent-line: rgba(122, 20, 20, 0.35); + --color-accent-hover: #911a1a; + --color-accent-contrast: #ffffff; } -.theme-purple { - --color-bg: #0e1220; - --color-surface: #151a2c; - --color-surface-2: #1b2138; - --color-line: #262e4a; - --color-text: #e9ebf5; - --color-muted: #98a0ba; - --color-accent: #8b7cff; - --color-accent-soft: rgba(139, 124, 255, 0.14); - --color-accent-line: rgba(139, 124, 255, 0.35); - --color-accent-hover: #9d90ff; - --color-accent-contrast: #0e1220; +html[data-variant='b'][data-mode='dark'] { + color-scheme: dark; + --color-bg: #0f0e0e; + --color-surface: #181615; + --color-surface-2: #232020; + --color-line: #3a3532; + --color-text: #f3f0ec; + --color-muted: #b3ada7; + --color-accent: #e5524a; + --color-accent-soft: rgba(229, 82, 74, 0.16); + --color-accent-line: rgba(229, 82, 74, 0.4); + --color-accent-hover: #ec6a62; + --color-accent-contrast: #0f0e0e; +} + +html[data-variant='e'][data-mode='light'] { + color-scheme: light; + --color-bg: #ffffff; + --color-surface: #f3f3f3; + --color-surface-2: #e9e9e9; + --color-line: #d0d0d0; + --color-text: #1a1a1a; + --color-muted: #555555; + --color-accent: #ac0000; + --color-accent-soft: rgba(172, 0, 0, 0.1); + --color-accent-line: rgba(172, 0, 0, 0.35); + --color-accent-hover: #c40000; + --color-accent-contrast: #ffffff; +} + +html[data-variant='e'][data-mode='dark'] { + color-scheme: dark; + --color-bg: #1b1b1d; + --color-surface: #232326; + --color-surface-2: #2c2c30; + --color-line: #3d3d42; + --color-text: #ededed; + --color-muted: #a8a8ad; + --color-accent: #ff6b5e; + --color-accent-soft: rgba(255, 107, 94, 0.16); + --color-accent-line: rgba(255, 107, 94, 0.4); + --color-accent-hover: #ff8277; + --color-accent-contrast: #1b1b1d; } html { @@ -49,15 +86,15 @@ body { color: var(--color-text); } -/* Instant, non-animated theme switch when the visitor prefers reduced motion (BR-5). */ -.theme-red, -.theme-purple { - transition: background-color 0.2s ease, color 0.2s ease; +/* Smooth colour change on mode switch; instant for visitors who prefer reduced motion (BR-U1-9). */ +html { + transition: + background-color 0.2s ease, + color 0.2s ease; } @media (prefers-reduced-motion: reduce) { - .theme-red, - .theme-purple { + html { transition: none; } } @@ -82,3 +119,58 @@ body { animation: none; } } + +/* Time-travel transition between variants (BR-U1-6): a pixel-dither overlay that covers the page + (phase "cover"), stays while the variant swaps, then clears (phase "reveal"). Not rendered at all + under prefers-reduced-motion (see TransitionOverlay) and hidden here as a safety net. */ +@keyframes tt-dither-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + +@keyframes tt-dither-out { + from { + opacity: 1; + } + to { + opacity: 0; + } +} + +.tt-overlay { + position: fixed; + inset: 0; + z-index: 100; + pointer-events: all; + background-color: var(--color-accent); + background-image: conic-gradient( + var(--color-bg) 25%, + transparent 0 50%, + var(--color-bg) 0 75%, + transparent 0 + ); + background-size: 8px 8px; + image-rendering: pixelated; +} + +.tt-overlay[data-phase='cover'] { + animation: tt-dither-in 300ms steps(6) forwards; +} + +.tt-overlay[data-phase='swap'] { + opacity: 1; +} + +.tt-overlay[data-phase='reveal'] { + animation: tt-dither-out 300ms steps(6) forwards; +} + +@media (prefers-reduced-motion: reduce) { + .tt-overlay { + display: none; + } +} diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 43da2cf..2d1a957 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -2,6 +2,7 @@ import { createRootRoute, Outlet } from '@tanstack/react-router'; import { QueryClientProvider } from '@tanstack/react-query'; import { ErrorBoundary } from '../components/shared/ErrorBoundary'; import { ThemeProvider } from '../theme/ThemeProvider'; +import { loadVariant } from '../theme/loadVariant'; import { RootLayout } from '../components/layout/RootLayout'; import { queryClient } from '../lib/queryClient'; @@ -12,7 +13,7 @@ import { queryClient } from '../lib/queryClient'; export const rootRoute = createRootRoute({ component: () => ( - + diff --git a/src/shared/hooks/__tests__/mediaQueryHooks.test.tsx b/src/shared/hooks/__tests__/mediaQueryHooks.test.tsx new file mode 100644 index 0000000..8c0819f --- /dev/null +++ b/src/shared/hooks/__tests__/mediaQueryHooks.test.tsx @@ -0,0 +1,36 @@ +import { act, render, screen } from '@testing-library/react'; +import { afterEach, describe, expect, it } from 'vitest'; +import { clearMatchMedia, mockMatchMedia } from '../../../test/matchMedia'; +import { PREFERS_DARK_QUERY, usePrefersDark } from '../usePrefersDark'; +import { REDUCED_MOTION_QUERY, usePrefersReducedMotion } from '../usePrefersReducedMotion'; + +function Probe() { + return ( +
      + {String(usePrefersDark())} + {String(usePrefersReducedMotion())} +
      + ); +} + +describe('media query hooks', () => { + afterEach(() => clearMatchMedia()); + + it('default to false when matchMedia is unavailable', () => { + render(); + expect(screen.getByTestId('dark')).toHaveTextContent('false'); + expect(screen.getByTestId('reduced')).toHaveTextContent('false'); + }); + + it('read the initial value and follow live changes', () => { + const media = mockMatchMedia({ [PREFERS_DARK_QUERY]: true }); + render(); + expect(screen.getByTestId('dark')).toHaveTextContent('true'); + expect(screen.getByTestId('reduced')).toHaveTextContent('false'); + + act(() => media.set(PREFERS_DARK_QUERY, false)); + act(() => media.set(REDUCED_MOTION_QUERY, true)); + expect(screen.getByTestId('dark')).toHaveTextContent('false'); + expect(screen.getByTestId('reduced')).toHaveTextContent('true'); + }); +}); diff --git a/src/shared/hooks/mediaQuery.ts b/src/shared/hooks/mediaQuery.ts new file mode 100644 index 0000000..535dd96 --- /dev/null +++ b/src/shared/hooks/mediaQuery.ts @@ -0,0 +1,25 @@ +import { useSyncExternalStore } from 'react'; + +/** Safe `matchMedia` access: environments without it (jsdom, very old browsers) count as "no match". */ +export function matchesMedia(query: string): boolean { + if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') { + return false; + } + return window.matchMedia(query).matches; +} + +/** Subscribes to a media query and re-renders when its result changes. */ +export function useMediaQuery(query: string): boolean { + return useSyncExternalStore( + (onChange) => { + if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') { + return () => {}; + } + const list = window.matchMedia(query); + list.addEventListener('change', onChange); + return () => list.removeEventListener('change', onChange); + }, + () => matchesMedia(query), + () => false, + ); +} diff --git a/src/shared/hooks/usePrefersDark.ts b/src/shared/hooks/usePrefersDark.ts new file mode 100644 index 0000000..8635d6c --- /dev/null +++ b/src/shared/hooks/usePrefersDark.ts @@ -0,0 +1,8 @@ +import { useMediaQuery } from './mediaQuery'; + +export const PREFERS_DARK_QUERY = '(prefers-color-scheme: dark)'; + +/** BR-U1-2/3: the system colour-scheme preference, live. */ +export function usePrefersDark(): boolean { + return useMediaQuery(PREFERS_DARK_QUERY); +} diff --git a/src/shared/hooks/usePrefersReducedMotion.ts b/src/shared/hooks/usePrefersReducedMotion.ts new file mode 100644 index 0000000..47e0ad5 --- /dev/null +++ b/src/shared/hooks/usePrefersReducedMotion.ts @@ -0,0 +1,8 @@ +import { useMediaQuery } from './mediaQuery'; + +export const REDUCED_MOTION_QUERY = '(prefers-reduced-motion: reduce)'; + +/** BR-U1-9: true when the visitor asks for less motion; all effects must then be skipped. */ +export function usePrefersReducedMotion(): boolean { + return useMediaQuery(REDUCED_MOTION_QUERY); +} diff --git a/src/test/matchMedia.ts b/src/test/matchMedia.ts new file mode 100644 index 0000000..7a3b34e --- /dev/null +++ b/src/test/matchMedia.ts @@ -0,0 +1,42 @@ +import { vi } from 'vitest'; + +type Listener = (event: { matches: boolean }) => void; + +/** + * Installs a controllable `window.matchMedia` (jsdom has none). `initial` maps a media query to + * its current result; `set()` flips a query and notifies subscribers like a real change event. + */ +export function mockMatchMedia(initial: Record = {}) { + const state: Record = { ...initial }; + const listeners = new Map>(); + + window.matchMedia = vi.fn((query: string) => ({ + get matches() { + return Boolean(state[query]); + }, + media: query, + onchange: null, + addEventListener: (_type: string, cb: Listener) => { + if (!listeners.has(query)) listeners.set(query, new Set()); + listeners.get(query)!.add(cb); + }, + removeEventListener: (_type: string, cb: Listener) => { + listeners.get(query)?.delete(cb); + }, + addListener: () => {}, + removeListener: () => {}, + dispatchEvent: () => false, + })) as unknown as typeof window.matchMedia; + + return { + set(query: string, value: boolean) { + state[query] = value; + listeners.get(query)?.forEach((cb) => cb({ matches: value })); + }, + }; +} + +/** Restores the jsdom default: no `matchMedia` at all. */ +export function clearMatchMedia() { + delete (window as unknown as { matchMedia?: unknown }).matchMedia; +} diff --git a/src/test/setup.ts b/src/test/setup.ts index bb02c60..53cba17 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -1 +1,5 @@ import '@testing-library/jest-dom/vitest'; +import { vi } from 'vitest'; + +// jsdom does not implement window.scrollTo; the variant switch scrolls to the top (BR-U1-6). +window.scrollTo = vi.fn() as unknown as typeof window.scrollTo; diff --git a/src/theme/ThemeProvider.tsx b/src/theme/ThemeProvider.tsx index 8414aa1..523a356 100644 --- a/src/theme/ThemeProvider.tsx +++ b/src/theme/ThemeProvider.tsx @@ -1,55 +1,235 @@ -import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import type { ReactNode } from 'react'; import { - DEFAULT_THEME, - THEME_STORAGE_KEY, - resolveInitialTheme, - themeClassName, - type ThemeName, + createContext, + useCallback, + useContext, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; +import type { ReactNode } from 'react'; +import { matchesMedia } from '../shared/hooks/mediaQuery'; +import { PREFERS_DARK_QUERY, usePrefersDark } from '../shared/hooks/usePrefersDark'; +import { usePrefersReducedMotion } from '../shared/hooks/usePrefersReducedMotion'; +import { + DEFAULT_VARIANT, + LEGACY_THEME_STORAGE_KEY, + MODE_STORAGE_KEY, + otherMode, + otherVariant, + resolveInitialMode, + type Mode, + type ModeSource, + type Variant, } from './tokens'; +/** Phases of the time-travel transition (BR-U1-6). `idle` = nothing running. */ +export type TransitionPhase = 'idle' | 'cover' | 'swap' | 'reveal'; + +export interface TransitionState { + phase: TransitionPhase; + target: Variant | null; +} + +/** Duration of the cover and the reveal phase in ms (skipped under reduced motion, BR-U1-9). */ +export const TRANSITION_PHASE_MS = 300; + interface ThemeContextValue { - theme: ThemeName; - toggleTheme: () => void; + variant: Variant; + mode: Mode; + modeSource: ModeSource; + toggleMode: () => void; + toggleVariant: () => void; + transition: TransitionState; + /** Text for the polite live region (BR-U1-7). */ + announcement: string; + /** True when switching to E failed (chunk could not be loaded or E crashed), BR-U1-8. */ + variantError: boolean; + retryVariant: () => void; + dismissVariantError: () => void; + /** Called by the E error boundary: falls back to B and shows the alert. */ + reportVariantError: () => void; } const ThemeContext = createContext(undefined); -function readStoredTheme(): string | null { +function readStoredMode(): string | null { try { - return window.localStorage.getItem(THEME_STORAGE_KEY); + return window.localStorage.getItem(MODE_STORAGE_KEY); } catch { - // BR-3: treat unavailable/unreadable storage the same as "nothing stored" — fall back to default. + // Treat unavailable/unreadable storage the same as "nothing stored". return null; } } -function persistTheme(theme: ThemeName): void { +function persistMode(mode: Mode): void { try { - window.localStorage.setItem(THEME_STORAGE_KEY, theme); + window.localStorage.setItem(MODE_STORAGE_KEY, mode); } catch { - // Ignore write failures (e.g. storage disabled) — theme still works for this session via state. + // Ignore write failures (storage disabled): the mode still works for this session. } } -export function ThemeProvider({ children }: { children: ReactNode }) { - const [theme, setTheme] = useState(() => resolveInitialTheme(readStoredTheme())); +function removeLegacyThemeKey(): void { + try { + window.localStorage.removeItem(LEGACY_THEME_STORAGE_KEY); + } catch { + // Nothing to clean up when storage is unavailable. + } +} + +const ANNOUNCE_TO_E = 'Tijdreis-weergave geladen.'; +const ANNOUNCE_TO_B = 'Terug naar de moderne weergave.'; + +function wait(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +interface ThemeProviderProps { + children: ReactNode; + /** + * Preloads what a variant needs before the swap (E is a lazy chunk). Rejecting keeps the + * current variant and raises `variantError` (BR-U1-8). Default: nothing to load. + */ + loadVariant?: (variant: Variant) => Promise; +} + +export function ThemeProvider({ children, loadVariant }: ThemeProviderProps) { + const systemDark = usePrefersDark(); + const reducedMotion = usePrefersReducedMotion(); + + const [initial] = useState(() => + resolveInitialMode(readStoredMode(), matchesMedia(PREFERS_DARK_QUERY)), + ); + const [variant, setVariant] = useState(DEFAULT_VARIANT); + const [mode, setMode] = useState(initial.mode); + const [modeSource, setModeSource] = useState(initial.source); + const [transition, setTransition] = useState({ phase: 'idle', target: null }); + const [announcement, setAnnouncement] = useState(''); + const [variantError, setVariantError] = useState(false); + + const busyRef = useRef(false); + const mountedRef = useRef(true); useEffect(() => { - const root = document.documentElement; - root.classList.remove('theme-red', 'theme-purple'); - root.classList.add(themeClassName(theme)); - }, [theme]); - - const toggleTheme = useCallback(() => { - setTheme((current) => { - const next: ThemeName = current === 'red' ? 'purple' : 'red'; - persistTheme(next); - return next; - }); + mountedRef.current = true; + return () => { + mountedRef.current = false; + }; }, []); - const value = useMemo(() => ({ theme, toggleTheme }), [theme, toggleTheme]); + // BR-U1-11: the red/purple key is obsolete. + useEffect(() => { + removeLegacyThemeKey(); + }, []); + + // BR-U1-3: follow the system preference until the visitor has chosen. + useEffect(() => { + if (modeSource === 'system') { + setMode(systemDark ? 'dark' : 'light'); + } + }, [systemDark, modeSource]); + + // Keep in sync (theme-init.js already set the same values before first paint). + useEffect(() => { + const root = document.documentElement; + root.setAttribute('data-variant', variant); + root.setAttribute('data-mode', mode); + root.classList.remove('theme-red', 'theme-purple'); + }, [variant, mode]); + + const toggleMode = useCallback(() => { + const next = otherMode(mode); + setMode(next); + setModeSource('user'); + persistMode(next); + }, [mode]); + + const runSwitch = useCallback( + async (target: Variant) => { + if (busyRef.current) { + return; + } + busyRef.current = true; + setVariantError(false); + const phaseMs = reducedMotion ? 0 : TRANSITION_PHASE_MS; + try { + setTransition({ phase: 'cover', target }); + // The cover runs while the target variant loads; both must finish before the swap. + await Promise.all([wait(phaseMs), loadVariant ? loadVariant(target) : Promise.resolve()]); + if (!mountedRef.current) { + return; + } + setVariant(target); + setTransition({ phase: 'swap', target }); + // Let React render the new variant, then scroll/focus (BR-U1-6) and announce (BR-U1-7). + await wait(0); + window.scrollTo({ top: 0, left: 0, behavior: 'instant' }); + document.getElementById('main')?.focus({ preventScroll: true }); + setAnnouncement(target === 'e' ? ANNOUNCE_TO_E : ANNOUNCE_TO_B); + setTransition({ phase: 'reveal', target }); + await wait(phaseMs); + } catch { + // BR-U1-8: stay in the current variant and tell the visitor. + if (mountedRef.current) { + setVariantError(true); + setAnnouncement('De tijdreis kon niet worden geladen.'); + } + } finally { + busyRef.current = false; + if (mountedRef.current) { + setTransition({ phase: 'idle', target: null }); + } + } + }, + [loadVariant, reducedMotion], + ); + + const toggleVariant = useCallback(() => { + void runSwitch(otherVariant(variant)); + }, [runSwitch, variant]); + + const retryVariant = useCallback(() => { + void runSwitch('e'); + }, [runSwitch]); + + const dismissVariantError = useCallback(() => setVariantError(false), []); + + const reportVariantError = useCallback(() => { + setVariant(DEFAULT_VARIANT); + setVariantError(true); + setAnnouncement('De tijdreis kon niet worden geladen.'); + setTransition({ phase: 'idle', target: null }); + }, []); + + const value = useMemo( + () => ({ + variant, + mode, + modeSource, + toggleMode, + toggleVariant, + transition, + announcement, + variantError, + retryVariant, + dismissVariantError, + reportVariantError, + }), + [ + variant, + mode, + modeSource, + toggleMode, + toggleVariant, + transition, + announcement, + variantError, + retryVariant, + dismissVariantError, + reportVariantError, + ], + ); return {children}; } @@ -61,5 +241,3 @@ export function useTheme(): ThemeContextValue { } return context; } - -export { DEFAULT_THEME }; diff --git a/src/theme/__tests__/ThemeProvider.test.tsx b/src/theme/__tests__/ThemeProvider.test.tsx index 91c34d7..e76bc9c 100644 --- a/src/theme/__tests__/ThemeProvider.test.tsx +++ b/src/theme/__tests__/ThemeProvider.test.tsx @@ -1,63 +1,210 @@ -import { render, screen, fireEvent } from '@testing-library/react'; -import { describe, it, expect, beforeEach } from 'vitest'; -import { ThemeProvider, useTheme } from '../ThemeProvider'; -import { THEME_STORAGE_KEY } from '../tokens'; +import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { ThemeProvider, TRANSITION_PHASE_MS, useTheme } from '../ThemeProvider'; +import { LEGACY_THEME_STORAGE_KEY, MODE_STORAGE_KEY } from '../tokens'; +import { clearMatchMedia, mockMatchMedia } from '../../test/matchMedia'; +import { PREFERS_DARK_QUERY } from '../../shared/hooks/usePrefersDark'; +import { REDUCED_MOTION_QUERY } from '../../shared/hooks/usePrefersReducedMotion'; function ThemeProbe() { - const { theme, toggleTheme } = useTheme(); + const t = useTheme(); return (
      - {theme} - + {t.variant} + {t.mode} + {t.modeSource} + {t.transition.phase} + {t.announcement} + {String(t.variantError)} + + + +
      ); } +function renderProvider(loadVariant?: (v: 'b' | 'e') => Promise) { + return render( + + + , + ); +} + describe('ThemeProvider', () => { beforeEach(() => { window.localStorage.clear(); - document.documentElement.className = ''; + document.documentElement.removeAttribute('data-variant'); + document.documentElement.removeAttribute('data-mode'); + vi.mocked(window.scrollTo).mockClear(); + }); + afterEach(() => { + clearMatchMedia(); + vi.restoreAllMocks(); + vi.useRealTimers(); }); - it('defaults to red when nothing is stored (BR-1)', () => { - render( - - - , - ); - expect(screen.getByTestId('current-theme')).toHaveTextContent('red'); - expect(document.documentElement.classList.contains('theme-red')).toBe(true); + describe('mode', () => { + it('starts in B and follows the system preference when nothing is stored (BR-U1-1, 2)', () => { + mockMatchMedia({ [PREFERS_DARK_QUERY]: true }); + renderProvider(); + expect(screen.getByTestId('variant')).toHaveTextContent('b'); + expect(screen.getByTestId('mode')).toHaveTextContent('dark'); + expect(screen.getByTestId('source')).toHaveTextContent('system'); + expect(document.documentElement).toHaveAttribute('data-variant', 'b'); + expect(document.documentElement).toHaveAttribute('data-mode', 'dark'); + }); + + it('uses light when the system preference is unavailable', () => { + renderProvider(); + expect(screen.getByTestId('mode')).toHaveTextContent('light'); + }); + + it('prefers a valid stored mode over the system preference', () => { + mockMatchMedia({ [PREFERS_DARK_QUERY]: true }); + window.localStorage.setItem(MODE_STORAGE_KEY, 'light'); + renderProvider(); + expect(screen.getByTestId('mode')).toHaveTextContent('light'); + expect(screen.getByTestId('source')).toHaveTextContent('user'); + }); + + it('ignores an invalid stored mode', () => { + window.localStorage.setItem(MODE_STORAGE_KEY, 'purple'); + renderProvider(); + expect(screen.getByTestId('mode')).toHaveTextContent('light'); + expect(screen.getByTestId('source')).toHaveTextContent('system'); + }); + + it('removes the legacy red/purple key once (BR-U1-11)', () => { + window.localStorage.setItem(LEGACY_THEME_STORAGE_KEY, 'purple'); + renderProvider(); + expect(window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY)).toBeNull(); + }); + + it('follows system changes until the visitor clicks (BR-U1-3)', () => { + const media = mockMatchMedia({ [PREFERS_DARK_QUERY]: false }); + renderProvider(); + act(() => media.set(PREFERS_DARK_QUERY, true)); + expect(screen.getByTestId('mode')).toHaveTextContent('dark'); + + fireEvent.click(screen.getByText('mode')); + expect(screen.getByTestId('mode')).toHaveTextContent('light'); + expect(screen.getByTestId('source')).toHaveTextContent('user'); + + act(() => media.set(PREFERS_DARK_QUERY, false)); + act(() => media.set(PREFERS_DARK_QUERY, true)); + expect(screen.getByTestId('mode')).toHaveTextContent('light'); + }); + + it('persists the chosen mode and updates (BR-U1-4)', () => { + renderProvider(); + fireEvent.click(screen.getByText('mode')); + expect(screen.getByTestId('mode')).toHaveTextContent('dark'); + expect(window.localStorage.getItem(MODE_STORAGE_KEY)).toBe('dark'); + expect(document.documentElement).toHaveAttribute('data-mode', 'dark'); + }); + + it('still toggles when storage is unavailable (BR-U1-4)', () => { + vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => { + throw new Error('blocked'); + }); + vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => { + throw new Error('blocked'); + }); + renderProvider(); + fireEvent.click(screen.getByText('mode')); + expect(screen.getByTestId('mode')).toHaveTextContent('dark'); + }); }); - it('persists the chosen theme to localStorage on toggle (BR-2)', () => { - render( - - - , - ); - fireEvent.click(screen.getByText('toggle')); - expect(screen.getByTestId('current-theme')).toHaveTextContent('purple'); - expect(window.localStorage.getItem(THEME_STORAGE_KEY)).toBe('purple'); - expect(document.documentElement.classList.contains('theme-purple')).toBe(true); - }); + describe('variant', () => { + it('never stores the variant (BR-U1-1)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderProvider(() => Promise.resolve()); + fireEvent.click(screen.getByText('variant')); + await waitFor(() => expect(screen.getByTestId('variant')).toHaveTextContent('e')); + await waitFor(() => expect(screen.getByTestId('phase')).toHaveTextContent('idle')); + expect(window.localStorage.length).toBe(0); + }); - it('falls back to the default theme when the stored value is invalid (BR-3)', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'blue'); - render( - - - , - ); - expect(screen.getByTestId('current-theme')).toHaveTextContent('red'); - }); + it('switches to E, scrolls to the top, focuses main and announces (BR-U1-6, 7)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderProvider(() => Promise.resolve()); + fireEvent.click(screen.getByText('variant')); + await waitFor(() => + expect(screen.getByTestId('announcement')).toHaveTextContent('Tijdreis-weergave geladen.'), + ); + expect(screen.getByTestId('variant')).toHaveTextContent('e'); + expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, left: 0, behavior: 'instant' }); + expect(document.activeElement).toBe(screen.getByTestId('main')); + expect(document.documentElement).toHaveAttribute('data-variant', 'e'); - it('uses a valid stored theme on load', () => { - window.localStorage.setItem(THEME_STORAGE_KEY, 'purple'); - render( - - - , - ); - expect(screen.getByTestId('current-theme')).toHaveTextContent('purple'); + await waitFor(() => expect(screen.getByTestId('phase')).toHaveTextContent('idle')); + fireEvent.click(screen.getByText('variant')); + await waitFor(() => + expect(screen.getByTestId('announcement')).toHaveTextContent( + 'Terug naar de moderne weergave.', + ), + ); + expect(screen.getByTestId('variant')).toHaveTextContent('b'); + }); + + it('keeps the mode when switching variant (BR-U1-10)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + renderProvider(() => Promise.resolve()); + fireEvent.click(screen.getByText('mode')); + fireEvent.click(screen.getByText('variant')); + await waitFor(() => expect(screen.getByTestId('variant')).toHaveTextContent('e')); + expect(screen.getByTestId('mode')).toHaveTextContent('dark'); + }); + + it('runs cover -> swap -> reveal -> idle with the dither timings (BR-U1-6)', async () => { + vi.useFakeTimers(); + mockMatchMedia(); + let release: () => void = () => {}; + const load = vi.fn(() => new Promise((resolve) => (release = resolve))); + renderProvider(load); + + fireEvent.click(screen.getByText('variant')); + expect(screen.getByTestId('phase')).toHaveTextContent('cover'); + expect(load).toHaveBeenCalledWith('e'); + + // The cover time alone is not enough: the chunk must be loaded as well. + await act(async () => { + await vi.advanceTimersByTimeAsync(TRANSITION_PHASE_MS); + }); + expect(screen.getByTestId('variant')).toHaveTextContent('b'); + + await act(async () => { + release(); + await vi.advanceTimersByTimeAsync(0); + }); + expect(screen.getByTestId('variant')).toHaveTextContent('e'); + expect(screen.getByTestId('phase')).toHaveTextContent('reveal'); + + await act(async () => { + await vi.advanceTimersByTimeAsync(TRANSITION_PHASE_MS); + }); + expect(screen.getByTestId('phase')).toHaveTextContent('idle'); + }); + + it('stays in B and reports an error when loading E fails, retry works (BR-U1-8)', async () => { + mockMatchMedia({ [REDUCED_MOTION_QUERY]: true }); + const load = vi + .fn<(v: 'b' | 'e') => Promise>() + .mockRejectedValueOnce(new Error('chunk failed')) + .mockResolvedValue(undefined); + renderProvider(load); + + fireEvent.click(screen.getByText('variant')); + await waitFor(() => expect(screen.getByTestId('error')).toHaveTextContent('true')); + expect(screen.getByTestId('variant')).toHaveTextContent('b'); + expect(screen.getByTestId('phase')).toHaveTextContent('idle'); + + fireEvent.click(screen.getByText('retry')); + await waitFor(() => expect(screen.getByTestId('variant')).toHaveTextContent('e')); + expect(screen.getByTestId('error')).toHaveTextContent('false'); + }); }); }); diff --git a/src/theme/__tests__/tokens.test.ts b/src/theme/__tests__/tokens.test.ts new file mode 100644 index 0000000..00ade65 --- /dev/null +++ b/src/theme/__tests__/tokens.test.ts @@ -0,0 +1,32 @@ +import { describe, it, expect } from 'vitest'; +import { isValidMode, otherMode, otherVariant, resolveInitialMode } from '../tokens'; + +describe('resolveInitialMode (BR-U1-2)', () => { + it.each([ + ['light', true, 'light', 'user'], + ['dark', false, 'dark', 'user'], + [null, true, 'dark', 'system'], + [null, false, 'light', 'system'], + ['blue', true, 'dark', 'system'], + ['', false, 'light', 'system'], + ['purple', false, 'light', 'system'], + ] as const)('stored=%s systemDark=%s -> %s (%s)', (stored, systemDark, mode, source) => { + expect(resolveInitialMode(stored, systemDark)).toEqual({ mode, source }); + }); +}); + +describe('helpers', () => { + it('validates only light and dark', () => { + expect(isValidMode('light')).toBe(true); + expect(isValidMode('dark')).toBe(true); + expect(isValidMode('red')).toBe(false); + expect(isValidMode(undefined)).toBe(false); + }); + + it('flips mode and variant', () => { + expect(otherMode('light')).toBe('dark'); + expect(otherMode('dark')).toBe('light'); + expect(otherVariant('b')).toBe('e'); + expect(otherVariant('e')).toBe('b'); + }); +}); diff --git a/src/theme/loadVariant.ts b/src/theme/loadVariant.ts new file mode 100644 index 0000000..ef151b6 --- /dev/null +++ b/src/theme/loadVariant.ts @@ -0,0 +1,10 @@ +import type { Variant } from './tokens'; + +/** + * Preloads the code of a variant before the transition swaps to it (BR-U1-8). B is part of the + * main bundle; E is a separate chunk. The same dynamic import is used by VariantRenderer, so the + * module is cached and the lazy component resolves immediately after the swap. + */ +export function loadVariant(variant: Variant): Promise { + return variant === 'e' ? import('../variants/e/LandingE') : Promise.resolve(); +} diff --git a/src/theme/tokens.ts b/src/theme/tokens.ts index 2ad629e..6967d72 100644 --- a/src/theme/tokens.ts +++ b/src/theme/tokens.ts @@ -1,30 +1,46 @@ /** - * Theme values (BR-3: only 'red' and 'purple' are valid). - * Actual token colors live in src/index.css (.theme-red / .theme-purple); - * this module only owns the *selectable* theme identifiers and the - * localStorage key used for persistence (BR-2). + * Theme model: variant (B = modern default, E = time-travel easter egg) x mode (light | dark). + * Actual token colors live in src/index.css (html[data-variant][data-mode]); this module only + * owns the identifiers, the storage keys and the pure rules for the initial mode. + * + * Rules: see aidlc-docs/features/redesign-modern-timetravel/construction/theme-foundation/ + * functional-design/business-rules.md (BR-U1-1 .. BR-U1-12). */ -export type ThemeName = 'red' | 'purple'; +export type Variant = 'b' | 'e'; +export type Mode = 'light' | 'dark'; +/** `system` until the visitor clicks the mode button, `user` afterwards (BR-U1-3/4). */ +export type ModeSource = 'system' | 'user'; -export const THEMES: ThemeName[] = ['red', 'purple']; +/** BR-U1-1: every page load starts in B; the variant is never stored and not in the URL. */ +export const DEFAULT_VARIANT: Variant = 'b'; -export const DEFAULT_THEME: ThemeName = 'red'; +export const MODE_STORAGE_KEY = 'slp-software-mode'; +/** Key of the former red/purple theme; ignored and removed once (BR-U1-11). */ +export const LEGACY_THEME_STORAGE_KEY = 'slp-software-theme'; -export const THEME_STORAGE_KEY = 'slp-software-theme'; - -/** BR-3: fall back to the default theme for anything that isn't a valid ThemeName. */ -export function isValidTheme(value: unknown): value is ThemeName { - return value === 'red' || value === 'purple'; +export function isValidMode(value: unknown): value is Mode { + return value === 'light' || value === 'dark'; } -export function resolveInitialTheme(storedValue: string | null): ThemeName { - if (isValidTheme(storedValue)) { - return storedValue; +/** + * BR-U1-2: a valid stored mode wins; otherwise the system preference decides. + * Must stay in sync with public/theme-init.js, which runs this same rule before first paint. + */ +export function resolveInitialMode( + stored: string | null, + systemPrefersDark: boolean, +): { mode: Mode; source: ModeSource } { + if (isValidMode(stored)) { + return { mode: stored, source: 'user' }; } - return DEFAULT_THEME; + return { mode: systemPrefersDark ? 'dark' : 'light', source: 'system' }; } -export function themeClassName(theme: ThemeName): string { - return `theme-${theme}`; +export function otherVariant(variant: Variant): Variant { + return variant === 'b' ? 'e' : 'b'; +} + +export function otherMode(mode: Mode): Mode { + return mode === 'light' ? 'dark' : 'light'; } diff --git a/src/variants/e/LandingE.tsx b/src/variants/e/LandingE.tsx new file mode 100644 index 0000000..a6adbad --- /dev/null +++ b/src/variants/e/LandingE.tsx @@ -0,0 +1,32 @@ +import { ModeToggle } from '../../components/ui/ModeToggle'; +import { VariantToggle } from '../../components/ui/VariantToggle'; + +/** + * Placeholder shell for variant E (time-travel). The real content (eras 2026 / 2013 / 2006 / + * 1998 / 1989) is built in unit U5; U1 only provides the lazy chunk and the way back to B. + */ +export default function LandingE() { + return ( + <> + +
      +

      Tijdreis

      +

      Deze weergave is in aanbouw.

      +
      + + ); +} diff --git a/tailwind.config.ts b/tailwind.config.ts index eee494a..d72af96 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -19,6 +19,7 @@ export default { sans: ['Instrument Sans', 'system-ui', 'sans-serif'], display: ['Sora', 'sans-serif'], mono: ['JetBrains Mono', 'monospace'], + archivo: ['Archivo Variable', 'system-ui', 'sans-serif'], }, borderRadius: { DEFAULT: '14px',