Public: anyone can read this; the crew can change it.

Revert "Status at a glance: one badge shape, segmented progress, one-line alerts and a marked table row (borrowed from SPEC-01/HARDWARE)" #13782

Closed opened this
Closed without merging

revert-13637 → main 1 commit

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +29 −117
docs/design/size-budget.json +8 −8
@@ -1,23 +1,23 @@
11 {
22 "/": {
33 "js": 22016,
4 "css": 44800
4 "css": 44544
55 },
66 "/explore": {
77 "js": 21760,
8 "css": 44800
8 "css": 44544
99 },
1010 "/map": {
1111 "js": 28672,
12 "css": 46336
12 "css": 46080
1313 },
1414 "/:owner/:name": {
1515 "js": 38144,
16 "css": 44800
16 "css": 44544
1717 },
1818 "/changelog": {
1919 "js": 26368,
20 "css": 44800
20 "css": 44544
2121 },
2222 "/:owner/:name/next": {
2323 "js": 23296,
@@ -37,14 +37,14 @@
3737 },
3838 "/pricing": {
3939 "js": 21760,
40 "css": 44800
40 "css": 44544
4141 },
4242 "/forges/new": {
4343 "js": 21760,
44 "css": 44800
44 "css": 44544
4545 },
4646 "/claim": {
4747 "js": 24064,
48 "css": 44800
48 "css": 44544
4949 }
5050 }
src/web/style/components.ts −7
@@ -222,13 +222,6 @@ a.stat:hover { border-color: var(--border-strong); }
222222 background: color-mix(in srgb, var(--attn) 12%, transparent);
223223 }
224224 .badge .ico { width: 12px; height: 12px; }
225 /* The one status badge: a bar at the left edge, in the state's colour. The
226 word and icon are always there, so the bar is never the only cue. */
227 .badge[data-status] { position: relative; padding-left: 12px; }
228 .badge[data-status]::before {
229 content: ""; position: absolute; inset: 4px auto 4px 4px; width: 3px; background: currentColor;
230 }
231 .badge[data-status="queued"]::before, .badge[data-status="held"]::before, .badge[data-status="cut"]::before { opacity: .7; }
232225 /* A loader that turns: the one icon that means "still going". */
233226 .ico-loader { animation: spin 1.1s linear infinite; }
234227 /* A button never spins at rest: only its own busy state turns the loader. */
src/web/ui.ts +21 −57
@@ -186,10 +186,7 @@ export interface BtnOptions {
186186 extra?: string;
187187 /** The element's id, for a script or a fragment link that finds it. */
188188 id?: string;
189 /**
190 * A pager's link says which way it goes (`rel="next"`): a reader of the list follows it
191 * (`bind.ts`).
192 */
189 /** A pager's link says which way it goes (`rel="next"`): a reader of the list follows it (`bind.ts`). */
193190 rel?: "next" | "prev";
194191 }
195192
@@ -388,32 +385,6 @@ export function verdictBadge(
388385 return badge(look.label, { icon: look.icon, tone: look.tone });
389386 }
390387
391 /** The closed set of states a status badge can wear. */
392 export type Status = "queued" | "running" | "ok" | "failed" | "cut" | "held";
393
394 const STATUS_VARIANT: Record<Status, string> = {
395 queued: "secondary",
396 running: "attn",
397 ok: "success",
398 failed: "danger",
399 cut: "outline",
400 held: "outline",
401 };
402
403 /**
404 * The one status badge: a quiet pill with a bar at its left edge, an icon
405 * and always a word, so it reads in black and white. `status` is the closed
406 * set above; `word` is what this thing calls that state ("Passed", "Asleep").
407 */
408 export function statusBadge(status: Status, word: string, ic: IconName): Html {
409 return html`<span
410 class="badge"
411 data-status="${status}"
412 data-variant="${STATUS_VARIANT[status]}"
413 >${icon(ic)}${word}</span
414 >`;
415 }
416
417388 /**
418389 * A run's state (docs/APPS.md): the one badge a check wears on a pull, a
419390 * row wears in a list, and a log page wears in its head. A finished deploy
@@ -422,15 +393,18 @@ export function statusBadge(status: Status, word: string, ic: IconName): Html {
422393 export function runStateBadge(state: RunState, kind: RunKind = "deploy"): Html {
423394 switch (state) {
424395 case "queued":
425 return statusBadge("queued", "Queued", "clock");
396 return badge("Queued", { icon: "clock", variant: "secondary" });
426397 case "running":
427 return statusBadge("running", "Running", "loader");
398 return badge("Running", { icon: "loader", tone: "attn" });
428399 case "ok":
429 return statusBadge("ok", kind === "agent" ? "Done" : "Passed", "check");
400 return badge(kind === "agent" ? "Done" : "Passed", {
401 icon: "check",
402 tone: "success",
403 });
430404 case "failed":
431 return statusBadge("failed", "Failed", "x");
405 return badge("Failed", { icon: "x", tone: "danger" });
432406 case "cancelled":
433 return statusBadge("cut", "Cancelled", "ban");
407 return badge("Cancelled", { icon: "ban", variant: "outline" });
434408 }
435409 }
436410
@@ -438,16 +412,16 @@ export function runStateBadge(state: RunState, kind: RunKind = "deploy"): Html {
438412 export function envStateBadge(state: EnvState, dormant = false): Html {
439413 switch (state) {
440414 case "stopped":
441 if (dormant) return statusBadge("held", "Asleep", "clock");
442 return statusBadge("cut", "Stopped", "square");
415 if (dormant) return badge("Asleep", { icon: "clock", variant: "outline" });
416 return badge("Stopped", { icon: "square", variant: "outline" });
443417 case "deploying":
444 return statusBadge("running", "Deploying", "loader");
418 return badge("Deploying", { icon: "loader", tone: "attn" });
445419 case "running":
446 return statusBadge("ok", "Running", "play");
420 return badge("Running", { icon: "play", tone: "success" });
447421 case "asleep":
448 return statusBadge("held", "Asleep", "clock");
422 return badge("Asleep", { icon: "clock", variant: "outline" });
449423 case "failed":
450 return statusBadge("failed", "Failed", "alert");
424 return badge("Failed", { icon: "alert", tone: "danger" });
451425 }
452426 }
453427
@@ -739,9 +713,7 @@ export function repoCounts(o: {
739713 openPulls?: number | null | undefined;
740714 /** Some origins report one number for issues *and* pulls; say so. */
741715 issuesIncludePulls?: boolean;
742 /**
743 * The repository we hold whose lists these count (`bind.ts`): absent for an origin's own numbers.
744 */
716 /** The repository we hold whose lists these count (`bind.ts`): absent for an origin's own numbers. */
745717 of?: { ownerName: string; name: string } | undefined;
746718 }): Html {
747719 const issues = o.openIssues ?? null;
@@ -806,9 +778,7 @@ export function chartBox(chart: Chart, cells: readonly Cell[], title: string): H
806778 return chartFrame(chart, drawChart(chart, cells, title));
807779 }
808780
809 /**
810 * The same box around a chart already drawn (`drawChart`'s own markup, from whoever read its rows).
811 */
781 /** The same box around a chart already drawn (`drawChart`'s own markup, from whoever read its rows). */
812782 export function chartFrame(chart: Chart, drawn: string): Html {
813783 return html`<div class="chart-box${chart === "table" ? " is-table" : ""}">${raw(drawn)}</div>`;
814784 }
@@ -1002,9 +972,8 @@ export interface RowOptions {
1002972 href?: string;
1003973 title: Html | string;
1004974 meta?: Html;
1005 /** Facts about the row, one `dt`/`dd` pair each, in a `dl.row-facts` under the meta. With facts
1006 * the row's main column is a `<div>`, so the `dl` is valid HTML: not for a `fold` row, whose
1007 * `<summary>` takes phrasing only. */
975 /** Facts about the row, one `dt`/`dd` pair each, in a `dl.row-facts` under the meta. With facts the row's
976 * main column is a `<div>`, so the `dl` is valid HTML: not for a `fold` row, whose `<summary>` takes phrasing only. */
1008977 facts?: readonly { label: string; value: Html | string }[];
1009978 /** Draw `.row-meta` even when `meta` is empty, for a script to write into. */
1010979 metaSlot?: boolean;
@@ -1029,9 +998,7 @@ export interface RowOptions {
1029998 /** The row folds: it is the `<summary>` of a `<details>` holding `body`,
1030999 * open when `open` says so. Its `lead` is the caret. */
10311000 fold?: { id: string; open: boolean; body: Html };
1032 /**
1033 * Why the list's count leaves this row out on purpose (`data-apart`, `bind.ts`): a sealed report.
1034 */
1001 /** Why the list's count leaves this row out on purpose (`data-apart`, `bind.ts`): a sealed report. */
10351002 apart?: string | undefined;
10361003 /** The row is a node of an ARIA tree: the row itself is the `treeitem` (it is what takes focus,
10371004 * so it says its level and, for a branch, `aria-expanded`), its `<li>` is `role="none"`,
@@ -1126,10 +1093,7 @@ export function tabs(items: TabItem[], ariaLabel: string): Html {
11261093 /** A segmented control built from links (a GET filter is navigation). */
11271094 export function seg(
11281095 items: { label: string; href: string; current: boolean; count?: number }[],
1129 /**
1130 * These links are a list's tabs: every item a reader may open is under one (`data-rows-tabs`,
1131 * `bind.ts`).
1132 */
1096 /** These links are a list's tabs: every item a reader may open is under one (`data-rows-tabs`, `bind.ts`). */
11331097 filters = false,
11341098 ): Html {
11351099 return html`<div class="seg"${filters ? raw(" data-rows-tabs") : null}>
test/status-badge.test.ts deleted −45
@@ -1,45 +0,0 @@
1 import { expect, test } from "bun:test";
2 import { envStateBadge, runStateBadge, statusBadge } from "../src/web/ui.ts";
3 import { components } from "../src/web/style/components.ts";
4
5 const RUNS = [
6 ["queued", "queued", "secondary", "Queued"],
7 ["running", "running", "attn", "Running"],
8 ["ok", "ok", "success", "Passed"],
9 ["failed", "failed", "danger", "Failed"],
10 ["cancelled", "cut", "outline", "Cancelled"],
11 ] as const;
12
13 test("each run state wears the badge with its status, variant and word", () => {
14 for (const [state, status, variant, word] of RUNS) {
15 const html = String(runStateBadge(state));
16 expect(html).toContain(`data-status="${status}"`);
17 expect(html).toContain(`data-variant="${variant}"`);
18 expect(html).toContain(word);
19 }
20 });
21
22 test("each environment state maps to the right status", () => {
23 const cases = [
24 [envStateBadge("deploying"), "running"],
25 [envStateBadge("running"), "ok"],
26 [envStateBadge("failed"), "failed"],
27 [envStateBadge("stopped"), "cut"],
28 [envStateBadge("stopped", true), "held"],
29 [envStateBadge("asleep"), "held"],
30 ] as const;
31 for (const [html, status] of cases) {
32 expect(String(html)).toContain(`data-status="${status}"`);
33 }
34 });
35
36 test("an agent run that is ok says Done, and the badge always carries its word", () => {
37 expect(String(runStateBadge("ok", "agent"))).toContain("Done");
38 expect(String(statusBadge("failed", "Failed", "x"))).toContain("Failed");
39 });
40
41 test("the bar is styled for the badge, faded states stay above 3:1", () => {
42 const css = String(components);
43 expect(css).toContain('.badge[data-status]::before');
44 expect(css).toContain('[data-status="cut"]::before { opacity: .7; }');
45 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs