From 1ca82b3e095195d9aab83f61a115d2dafb5ed2f9 Mon Sep 17 00:00:00 2001 From: iris Date: Thu, 19 Nov 2026 20:49:40 +0100 Subject: [PATCH] frontend: one glass token pair in place of three copied light and dark blocks Headers, badges, terminal panes, the message box and the dashboard's bars read --glass-clear and --glass-filter from theme.css; the light palette (colors.css) and the solid-backgrounds setting set them. Each surface keeps a single rule, the per-theme override blocks and the quiet-badge specificity workaround go, and the dashboard and agent page now follow the light palette like the swarm UI. --- docs/4-implementation/web-ui/css-vars.md | 9 +++ frontend/packages/dashboard/src/dashboard.css | 20 +++++-- frontend/packages/shared/src/badge/Badge.css | 58 +++++-------------- frontend/packages/shared/src/chrome.css | 10 +++- frontend/packages/shared/src/colors.css | 7 +++ .../shared/src/settings/solid-backgrounds.css | 30 +++------- .../packages/shared/src/terminal/terminal.css | 10 +++- frontend/packages/shared/src/theme.css | 11 ++++ .../src/agent/terminal/AgentInputForm.css | 29 +++------- .../packages/swarm-ui/src/shell/Shell.css | 31 +++------- 10 files changed, 93 insertions(+), 122 deletions(-) diff --git a/docs/4-implementation/web-ui/css-vars.md b/docs/4-implementation/web-ui/css-vars.md index cbe7bf86b..e7df3896b 100644 --- a/docs/4-implementation/web-ui/css-vars.md +++ b/docs/4-implementation/web-ui/css-vars.md @@ -80,6 +80,15 @@ keeps 95% of its background in `--code-bg` (`--code-bg-share`), as `--crust` is grey on a light palette and text on it fell to 2:1. A palette that sets none of these variables, such as a generated one, keeps the dark shares. +The frosted surfaces (the headers, the badges, the terminal panes, the message box and the +dashboard's banner) read two derived variables from `theme.css`. `--glass-clear` is `1` +for glass and `0` for solid: a surface keeps `calc(100% - its-share * var(--glass-clear))` +of its fill colour. `--glass-filter` is its `backdrop-filter`: a blur on the dark palette, +`none` on the light one, where bright content behind the glass would wash the text out. +The light palette sets `--palette-glass-clear` and `--palette-glass-filter` in `colors.css`, +and the dark palette resets them; the solid-backgrounds setting sets the two derived +variables itself. A new glass surface uses the two variables and needs no theme rules of its own. + ## Common mistakes The Catppuccin colour names **don't** map 1:1 to the variable names. diff --git a/frontend/packages/dashboard/src/dashboard.css b/frontend/packages/dashboard/src/dashboard.css index e9eb822bd..a2e2509a3 100644 --- a/frontend/packages/dashboard/src/dashboard.css +++ b/frontend/packages/dashboard/src/dashboard.css @@ -36,9 +36,13 @@ body.dashboard-shell { gap: 0.75em; /* Stickiness lives on the `.sticky-top` wrapper (common.css) that common.js wraps this chrome in. */ - background: color-mix(in srgb, var(--bg) 86%, transparent); - -webkit-backdrop-filter: blur(8px) saturate(120%); - backdrop-filter: blur(8px) saturate(120%); + background: color-mix( + in srgb, + var(--bg) calc(100% - 14% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); border-bottom: 1px solid var(--purple-dim); padding: 0.3em 1em; margin: 0 0 1em; @@ -593,9 +597,13 @@ footer .banner-thin { flex-wrap: wrap; gap: 0.6em; padding: 0.55em 1em; - background: color-mix(in srgb, var(--bg) 74%, transparent); - -webkit-backdrop-filter: blur(12px) saturate(140%); - backdrop-filter: blur(12px) saturate(140%); + background: color-mix( + in srgb, + var(--bg) calc(100% - 26% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); border-top: 1px solid var(--purple); box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.4); } diff --git a/frontend/packages/shared/src/badge/Badge.css b/frontend/packages/shared/src/badge/Badge.css index 784b201ef..8b80b14a7 100644 --- a/frontend/packages/shared/src/badge/Badge.css +++ b/frontend/packages/shared/src/badge/Badge.css @@ -13,54 +13,22 @@ font: inherit; font-size: 0.85em; line-height: 1.4; - background: color-mix(in srgb, var(--purple-dim) 65%, transparent); - -webkit-backdrop-filter: blur(6px) saturate(140%); - backdrop-filter: blur(6px) saturate(140%); + /* Frosted glass (mara: "make badges look glassy... in dark mode the added + transparency improves readability, bg behind is dark"): translucent over a + blur on the dark palette, solid on the light one (see `--glass-clear` in + theme.css). Same recipe as the header, the terminal panes and the message + box. */ + background: color-mix( + in srgb, + var(--purple-dim) calc(100% - 35% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); color: var(--fg); border: none; white-space: nowrap; } -/* Frosted-glass fill (mara: "make badges look glassy... in dark mode - the added transparency improves readability, bg behind is dark") — - same recipe as the header chrome/terminal glass (`chrome.css`, - `terminal.css`): translucent `color-mix` + `backdrop-filter`. Only - for the default filled badges — `variant="quiet"` (below) already - has no fill at all, nothing to frost. - Dark (mocha) only, deliberately: her own reasoning was conditioned - on a dark surface behind the badge. A light (latte) page has bright, - often busy content behind a badge — the same transparency would - wash out the value text instead of improving it, the opposite of - what this is for — so light mode keeps the plain solid fill. Same - three-way structure `colors.css` uses for every light/dark switch: - this default rule *is* the dark look (mocha is the default palette), - the `@media`/`:root[data-theme]` blocks below revert it for light, - restore it for an explicit dark override. */ -@media (prefers-color-scheme: light) { - .ui-badge { - background: var(--purple-dim); - -webkit-backdrop-filter: none; - backdrop-filter: none; - } -} -/* `:not(.ui-badge-quiet)` here, unlike the base rule/`@media` block - above — argus's review: both of these add `:root`+`[data-theme]` to - the selector, so specificity is 0-3-0 vs plain `.ui-badge-quiet`'s - 0-1-0. Without the exclusion these would beat quiet's `background: - none` (below) whenever a user has an *explicit* theme override set - (SettingsMenu's dropdown, not just the OS default), reintroducing - the settings/links "should not have the badge bg" bug on those - triggers. Verified against a real repro before landing, not just - the specificity arithmetic. */ -:root[data-theme="light"] .ui-badge:not(.ui-badge-quiet) { - background: var(--purple-dim); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -:root[data-theme="dark"] .ui-badge:not(.ui-badge-quiet) { - background: color-mix(in srgb, var(--purple-dim) 65%, transparent); - -webkit-backdrop-filter: blur(6px) saturate(140%); - backdrop-filter: blur(6px) saturate(140%); -} /* The base `.ui-badge` rule's `border-radius: 1em` is a genuine pill at its own compact display-only height, but `min-height: 2.75em` below (the WCAG 2.5.5 touch-target floor) makes an *interactive* badge tall @@ -92,6 +60,8 @@ the idle background, which is what mara's report was actually about. */ .ui-badge-quiet { background: none; + -webkit-backdrop-filter: none; + backdrop-filter: none; } .ui-badge-interactive[aria-expanded="true"] { background: var(--bg-elev); diff --git a/frontend/packages/shared/src/chrome.css b/frontend/packages/shared/src/chrome.css index 13c469632..5423b39a3 100644 --- a/frontend/packages/shared/src/chrome.css +++ b/frontend/packages/shared/src/chrome.css @@ -16,9 +16,13 @@ .page-header { /* Stickiness lives on the `.sticky-top` wrapper (common.css) that common.js wraps this header in. */ - background: color-mix(in srgb, var(--bg) 92%, transparent); - -webkit-backdrop-filter: blur(8px) saturate(120%); - backdrop-filter: blur(8px) saturate(120%); + background: color-mix( + in srgb, + var(--bg) calc(100% - 8% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); border-bottom: 1px solid var(--purple-dim); display: flex; /* Keep the back-link + sub-tab nav on one row. Without an explicit diff --git a/frontend/packages/shared/src/colors.css b/frontend/packages/shared/src/colors.css index c95ee9a27..cea5f08b6 100644 --- a/frontend/packages/shared/src/colors.css +++ b/frontend/packages/shared/src/colors.css @@ -135,6 +135,9 @@ --muted-share: 85%; --subtext0-share: 93%; --code-bg-share: 95%; + /* No frosted glass on the light palette: see `--glass-clear` in theme.css. */ + --palette-glass-clear: 0; + --palette-glass-filter: none; color-scheme: light; } } @@ -171,6 +174,8 @@ --muted-share: 85%; --subtext0-share: 93%; --code-bg-share: 95%; + --palette-glass-clear: 0; + --palette-glass-filter: none; color-scheme: light; } :root[data-theme="dark"] { @@ -195,5 +200,7 @@ --muted-share: 58%; --subtext0-share: 77.7%; --code-bg-share: 58%; + --palette-glass-clear: initial; + --palette-glass-filter: initial; color-scheme: dark; } diff --git a/frontend/packages/shared/src/settings/solid-backgrounds.css b/frontend/packages/shared/src/settings/solid-backgrounds.css index 7d9146ecd..719cd8ee6 100644 --- a/frontend/packages/shared/src/settings/solid-backgrounds.css +++ b/frontend/packages/shared/src/settings/solid-backgrounds.css @@ -1,25 +1,9 @@ /* The frosted surfaces, made opaque while `data-solid="true"` is on `` - (`solid-backgrounds.tsx`). Each rule names the same surface as the rule that - makes it see-through, with `html:root` in front so it outranks that rule's - theme variants whatever order the stylesheets load in. The dialog scrim is - left alone: it dims the page on purpose. */ -html:root[data-solid="true"] .shell-header { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -html:root[data-solid="true"] .ui-badge:not(.ui-badge-quiet) { - background: var(--purple-dim); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -html:root[data-solid="true"] .terminal-wrap { - background: var(--code-bg); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -html:root[data-solid="true"] .ui-agent-input-form { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; + (`solid-backgrounds.tsx`): the two glass tokens of `theme.css` go to solid, + and every glass surface follows. `html:root` outranks theme.css's `:root` + whatever order the stylesheets load in. The dialog scrim is left alone: it + dims the page on purpose. */ +html:root[data-solid="true"] { + --glass-clear: 0; + --glass-filter: none; } diff --git a/frontend/packages/shared/src/terminal/terminal.css b/frontend/packages/shared/src/terminal/terminal.css index 8099fd4c9..4eb881feb 100644 --- a/frontend/packages/shared/src/terminal/terminal.css +++ b/frontend/packages/shared/src/terminal/terminal.css @@ -18,9 +18,13 @@ .terminal-wrap { position: relative; - background: color-mix(in srgb, var(--code-bg) 78%, transparent); - -webkit-backdrop-filter: blur(8px) saturate(120%); - backdrop-filter: blur(8px) saturate(120%); + background: color-mix( + in srgb, + var(--code-bg) calc(100% - 22% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); border: 1px solid var(--purple-dim); box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7); border-radius: 4px; diff --git a/frontend/packages/shared/src/theme.css b/frontend/packages/shared/src/theme.css index 3d8784569..b067fe96f 100644 --- a/frontend/packages/shared/src/theme.css +++ b/frontend/packages/shared/src/theme.css @@ -59,6 +59,17 @@ 2.4:1 against its card background, short of the 4.5:1 AA asks for. A palette that sets neither keeps the shares above. */ + /* The frosted-glass surfaces (headers, badges, terminal panes, the message + box) are see-through over a blur on the dark palette and solid on the light + one, where bright content behind them would wash the text out. + `--glass-clear` is 1 for glass and 0 for solid; a surface keeps + `calc(100% - its-clear-share * var(--glass-clear))` of its fill colour, and + `--glass-filter` is its `backdrop-filter`. A light palette sets + `--palette-glass-clear` and `--palette-glass-filter` in `colors.css`, and + the solid-backgrounds setting sets the two final tokens itself. */ + --glass-clear: var(--palette-glass-clear, 1); + --glass-filter: var(--palette-glass-filter, blur(8px) saturate(130%)); + /* `--muted`, above, is mixed toward `--base00`/`--bg` — correct for dimmed text on the page background, wrong for dimmed text sitting on an elevated fill like `--purple-dim` (badge/dropdown-item diff --git a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css index d6d7eb50d..f5eb8d82e 100644 --- a/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css +++ b/frontend/packages/swarm-ui/src/agent/terminal/AgentInputForm.css @@ -39,31 +39,18 @@ /* Frosted glass, the recipe of the badges (`Badge.css`): translucent over a blur, so the rows scroll behind it. Dark only, as there: on a light page the busy content behind would wash the text out, so light keeps the solid - fill. */ - background: color-mix(in srgb, var(--bg-elev) 55%, transparent); - -webkit-backdrop-filter: blur(10px) saturate(140%); - backdrop-filter: blur(10px) saturate(140%); + fill (`--glass-clear` in theme.css). */ + background: color-mix( + in srgb, + var(--bg-elev) calc(100% - 45% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); box-shadow: 0 0.3em 1em rgba(0, 0, 0, 0.45), 0 0 0 1px color-mix(in srgb, var(--purple) 12%, transparent); } -@media (prefers-color-scheme: light) { - .ui-agent-input-form { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; - } -} -:root[data-theme="light"] .ui-agent-input-form { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -:root[data-theme="dark"] .ui-agent-input-form { - background: color-mix(in srgb, var(--bg-elev) 55%, transparent); - -webkit-backdrop-filter: blur(10px) saturate(140%); - backdrop-filter: blur(10px) saturate(140%); -} .ui-agent-input-form:focus-within { border-color: var(--purple); box-shadow: diff --git a/frontend/packages/swarm-ui/src/shell/Shell.css b/frontend/packages/swarm-ui/src/shell/Shell.css index 8d8a74f79..da6604e6f 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.css +++ b/frontend/packages/swarm-ui/src/shell/Shell.css @@ -22,8 +22,8 @@ /* Sticky + frosted glass (mara: "sticky header bar ... frosted glass") — same `color-mix` + `backdrop-filter` recipe `.terminal-wrap`/ `.ui-badge` (@hive/shared) already use, dark-only same as those (a - light bg behind glass washes out). `z-index` keeps it above - `.shell-body` once content scrolls underneath. */ + light bg behind glass washes out; `--glass-clear` in theme.css). + `z-index` keeps it above `.shell-body` once content scrolls underneath. */ .shell-header { display: flex; align-items: center; @@ -31,30 +31,17 @@ gap: 1.5em; padding: 0.75em 1.25em; border-bottom: 1px solid var(--border); - background: color-mix(in srgb, var(--bg-elev) 80%, transparent); - -webkit-backdrop-filter: blur(8px) saturate(120%); - backdrop-filter: blur(8px) saturate(120%); + background: color-mix( + in srgb, + var(--bg-elev) calc(100% - 20% * var(--glass-clear)), + transparent + ); + -webkit-backdrop-filter: var(--glass-filter); + backdrop-filter: var(--glass-filter); position: sticky; top: 0; z-index: 10; } -@media (prefers-color-scheme: light) { - .shell-header { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; - } -} -:root[data-theme="light"] .shell-header { - background: var(--bg-elev); - -webkit-backdrop-filter: none; - backdrop-filter: none; -} -:root[data-theme="dark"] .shell-header { - background: color-mix(in srgb, var(--bg-elev) 80%, transparent); - -webkit-backdrop-filter: blur(8px) saturate(120%); - backdrop-filter: blur(8px) saturate(120%); -} /* The swarm name links to the start page; the link adds no look of its own, so the brand's accent and glow (on the span inside) are all that show. */ .shell-brand-link {