From 2b5dd9ebc100aa670576c2585e72364cfddafa8b Mon Sep 17 00:00:00 2001 From: meh Date: Wed, 30 Sep 2026 01:12:48 +0700 Subject: [PATCH 1/2] fix(glass): tint glass with the theme's surface, not white The themes and every component fallback drew glass as a white film. On a dark theme that read as milky rather than as glass, and sites overrode the tokens or wrote their own glass CSS to escape it. The film is now base-100 and the border base-content, in both themes and in the fallbacks, so glass is the page's own surface made translucent. Highlights stay white. Dark mode's opacity curve assumed the white film (4% to 26%); a dark film at those values all but vanishes, so both modes take the one curve, and the dark theme's film is the value it derives, 41.55%. --- src/components/_shared/material.css | 24 +++++++++++++----------- src/components/card/Card.css | 9 +++++---- src/components/glow-card/GlowCard.css | 6 +++--- src/styles/glass.ts | 22 +++++++++------------- src/styles/themes/dark.css | 6 +++--- src/styles/themes/light.css | 2 +- 6 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/components/_shared/material.css b/src/components/_shared/material.css index 7194695d..c449667f 100644 --- a/src/components/_shared/material.css +++ b/src/components/_shared/material.css @@ -17,10 +17,12 @@ * than tidy. An undefined custom property does not fall back to its initial * value: CSS drops the whole declaration. Three of these used to be read bare, * so a theme that defined twenty-eight of the thirty-one glass tokens got a - * surface with no background at all rather than a plainer one. The two shipped - * themes both use `white` for the three colours, so that is what the fallbacks - * say. `src/styles/glass.ts` derives the rest from `blur`, `refraction` and - * `depth`. + * surface with no background at all rather than a plainer one. The fallbacks + * tint glass with the theme itself: the film is `base-100` and the border + * `base-content`, so glass is the page's own surface made translucent, in any + * theme, rather than a white film laid over it. Highlights stay white, because + * they are light catching an edge. `src/styles/glass.ts` derives the rest from + * `blur`, `refraction` and `depth`. */ @layer components { @@ -71,12 +73,12 @@ :root.glass [data-material="solid"]:not([data-material-explicit]) { background-color: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc(100% - var(--glass-background-opacity, 55%)) ); border-color: color-mix( in oklab, - var(--glass-border-color, white), + var(--glass-border-color, var(--color-base-content)), transparent calc(100% - var(--glass-border-opacity, 12%)) ); } @@ -110,12 +112,12 @@ [data-material="glass"] { background-color: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc(100% - var(--glass-background-opacity, 55%)) ); border-color: color-mix( in oklab, - var(--glass-border-color, white), + var(--glass-border-color, var(--color-base-content)), transparent calc(100% - var(--glass-border-opacity, 12%)) ); -webkit-backdrop-filter: blur(var(--glass-blur, 9px)) @@ -288,7 +290,7 @@ [data-control-material="glass"] { background-color: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc( 100% - @@ -311,7 +313,7 @@ [data-material="glass"] { background-color: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc(100% - var(--glass-fallback-background-opacity, 78%)) ); } @@ -321,7 +323,7 @@ [data-material="glass"] { background-color: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc(100% - var(--glass-fallback-background-opacity, 78%)) ); -webkit-backdrop-filter: none; diff --git a/src/components/card/Card.css b/src/components/card/Card.css index d4ae4a68..e0abc1e9 100644 --- a/src/components/card/Card.css +++ b/src/components/card/Card.css @@ -109,19 +109,20 @@ initial value: CSS drops the whole declaration. Three of these were read bare, so a theme that defined twenty-eight of the thirty-one glass tokens got a card with no background at all rather than a plainer one, and the - only themes that defined all thirty-one were the two shipped here. Both - use `white` for the three colours, so that is what the fallbacks say. + only themes that defined all thirty-one were the two shipped here. The + film falls back to `base-100` and the border to `base-content`, the same + theme colours `_shared/material.css` uses. `src/styles/glass.ts` derives the other twenty-five from three numbers. */ .card--material-glass { --card-bg: color-mix( in oklab, - var(--glass-background-color, white), + var(--glass-background-color, var(--color-base-100)), transparent calc(100% - var(--glass-background-opacity, 55%)) ); --card-border: color-mix( in oklab, - var(--glass-border-color, white), + var(--glass-border-color, var(--color-base-content)), transparent calc(100% - var(--glass-border-opacity, 12%)) ); -webkit-backdrop-filter: blur( diff --git a/src/components/glow-card/GlowCard.css b/src/components/glow-card/GlowCard.css index c33a9c09..83389712 100644 --- a/src/components/glow-card/GlowCard.css +++ b/src/components/glow-card/GlowCard.css @@ -17,13 +17,13 @@ border-radius: inherit; background: color-mix( in oklab, - var(--glass-background-color, white) var(--glass-background-opacity, 38%), + var(--glass-background-color, var(--color-base-100)) var(--glass-background-opacity, 38%), transparent ); border: var(--border, 1px) solid color-mix( in oklab, - var(--glass-border-color, white) var(--glass-border-opacity, 30%), + var(--glass-border-color, var(--color-base-content)) var(--glass-border-opacity, 30%), transparent ); backdrop-filter: blur(var(--glow-card-blur)) @@ -87,7 +87,7 @@ .glow-card { background: color-mix( in oklab, - var(--glass-background-color, white) + var(--glass-background-color, var(--color-base-100)) var(--glass-fallback-background-opacity, 78%), transparent ); diff --git a/src/styles/glass.ts b/src/styles/glass.ts index f944ea02..5b5452b4 100644 --- a/src/styles/glass.ts +++ b/src/styles/glass.ts @@ -161,21 +161,17 @@ export function resolveGlassTokens( const controlTint = v.controlTint; /* - * Dark mode's film has to be a film, not a rounding error. + * The film is the theme's own `base-100`, so both modes take one curve. * - * This was `7 * rv`, so the entire refraction range moved the surface from - * 0% to 7% while light mode spanned 18% to 48%. Measured across the whole - * slider, dark mode's largest step was under two points of opacity, which is - * below what anyone can see on a near-black desk: the axis read as broken - * rather than as subtle, and the consuming app worked around it by - * overriding this token from a slider of its own. - * - * Dark still lands lower than light, and deliberately - a light film on a - * dark surface reads much faster than a dark film on a light one, so parity - * in numbers would not be parity in appearance. 26% at the top is enough for - * the surface to declare itself while leaving the text ladder its contrast. + * Dark used to land lower (4% to 26%) because its film was white, and a + * light film on a dark surface reads much faster than a dark one. Tinted + * with the theme's surface instead, the film is dark on dark: at 4% to 26% + * of it the panel all but vanished, and at the white film's opacities the + * panel read as milky rather than as glass, which is what sites overrode + * this token to escape. 18% to 48% of the theme's own surface is the range + * a translucent header on the same backdrop already sits in. */ - const background = light ? (zero ? 0 : 18 + 30 * rv) : zero ? 0 : 4 + 22 * rv; + const background = zero ? 0 : 18 + 30 * rv; const border = light ? (zero ? 0 : 18 + 18 * rs) : 26 * rs; const highlight = light ? (zero ? 0 : 22 + 26 * rs) : 24 * rs; const bottomHighlight = light diff --git a/src/styles/themes/dark.css b/src/styles/themes/dark.css index f14af3ae..1269f014 100644 --- a/src/styles/themes/dark.css +++ b/src/styles/themes/dark.css @@ -100,9 +100,9 @@ --noise: 1; /* Glass surface tokens */ - --glass-background-color: white; - --glass-background-opacity: 0.96%; - --glass-border-color: white; + --glass-background-color: var(--color-base-100); + --glass-background-opacity: 41.55%; + --glass-border-color: var(--color-base-content); --glass-border-opacity: 30%; --glass-highlight-color: white; --glass-highlight-opacity: 6.4%; diff --git a/src/styles/themes/light.css b/src/styles/themes/light.css index a68a7bd2..e3c114c8 100644 --- a/src/styles/themes/light.css +++ b/src/styles/themes/light.css @@ -101,7 +101,7 @@ --noise: 1; /* Glass surface tokens */ - --glass-background-color: white; + --glass-background-color: var(--color-base-100); --glass-background-opacity: 0.96%; --glass-border-color: white; --glass-border-opacity: 30%; From df0574e00b5c63624b523dd58089bbfac87a7c74 Mon Sep 17 00:00:00 2001 From: meh Date: Wed, 30 Sep 2026 01:12:48 +0700 Subject: [PATCH 2/2] feat(navbar, footer): material on Navbar.Row and Footer A header row or a footer can now be glass like a card, from the same tokens, instead of a site writing its own glass CSS for it. Opt-in: with material unset neither element gets a data-material attribute and renders as before. A glass row drops its flavour's fill, which would hide the glass, and takes the surface's text colour. --- docs/api-contract.md | 1 + src/components/footer/Footer.layout.tsx | 18 ++++++++++++++-- src/components/navbar/Navbar.css | 25 ++++++++++++++-------- src/components/navbar/NavbarRow.layout.tsx | 8 ++++++- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index b6b25f5e..ed5b43f9 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -1011,6 +1011,7 @@ rows: readonly T[] center?: boolean children?: JSX.Element horizontal?: boolean +material?: Material vertical?: boolean ``` diff --git a/src/components/footer/Footer.layout.tsx b/src/components/footer/Footer.layout.tsx index eee55e22..5ad12b73 100644 --- a/src/components/footer/Footer.layout.tsx +++ b/src/components/footer/Footer.layout.tsx @@ -2,7 +2,8 @@ import "./footer.css"; import type { JSX } from "@solidjs/web"; import {type ParentComponent, omit} from "solid-js"; import { twMerge } from "../../lib/twMerge"; -import type { UIBaseProps } from "../vocabulary"; +import "../_shared/material.css"; +import type { Material, UIBaseProps } from "../vocabulary"; import { FooterTitle } from "./FooterTitle.generated"; import { CLASSES } from "./Footer.recipe"; import type { Layout } from "../../lib/layouts"; @@ -13,10 +14,21 @@ export type FooterProps = UIBaseProps & { center?: boolean; horizontal?: boolean; vertical?: boolean; + /** What the footer is made of. Unset keeps the footer's own background. */ + material?: Material; }; const Footer: Layout = () => { - const others = omit(props, "children", "class", "dataTheme", "center", "horizontal", "vertical"); + const others = omit( + props, + "children", + "class", + "dataTheme", + "center", + "horizontal", + "vertical", + "material", + ); const classes = () => twMerge( @@ -31,6 +43,8 @@ const Footer: Layout = () => {