feat(theme): implement dual light/dark colour token system with WCAG AA contrast
Replace hard-coded hex values and ad-hoc `dark:` variants with a single
semantic token layer in `src/styles/global.css` (`@theme` + `html.dark`
re-declaration), so every component uses the same Tailwind class list in
both modes.
Key changes:
- Define semantic tokens (page, surface, ink, accent, edge, etc.) and raw
ingredient palette (--color-spaghetti-*, --color-marinara*, etc.)
- Configure dual Shiki themes (light-plus / everforest-dark) with
`defaultColor: false` for proper per-mode code block colours, replacing
the old `.prose pre { #1f2937 !important }` hack
- Tint background particles to match the warm cream/espresso palette
instead of pure black dots
- Document theme rules: add tokens not `dark:` variants, keep colour rules
inside `@layer`, never target Tailwind utility classes with unlayered
overrides, route prose colours through `--tw-prose-*` only
All text and interactive elements meet WCAG AA contrast (4.5:1 body, 3:1
large/interactive). Light mode is a warm cream plate with white cards; dark
mode is espresso (#140C08) with raised cards.
This commit is contained in:
1 parent
8b6be36f7a
commit
9e157a4fa3
23 files changed
+544
-373
No files matched your search
@@ -50,6 +50,43 @@ Optional environment variables (all have working defaults):
|
||||
| `STATUS_STALE_AFTER_SECONDS` | `900` | Treat the light as unknown once beats stop arriving |
|
||||
|
||||
|
||||
## Theme and Colour Tokens
|
||||
|
||||
The site has one colour system, in `src/styles/global.css`. Components never hard-code
|
||||
a hex and, in almost every case, never need a `dark:` colour variant.
|
||||
|
||||
- **`@theme`** declares semantic tokens (`page`, `surface`, `wash`, `ink`, `ink-muted`,
|
||||
`accent`, `link`, `link-hover`, `edge`, `line`, `chip`, `chip-ink`, `code-bg`, `focus`,
|
||||
`status-*`). Tailwind generates `bg-page`, `text-ink`, `border-edge`, … from them.
|
||||
- **`html.dark`** re-declares the same names with cooked-longer values. Because Tailwind
|
||||
emits the utilities as `var(--color-*)` references, flipping the class on `<html>`
|
||||
recolours the whole site from the same class list.
|
||||
- **`--color-spaghetti-*`, `--color-marinara*`, `--color-meatball*`, `--color-parmesan`**
|
||||
are the raw ingredient palette. They feed the hero sky and gradients; they are *not*
|
||||
for text, because the pastels fall to 1.1–1.5:1 on the cream plate.
|
||||
|
||||
Rules that keep it from drifting again:
|
||||
|
||||
1. Add a token, don't add a `dark:` variant. A component class list should read the same
|
||||
in both modes.
|
||||
2. Keep colour rules inside `@layer`. Unlayered CSS outranks every Tailwind layer, which
|
||||
is how `.dark .text-spaghetti-brown` used to silently beat `dark:` utilities and put
|
||||
cream-on-cream text on the hero button (1.18:1).
|
||||
3. Never target a Tailwind utility class (e.g. `.border-black/15`) with an unlayered
|
||||
override — it fires in both modes.
|
||||
4. Prose colours go through `--tw-prose-*` only. The `html .prose` prefix in `global.css`
|
||||
is load-bearing: the typography plugin emits its defaults into the same layer but
|
||||
later, so at equal specificity it would win and articles would render slate.
|
||||
|
||||
Contrast is held to WCAG AA: 4.5:1 for body text and links, 3:1 for large text and
|
||||
interactive borders. Light mode is a warm cream plate with white cards; dark mode is a
|
||||
warm espresso plate (`#140C08`) with raised cards, so the marinara-and-meatball night sky
|
||||
has something warm to sit on.
|
||||
|
||||
Code blocks use dual Shiki themes (`light-plus` / `everforest-dark`, chosen by measuring
|
||||
every bundled theme's tokens against the site's own code backgrounds) with the
|
||||
`--shiki-light` / `--shiki-dark` swap in `global.css`.
|
||||
|
||||
## Technologies Used
|
||||
|
||||
- **Framework**: Astro (Static site generation)
|
||||
|
||||
Reference in new issue
Block a user