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
revert-13637 → main 1 commit
4 files
changed +29
−117
docs/design/size-budget.json +8 −8
| @@ -1,23 +1,23 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "/": { |
| 3 | 3 | "js": 22016, |
| 4 | "css": 44800 | |
| 4 | "css": 44544 | |
| 5 | 5 | }, |
| 6 | 6 | "/explore": { |
| 7 | 7 | "js": 21760, |
| 8 | "css": 44800 | |
| 8 | "css": 44544 | |
| 9 | 9 | }, |
| 10 | 10 | "/map": { |
| 11 | 11 | "js": 28672, |
| 12 | "css": 46336 | |
| 12 | "css": 46080 | |
| 13 | 13 | }, |
| 14 | 14 | "/:owner/:name": { |
| 15 | 15 | "js": 38144, |
| 16 | "css": 44800 | |
| 16 | "css": 44544 | |
| 17 | 17 | }, |
| 18 | 18 | "/changelog": { |
| 19 | 19 | "js": 26368, |
| 20 | "css": 44800 | |
| 20 | "css": 44544 | |
| 21 | 21 | }, |
| 22 | 22 | "/:owner/:name/next": { |
| 23 | 23 | "js": 23296, |
| @@ -37,14 +37,14 @@ | ||
| 37 | 37 | }, |
| 38 | 38 | "/pricing": { |
| 39 | 39 | "js": 21760, |
| 40 | "css": 44800 | |
| 40 | "css": 44544 | |
| 41 | 41 | }, |
| 42 | 42 | "/forges/new": { |
| 43 | 43 | "js": 21760, |
| 44 | "css": 44800 | |
| 44 | "css": 44544 | |
| 45 | 45 | }, |
| 46 | 46 | "/claim": { |
| 47 | 47 | "js": 24064, |
| 48 | "css": 44800 | |
| 48 | "css": 44544 | |
| 49 | 49 | } |
| 50 | 50 | } |
src/web/style/components.ts −7
| @@ -222,13 +222,6 @@ a.stat:hover { border-color: var(--border-strong); } | ||
| 222 | 222 | background: color-mix(in srgb, var(--attn) 12%, transparent); |
| 223 | 223 | } |
| 224 | 224 | .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; } | |
| 232 | 225 | /* A loader that turns: the one icon that means "still going". */ |
| 233 | 226 | .ico-loader { animation: spin 1.1s linear infinite; } |
| 234 | 227 | /* 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 { | ||
| 186 | 186 | extra?: string; |
| 187 | 187 | /** The element's id, for a script or a fragment link that finds it. */ |
| 188 | 188 | 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`). */ | |
| 193 | 190 | rel?: "next" | "prev"; |
| 194 | 191 | } |
| 195 | 192 | |
| @@ -388,32 +385,6 @@ export function verdictBadge( | ||
| 388 | 385 | return badge(look.label, { icon: look.icon, tone: look.tone }); |
| 389 | 386 | } |
| 390 | 387 | |
| 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 | ||
| 417 | 388 | /** |
| 418 | 389 | * A run's state (docs/APPS.md): the one badge a check wears on a pull, a |
| 419 | 390 | * 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 { | ||
| 422 | 393 | export function runStateBadge(state: RunState, kind: RunKind = "deploy"): Html { |
| 423 | 394 | switch (state) { |
| 424 | 395 | case "queued": |
| 425 | return statusBadge("queued", "Queued", "clock"); | |
| 396 | return badge("Queued", { icon: "clock", variant: "secondary" }); | |
| 426 | 397 | case "running": |
| 427 | return statusBadge("running", "Running", "loader"); | |
| 398 | return badge("Running", { icon: "loader", tone: "attn" }); | |
| 428 | 399 | 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 | }); | |
| 430 | 404 | case "failed": |
| 431 | return statusBadge("failed", "Failed", "x"); | |
| 405 | return badge("Failed", { icon: "x", tone: "danger" }); | |
| 432 | 406 | case "cancelled": |
| 433 | return statusBadge("cut", "Cancelled", "ban"); | |
| 407 | return badge("Cancelled", { icon: "ban", variant: "outline" }); | |
| 434 | 408 | } |
| 435 | 409 | } |
| 436 | 410 | |
| @@ -438,16 +412,16 @@ export function runStateBadge(state: RunState, kind: RunKind = "deploy"): Html { | ||
| 438 | 412 | export function envStateBadge(state: EnvState, dormant = false): Html { |
| 439 | 413 | switch (state) { |
| 440 | 414 | 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" }); | |
| 443 | 417 | case "deploying": |
| 444 | return statusBadge("running", "Deploying", "loader"); | |
| 418 | return badge("Deploying", { icon: "loader", tone: "attn" }); | |
| 445 | 419 | case "running": |
| 446 | return statusBadge("ok", "Running", "play"); | |
| 420 | return badge("Running", { icon: "play", tone: "success" }); | |
| 447 | 421 | case "asleep": |
| 448 | return statusBadge("held", "Asleep", "clock"); | |
| 422 | return badge("Asleep", { icon: "clock", variant: "outline" }); | |
| 449 | 423 | case "failed": |
| 450 | return statusBadge("failed", "Failed", "alert"); | |
| 424 | return badge("Failed", { icon: "alert", tone: "danger" }); | |
| 451 | 425 | } |
| 452 | 426 | } |
| 453 | 427 | |
| @@ -739,9 +713,7 @@ export function repoCounts(o: { | ||
| 739 | 713 | openPulls?: number | null | undefined; |
| 740 | 714 | /** Some origins report one number for issues *and* pulls; say so. */ |
| 741 | 715 | 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. */ | |
| 745 | 717 | of?: { ownerName: string; name: string } | undefined; |
| 746 | 718 | }): Html { |
| 747 | 719 | const issues = o.openIssues ?? null; |
| @@ -806,9 +778,7 @@ export function chartBox(chart: Chart, cells: readonly Cell[], title: string): H | ||
| 806 | 778 | return chartFrame(chart, drawChart(chart, cells, title)); |
| 807 | 779 | } |
| 808 | 780 | |
| 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). */ | |
| 812 | 782 | export function chartFrame(chart: Chart, drawn: string): Html { |
| 813 | 783 | return html`<div class="chart-box${chart === "table" ? " is-table" : ""}">${raw(drawn)}</div>`; |
| 814 | 784 | } |
| @@ -1002,9 +972,8 @@ export interface RowOptions { | ||
| 1002 | 972 | href?: string; |
| 1003 | 973 | title: Html | string; |
| 1004 | 974 | 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. */ | |
| 1008 | 977 | facts?: readonly { label: string; value: Html | string }[]; |
| 1009 | 978 | /** Draw `.row-meta` even when `meta` is empty, for a script to write into. */ |
| 1010 | 979 | metaSlot?: boolean; |
| @@ -1029,9 +998,7 @@ export interface RowOptions { | ||
| 1029 | 998 | /** The row folds: it is the `<summary>` of a `<details>` holding `body`, |
| 1030 | 999 | * open when `open` says so. Its `lead` is the caret. */ |
| 1031 | 1000 | 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. */ | |
| 1035 | 1002 | apart?: string | undefined; |
| 1036 | 1003 | /** The row is a node of an ARIA tree: the row itself is the `treeitem` (it is what takes focus, |
| 1037 | 1004 | * 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 { | ||
| 1126 | 1093 | /** A segmented control built from links (a GET filter is navigation). */ |
| 1127 | 1094 | export function seg( |
| 1128 | 1095 | 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`). */ | |
| 1133 | 1097 | filters = false, |
| 1134 | 1098 | ): Html { |
| 1135 | 1099 | 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 | }); |
new above
offline