Watch
0
0
Fork
You've already forked hyperhive
0

frontend: remove the stylix overlay and add hyperhive and Catppuccin light and dark themes

This commit is contained in:
iris 2026-11-22 16:43:49 +01:00 • committed by mara
commit 91e2d26133
2 changed files with 486 additions and 413 deletions

View file

@ -1,15 +1,13 @@
# CSS custom properties (theme variables)
Colour variables live in **two standalone stylesheets**, split so a theme
swap touches only the first:
Colour variables live in **two standalone stylesheets**, split so a new theme
touches only the first:
1. **`colors.css`** — the 16 `--base00`…`--base0F` base16 slots. **This is
the entire theme swap contract.** A generator (for example one fed a stylix
base16 scheme, which is natively base00–base0F) replaces _only this
file_.
the whole theme contract.** A theme is 16 colours here and nothing else.
2. **`theme.css`** — the semantic layer: `--bg`, `--fg`, `--purple`, …
_derived_ from the base16 slots (`--bg: var(--base00)` etc.). This is
what the app references and it **never changes on a swap**.
what the app references and it **doesn't change per theme**.
Both files live in `frontend/packages/shared/src/`. Per-page stylesheets
(`common.css`, `dashboard.css`, `agent.css`)
@ -17,23 +15,35 @@ reference the **semantic** names and must **not** redeclare them or reach
for the raw `--baseNN` slots directly. (`base.css` holds only the shared
`body` typography — it references the palette but no longer defines it.)
`colors.css` declares each palette's 16 hex values exactly once —
`--mocha-baseNN` (dark, Catppuccin Mocha) and `--latte-baseNN` (light,
Catppuccin-Latte-derived; `base08`-`base0F` run darker than stock
Latte to actually clear WCAG AA against how this app uses them — real
contrast failures found in review, see the comment above those
declarations in `colors.css` for the numbers and why). Everything else
in the file just points the active `--baseNN` slot at one of those two
raw palettes via `var()`, never a second copy of a hex value: an
unconditional default (Mocha), a row gated behind `@media
(prefers-color-scheme: light)` (Latte, the OS/browser-level default),
and two `:root[data-theme='light'|'dark']` blocks a per-user override
sets (swarm-ui's `SettingsMenu`) — an attribute selector always
outranks the plain `:root` inside the media query, so the override wins
regardless of the actual OS preference. Absent an override, the media
query decides; that's what a client with no more specific theme
decision gets (see "Theme swapping" below for how a stylix deployment
supersedes all of this at once).
`colors.css` declares each theme's 16 hex values exactly once, as
`--<theme>-baseNN`, for five themes that are each light or dark:
| Theme | Id | Scheme | Palette |
| ---------------------- | ------------------------ | ------ | ------------------------------------------------------------------ |
| hyperhive light | `hyperhive-light` | light | Latte's neutrals, accents darker than stock to clear WCAG AA |
| hyperhive dark | `hyperhive-dark` | dark | Mocha's neutrals, the light accents' hues lifted to suit a dark bg |
| catppuccin latte mauve | `catppuccin-latte-mauve` | light | Catppuccin Latte as published |
| catppuccin mocha mauve | `catppuccin-mocha-mauve` | dark | Catppuccin Mocha as published |
| catppuccin mocha mara | `catppuccin-mocha-mara` | dark | Mocha with the accents mara picked |
The hyperhive light accents (`base08`-`base0F`) run darker than stock Latte
because the stock ones fail contrast as badge text and as plain text; the
comment above them in `colors.css` has the numbers. The hyperhive dark
accents keep those hues and saturations and raise the lightness until each
clears 6:1 against `base02`.
Everything else in the file points the active `--baseNN` slots at one of
those raw palettes via `var()`, never a second copy of a hex value: an
unconditional default (hyperhive dark), a block gated behind
`@media (prefers-color-scheme: light)` (hyperhive light, the OS-level
default), and one `:root[data-theme='<id>']` block per theme, which the
settings menu's theme select sets. An attribute selector always outranks
the plain `:root` inside the media query, so a picked theme wins whatever
the OS prefers. The select's **auto** choice sets no `data-theme`, so the
media query decides.
`frontend/packages/shared/src/settings/themes.ts` lists the ids, labels and
schemes; adding a theme is one entry there and one palette plus one block in
`colors.css`.
Both are deliberately standalone, not `@import`ed into the page bundles:
each package re-exports them (`src/{colors,theme}.css` →
@ -139,26 +149,22 @@ color: var(--amber); /* warning / running */
color: var(--green); /* ok */
```
## Theme swapping — the base16 contract
## Themes — the base16 contract
**The swap interface is `colors.css` — the 16 base16 slots, not the
semantic names.** A theme generator (for example one reading a stylix base16
scheme) overrides only `colors.css`; the semantic layer in `theme.css`
derives everything else, so the whole UI re-themes with nothing else to
template or regenerate. The base16 slot → semantic mapping is _internal_
to `theme.css` (the "Derives from" column above) — a generator never
needs to know the semantic var names, and `theme.css` + the page bundles stay
untouched.
**The theme interface is `colors.css` — the 16 base16 slots, not the
semantic names.** The semantic layer in `theme.css` derives everything
else, so a new theme needs nothing else to template or regenerate. The
base16 slot → semantic mapping is _internal_ to `theme.css` (the "Derives
from" column above): a theme never needs the semantic var names, and
`theme.css` and the page bundles stay untouched.
**Two palettes, one contract.** `colors.css` ships both a dark default
(Catppuccin Mocha, unconditional) and a light default (Catppuccin Latte,
behind `@media (prefers-color-scheme: light)`), plus a per-user override
path (`:root[data-theme]`) — a theme generator that overrides the file
wholesale (for example the stylix path, which writes a single unconditional
`:root` block with no media query, no `--mocha-*`/`--latte-*` vars, no
`[data-theme]` blocks) supersedes all of it at once, same as today.
**Five palettes, one contract.** `colors.css` ships the five themes in the
table above, each light or dark, with hyperhive dark as the unconditional
default and hyperhive light behind `@media (prefers-color-scheme: light)`.
Each theme's block also sets `color-scheme` and the contrast shares of
`theme.css` (`--muted-share` and friends) for its scheme.
`colors.css` base16 slot defaults (Catppuccin Mocha, dark default):
`colors.css` base16 slots in the dark palettes (the values are Catppuccin Mocha's; hyperhive dark differs in `base08`-`base0F`):
| Slot | Default | Standard base16 role | Mapped to |
| -------- | --------- | -------------------- | ---------------------------------------------------------- |
@ -187,10 +193,8 @@ Notes for theme authors:
`--muted`/`--subtext0` = `base05`↔`base00` blends). They still track a
swap automatically; no generator action needed.
- A standard Catppuccin base16 scheme uses **teal** for `base0C`;
`colors.css` defaults it to **sky** (`#89dceb`) to preserve the historical
accent. A
stylix Catppuccin scheme will shift `--cyan` to teal — that's the
operator's chosen scheme, working as intended.
`colors.css` uses **sky** (`#89dceb` in Mocha) to keep the historical
accent.
- `base04`/`base06`/`base07` aren't consumed by a semantic var today;
they're kept at their standard values so the 16-slot contract is
complete (a partial scheme override still works).

View file

@ -240,6 +240,13 @@ stream with an error status, the browser gives up and the badge reads
**disconnected**. The **reconnect** button beside it opens the stream again, and
the stream replays the rows. The message log card works the same way.
The settings menu in the header has a **theme** select: **auto**, which follows
the OS and picks hyperhive light or hyperhive dark, then hyperhive light,
hyperhive dark, catppuccin latte mauve, catppuccin mocha mauve and catppuccin
mocha mara. Each theme is light or
dark, and a pick beats the OS preference. The browser remembers the choice, and
hyperhive dark applies until a user picks one. The hive dashboard's menu has the same select.
The settings menu in the header has a **hide developer details** toggle. It drops
the muted debug rows (coalesced ticks, harness chatter) from every
terminal, the preview and the tabs, and rows already on screen hide or show as