Watch
0
0
Fork
You've already forked hyperhive
0

frontend: one tone vocabulary for badges, hints, banners and toasts

Part of the unification order in the UI sweep issue (step b).

A badge named its tones positive/warning/negative, a hint muted/warn/error/ok,
a banner info/warning/error and a toast info/ok/error. They now all take the
shared Tone: neutral, info, ok, warn, error (a badge adds accent for a selected
choice). Warn is amber everywhere (a hint used yellow), info is cyan everywhere
(a toast used purple). A test pins the list against each component's CSS.
This commit is contained in:
iris 2026-11-25 21:43:23 +01:00
commit 25965341e0
4 changed files with 164 additions and 86 deletions

View file

@ -89,15 +89,18 @@
conventions or css mix new colors" — this is that; stock mocha/latte
keep their existing look, since both accents already sit close to
`--fg` in contrast terms). */
.ui-badge-positive .ui-badge-value {
.ui-badge-ok .ui-badge-value {
color: color-mix(in srgb, var(--green) 60%, var(--fg));
}
.ui-badge-warning .ui-badge-value {
.ui-badge-warn .ui-badge-value {
color: color-mix(in srgb, var(--amber) 60%, var(--fg));
}
.ui-badge-negative .ui-badge-value {
.ui-badge-error .ui-badge-value {
color: color-mix(in srgb, var(--red) 60%, var(--fg));
}
.ui-badge-info .ui-badge-value {
color: color-mix(in srgb, var(--cyan) 60%, var(--fg));
}
.ui-badge-accent .ui-badge-value {
color: color-mix(in srgb, var(--purple) 60%, var(--fg));
}

View file

@ -19,14 +19,14 @@
// `shared` is the one package both already depend on (see
// `docs/5-project/web-ui/design-guide.md`'s component-first + junk-drawer rules).
import type { ComponentChildren } from "preact";
import type { Tone } from "../tone.js";
import "./Badge.css";
export type BadgeTone =
| "neutral"
| "positive"
| "warning"
| "negative"
| "accent";
/**
* The shared `Tone`, plus `accent` for "selected" or "active", which marks a
* choice rather than a status.
*/
export type BadgeTone = Tone | "accent";
/**
* `'default'` — the filled pill every status/picker badge has always
* been. `'quiet'` — no permanent fill, only a background on hover/

View file

@ -0,0 +1,10 @@
// The one set of status tones: a badge, a hint, a banner and a toast all
// take a `Tone`, so "ok" or "warn" is spelled and coloured the same way
// everywhere. `neutral` is "no signal" (plain text, no colour); the other four
// map to the theme's green, amber, red and cyan (`--green`, `--amber`,
// `--red`, `--cyan`). A new component that shows a status takes a `Tone` and
// does not add a fifth spelling.
export const TONES = ["neutral", "info", "ok", "warn", "error"] as const;
export type Tone = (typeof TONES)[number];

View file

@ -10,13 +10,15 @@
// is the first consumer — compose from this instead of duplicating the
// banner's own border/colour/pulse rules locally.
//
// `level` defaults to 'warning', matching `hive-warn.js`'s own default.
// `level` defaults to 'warn', matching `hive-warn.js`'s own default.
// Only `error` pulses — an active incident, not a standing caveat, same
// rule `hive-warn.css`'s own comment states.
import type { ComponentChildren } from "preact";
import type { Tone } from "../tone.js";
import "./WarnBanner.css";
export type WarnLevel = "info" | "warning" | "error";
/** A banner is never `neutral` or `ok`: it exists to flag something. */
export type WarnLevel = Exclude<Tone, "neutral" | "ok">;
export interface WarnBannerProps {
level?: WarnLevel;
@ -29,7 +31,7 @@ export interface WarnBannerProps {
}
export function WarnBanner({
level = "warning",
level = "warn",
class: extraClass,
children,
}: WarnBannerProps) {