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
12 changed files with 164 additions and 86 deletions
|
|
@ -28,10 +28,10 @@ import {
|
|||
} from "./alerts.js";
|
||||
|
||||
const STATE_TONE: Record<string, BadgeTone> = {
|
||||
Alerting: "negative",
|
||||
Error: "negative",
|
||||
NoData: "warning",
|
||||
Pending: "warning",
|
||||
Alerting: "error",
|
||||
Error: "error",
|
||||
NoData: "warn",
|
||||
Pending: "warn",
|
||||
};
|
||||
|
||||
const COLUMNS: TableColumn<Alert>[] = [
|
||||
|
|
|
|||
|
|
@ -55,9 +55,10 @@ import { Popover } from "../ui/popover/Popover.js";
|
|||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
||||
import { GearIcon } from "@hive/shared/icons.js";
|
||||
import { Dropdown, type DropdownOption } from "@hive/shared/dropdown.js";
|
||||
import { TONES } from "@hive/shared/tone.js";
|
||||
import "./ComponentsPage.css";
|
||||
|
||||
const HINT_TONES: HintTone[] = ["muted", "warn", "error", "ok"];
|
||||
const HINT_TONES: HintTone[] = [...TONES];
|
||||
|
||||
const SUBMIT_SAMPLES: [string, SubmitState][] = [
|
||||
["done", { status: "done", value: undefined }],
|
||||
|
|
@ -118,7 +119,7 @@ const TABLE_COLUMNS: TableColumn<Row>[] = [
|
|||
{
|
||||
key: "status",
|
||||
header: "status",
|
||||
render: () => <Badge tone="positive" value="ok" />,
|
||||
render: () => <Badge tone="ok" value="ok" />,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -133,13 +134,7 @@ const SELECT_OPTIONS: SelectOption[] = [
|
|||
];
|
||||
|
||||
const BUTTON_VARIANTS: ButtonVariant[] = ["primary", "default", "danger"];
|
||||
const BADGE_TONES: BadgeTone[] = [
|
||||
"neutral",
|
||||
"positive",
|
||||
"warning",
|
||||
"negative",
|
||||
"accent",
|
||||
];
|
||||
const BADGE_TONES: BadgeTone[] = [...TONES, "accent"];
|
||||
|
||||
const MODEL_OPTIONS: DropdownOption[] = [
|
||||
{ value: "haiku", label: "haiku", description: "fast" },
|
||||
|
|
@ -250,7 +245,7 @@ function BadgeToggleSample() {
|
|||
return (
|
||||
<Badge
|
||||
value={paused ? "▶ resume" : "⏸ pause"}
|
||||
tone={paused ? "warning" : "neutral"}
|
||||
tone={paused ? "warn" : "neutral"}
|
||||
onClick={() => setPaused((p) => !p)}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -329,8 +329,7 @@ function IssueReportBody() {
|
|||
/>
|
||||
),
|
||||
ariaSort: ariaSortFor("blocked"),
|
||||
render: (r) =>
|
||||
r.blocked ? <Badge tone="warning" value="blocked" /> : "—",
|
||||
render: (r) => (r.blocked ? <Badge tone="warn" value="blocked" /> : "—"),
|
||||
// A distinct gap from the existing "hide blocked" toggle above:
|
||||
// that one only *hides* blocked issues, there was no way to see
|
||||
// *only* the blocked ones. Synthesized two-value set (not the raw
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ export function LinkMatrixAccountForm({
|
|||
setMode(v as Mode);
|
||||
}}
|
||||
/>
|
||||
<Hint tone={mode === "token" ? "warn" : "muted"}>
|
||||
<Hint tone={mode === "token" ? "warn" : "neutral"}>
|
||||
{mode === "token" ? TOKEN_WARNING : PASSWORD_NOTE}
|
||||
</Hint>
|
||||
{mode === "token" ? (
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ const REPO_FILTER_KEY = "swarm-ui:pr-report:repo-filter";
|
|||
const TABLE_FILTERS_KEY = "swarm-ui:pr-report:table-filters";
|
||||
|
||||
const CI_TONE: Record<NonNullable<PrReportRow["ci"]>, BadgeTone> = {
|
||||
success: "positive",
|
||||
pending: "warning",
|
||||
failure: "negative",
|
||||
success: "ok",
|
||||
pending: "warn",
|
||||
failure: "error",
|
||||
};
|
||||
|
||||
const COLUMNS: TableColumn<PrReportRow>[] = [
|
||||
|
|
@ -119,7 +119,7 @@ const COLUMNS: TableColumn<PrReportRow>[] = [
|
|||
{r.changes_requested > 0 ? (
|
||||
<>
|
||||
{" "}
|
||||
<Badge tone="negative" value="changes requested" />
|
||||
<Badge tone="error" value="changes requested" />
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
|
|
@ -132,7 +132,7 @@ const COLUMNS: TableColumn<PrReportRow>[] = [
|
|||
key: "conflicts",
|
||||
header: "conflicts",
|
||||
render: (r) =>
|
||||
r.has_conflicts ? <Badge tone="negative" value="conflicts" /> : "—",
|
||||
r.has_conflicts ? <Badge tone="error" value="conflicts" /> : "—",
|
||||
sortBy: (r) => Number(r.has_conflicts),
|
||||
filterValues: (r) => [yesNo(r.has_conflicts)],
|
||||
filterMode: "multiselect",
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ export const OUTCOME_LABEL: Record<BuildOutcome, string> = {
|
|||
};
|
||||
|
||||
export const OUTCOME_TONE: Record<BuildOutcome, BadgeTone> = {
|
||||
built: "positive",
|
||||
failed: "negative",
|
||||
error: "warning",
|
||||
built: "ok",
|
||||
failed: "error",
|
||||
error: "warn",
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ const CONNECTION_LABEL: Record<ConnectionState, string> = {
|
|||
|
||||
const CONNECTION_TONE: Record<ConnectionState, BadgeTone> = {
|
||||
connecting: "neutral",
|
||||
open: "positive",
|
||||
reconnecting: "warning",
|
||||
closed: "negative",
|
||||
open: "ok",
|
||||
reconnecting: "warn",
|
||||
closed: "error",
|
||||
};
|
||||
|
||||
// One message's row. Memoised on the message, which keeps its identity while it
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export function TryOutResult({
|
|||
<p class="ui-tryout-overall">
|
||||
<strong>Overall: </strong>
|
||||
<Badge
|
||||
tone={result.overall === "approve" ? "positive" : "negative"}
|
||||
tone={result.overall === "approve" ? "ok" : "error"}
|
||||
value={result.overall === "approve" ? "approve" : "request changes"}
|
||||
/>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ export const OUTCOME_LABEL: Record<RunOutcome, string> = {
|
|||
};
|
||||
|
||||
export const OUTCOME_TONE: Record<RunOutcome, BadgeTone> = {
|
||||
approved: "positive",
|
||||
approved: "ok",
|
||||
"changes-requested": "accent",
|
||||
"no-verdict": "neutral",
|
||||
"queue-full": "warning",
|
||||
"post-failed": "negative",
|
||||
done: "positive",
|
||||
failed: "negative",
|
||||
"queue-full": "warn",
|
||||
"post-failed": "error",
|
||||
done: "ok",
|
||||
failed: "error",
|
||||
};
|
||||
|
||||
export const TRIGGER_LABEL: Record<RunTrigger, string> = {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import {
|
|||
import "./ScheduleCard.css";
|
||||
|
||||
const STATE_TONE: Record<ScheduleState, BadgeTone> = {
|
||||
active: "positive",
|
||||
paused: "warning",
|
||||
active: "ok",
|
||||
paused: "warn",
|
||||
past: "neutral",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ interface HiveStatus {
|
|||
}
|
||||
|
||||
// One tone + label per freshness value. `unknown` (reporting but absent
|
||||
// from the roster) reads `negative` — it's the one case this endpoint
|
||||
// from the roster) reads `error` — it's the one case this endpoint
|
||||
// cannot vouch for at all, per `status.rs`'s doc comment.
|
||||
const FRESHNESS: Record<Freshness, { tone: BadgeTone; label: string }> = {
|
||||
fresh: { tone: "positive", label: "fresh" },
|
||||
stale: { tone: "warning", label: "stale" },
|
||||
fresh: { tone: "ok", label: "fresh" },
|
||||
stale: { tone: "warn", label: "stale" },
|
||||
never_reported: { tone: "neutral", label: "never reported" },
|
||||
unknown: { tone: "negative", label: "unknown" },
|
||||
unknown: { tone: "error", label: "unknown" },
|
||||
};
|
||||
|
||||
const COLUMNS: TableColumn<HiveStatus>[] = [
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ export function SwarmPage() {
|
|||
icon="🔔"
|
||||
hint={
|
||||
<>
|
||||
<Badge tone="warning" value="beta" /> forge events routed to agents,
|
||||
as flows
|
||||
<Badge tone="warn" value="beta" /> forge events routed to agents, as
|
||||
flows
|
||||
</>
|
||||
}
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in a new issue