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:
parent
c205c6115b
commit
25965341e0
4 changed files with 164 additions and 86 deletions
|
|
@ -3,11 +3,14 @@
|
|||
.ui-hint {
|
||||
margin: 0;
|
||||
}
|
||||
.ui-hint-muted {
|
||||
.ui-hint-neutral {
|
||||
color: var(--muted);
|
||||
}
|
||||
.ui-hint-info {
|
||||
color: var(--cyan);
|
||||
}
|
||||
.ui-hint-warn {
|
||||
color: var(--yellow);
|
||||
color: var(--amber);
|
||||
}
|
||||
.ui-hint-error {
|
||||
color: var(--red);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
// <Hint> — a line of small supporting text: helper text under a field, a
|
||||
// count, a status line, an inline problem or a success note. One component
|
||||
// for what each form and card used to restyle under its own class name, so
|
||||
// "muted", "warning", "error" and "ok" mean the same colour everywhere.
|
||||
// "neutral", "info", "ok", "warn" and "error" mean the same colour everywhere.
|
||||
//
|
||||
// `error` is read out when it appears (`role="alert"`); the other tones are
|
||||
// plain text unless the caller passes a `role`, such as `status` for a line
|
||||
// that changes after a save. `class` is for a page's
|
||||
// layout around the hint (a margin, a width), not for its colour.
|
||||
import type { ComponentChildren } from "preact";
|
||||
import type { Tone } from "@hive/shared/tone.js";
|
||||
import "./Hint.css";
|
||||
|
||||
export type HintTone = "muted" | "warn" | "error" | "ok";
|
||||
export type HintTone = Tone;
|
||||
|
||||
export function Hint({
|
||||
tone = "muted",
|
||||
tone = "neutral",
|
||||
as: Tag = "p",
|
||||
role,
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@
|
|||
white-space: pre-wrap;
|
||||
}
|
||||
.ui-toast-info {
|
||||
border-left-color: var(--purple-dim);
|
||||
border-left-color: var(--cyan);
|
||||
}
|
||||
.ui-toast-warn {
|
||||
border-left-color: var(--amber);
|
||||
}
|
||||
.ui-toast-ok {
|
||||
border-left-color: var(--green);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
// by itself, and a click dismisses it sooner. Anything that shows one calls
|
||||
// `showToast`; `<ToastHost>` renders the list.
|
||||
|
||||
export type ToastTone = "info" | "ok" | "error";
|
||||
import type { Tone } from "@hive/shared/tone.js";
|
||||
|
||||
export type ToastTone = Exclude<Tone, "neutral">;
|
||||
|
||||
export interface Toast {
|
||||
id: number;
|
||||
|
|
|
|||
Loading…
Reference in a new issue