@mccaskie-labs/workbench-ui 0.0.0-stage → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # @mccaskie-labs/workbench-ui
2
+
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - No code change. The first version published by the publish workflow, which confirms the package's npm trusted publisher.
8
+
9
+ ## 0.2.1
10
+
11
+ - A folding card can carry a `summary` chip beside its heading, shown only while the card is folded ("All running" with a tick, "1 waiting"), so a folded card still says whether it needs anything.
12
+ - A folding card marked `attention` opens when the page loads even if the reader folded it earlier, and folds again once nothing in it needs them.
13
+
14
+ ## 0.2.0
15
+
16
+ - Cards can fold: `card(..., { collapsible: true })`. `jumpNav` is a row of pills that jump to a page's cards, each with a summary chip, and `topBar` takes it as `below`. `SECTIONS_SCRIPT` opens a folded card when its pill is pressed and remembers which cards were folded.
17
+
18
+ ## 0.1.0
19
+
20
+ - First version: the shared stylesheet (always dark), `shell`, `topBar`, `card`, `pill`, `chip`, and one format for times (`when`, `shortWhen`, `timeLeft`), money (`money`) and durations (`duration`) (`docs/spec.md` §10, 11 November 2026).
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # @mccaskie-labs/workbench-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The one look for every page of Workbench, a private platform: Workbench Control, the Gateway, the probe console and each project's starter page. Published publicly so Workbench projects can install it with no token; it is not supported for other uses.
4
+
5
+ ```sh
6
+ npm install @mccaskie-labs/workbench-ui
7
+ ```
8
+
9
+ ```ts
10
+ import { card, pill, shell, shortWhen, topBar } from '@mccaskie-labs/workbench-ui'
11
+
12
+ const html = shell({
13
+ title: 'Probes',
14
+ site: 'wb-probe',
15
+ top: topBar({ name: 'wb-probe', href: '/', env: 'staging', links: [['History', '/runs'], ['Compare', '/compare']] }),
16
+ body: card('Last run', `<div class="body">${pill('pass', 'Passed')} ${shortWhen(run.started_at)}</div>`, { about: 'The most recent full check.' }),
17
+ })
18
+ ```
19
+
20
+ Everything returns HTML text. Arguments described as plain text are escaped; arguments described as HTML are used as they are, so escape what goes into them with `escape`.
21
+
22
+ | Export | What it does |
23
+ | --- | --- |
24
+ | `shell({ title, site, top, body, head?, tail? })` | A whole page: the shared stylesheet, the top bar, the title as the heading, then `body` (HTML). `head` takes a page's own `<style>`; `tail` takes its `<script>` |
25
+ | `topBar({ name, href?, env?, links?, extra?, below? })` | The sticky bar: the page's name, the environment tag (`production` is red, anything else amber), then links |
26
+ | `card(title, inner, { id?, counts?, about?, collapsible?, summary?, attention? })` | A card. `about` is one plain sentence on what the card shows. `collapsible` lets the reader fold it away by its heading, and `summary` is a chip beside the heading that shows while the card is folded ("All running", "1 waiting"). `attention` opens the card on load even if it was folded earlier |
27
+ | `jumpNav([{ id, label, chip? }])` | A row of pills that jump to the page's cards, each with a summary chip ("1 waiting", "All running"). Pass it to `topBar` as `below`, so it stays on screen |
28
+ | `SECTIONS_SCRIPT` | Script for a page with folding cards and a `jumpNav`: a pill opens its card, and the browser remembers which cards were folded. Put it in a `<script>` with the response's nonce |
29
+ | `pill(tone, text)`, `chip(tone, text)` | The outcome pill, and the smaller one after it that says whether anything needs doing. Tones: `pass`, `refused`, `fail`, `skip`, `none`, `running` |
30
+ | `when(iso)`, `shortWhen(iso)` | A time in Manila, with UTC after it or on hover |
31
+ | `timeLeft(iso)` | "42 minutes left", or `''` once the time has passed |
32
+ | `money(usd)`, `duration(ms)` | "US$0.0042", "US$12.50"; "640 ms", "2.35 s", "3 min 5 s". Nothing to show is an en dash |
33
+ | `escape(text)` | Plain text made safe for HTML |
34
+ | `STYLE`, `CSS` | The stylesheet, as a `<style>` tag and as bare rules, for a page that builds its own document |
35
+
36
+ Pages are always dark, whatever the computer is set to. A page with its own rules adds them after the shared ones and uses the colour tokens (`--surface`, `--line`, `--pass` and so on), never its own colours.
37
+
38
+ Runs on Node 24 and the Cloudflare Workers runtime. No dependencies.
@@ -0,0 +1,117 @@
1
+ export { CSS, STYLE } from "./style.ts";
2
+ /** Plain text made safe to put in HTML, in text or in a quoted attribute. */
3
+ export declare const escape: (value: string) => string;
4
+ /** The outcome colours: a pill's class and, prefixed with o-, a table row's left edge. */
5
+ export type Tone = "pass" | "refused" | "fail" | "skip" | "none" | "running";
6
+ /** A coloured outcome pill. `text` is plain text. */
7
+ export declare function pill(tone: Tone, text: string): string;
8
+ /** A small square pill that follows an outcome pill: whether anything needs doing. `text` is plain text. */
9
+ export declare function chip(tone: Tone, text: string): string;
10
+ export interface CardOptions {
11
+ id?: string;
12
+ /** Pills beside the heading, as HTML. */
13
+ counts?: string;
14
+ /** One plain sentence under the heading on what the card shows. */
15
+ about?: string;
16
+ /**
17
+ * Let the reader fold the card away by its heading. It starts open, and
18
+ * needs no script. With `SECTIONS_SCRIPT` on the page and an `id` on the
19
+ * card, the browser remembers which cards were folded.
20
+ */
21
+ collapsible?: boolean;
22
+ /**
23
+ * For a collapsible card: a chip beside the heading that shows only while
24
+ * the card is folded, so a folded card still says whether it needs anything
25
+ * ("1 waiting", "All running"). Usually the same chip as the card's jump
26
+ * pill. With an `id` on the card, the chip's element has the id `<id>-chip`.
27
+ */
28
+ summary?: {
29
+ tone: Tone;
30
+ text: string;
31
+ };
32
+ /**
33
+ * For a collapsible card: something in it needs the reader now. With
34
+ * `SECTIONS_SCRIPT`, the card then opens when the page loads even if the
35
+ * reader folded it earlier; it folds again on a later load once this is off.
36
+ */
37
+ attention?: boolean;
38
+ }
39
+ /** A card: a heading bar over `inner`, which is HTML. */
40
+ export declare function card(title: string, inner: string, opts?: CardOptions): string;
41
+ export interface JumpItem {
42
+ /** The id of the card this pill jumps to. */
43
+ id: string;
44
+ /** The pill's words, usually the card's heading. Plain text. */
45
+ label: string;
46
+ /** A short summary after the label: whether anything needs doing ("1 waiting"), or a count ("4 active"). */
47
+ chip?: {
48
+ tone: Tone;
49
+ text: string;
50
+ };
51
+ }
52
+ /**
53
+ * A row of pills that jump to the page's cards, for `topBar`'s `below`. Each
54
+ * can carry a chip, so the bar says at a glance whether anything needs doing.
55
+ * A chip's element has the id `jump-<id>-chip`, for a page script that keeps it current
56
+ * (a folded card's own chip, from `card`'s `summary`, is `<id>-chip`).
57
+ */
58
+ export declare function jumpNav(items: readonly JumpItem[]): string;
59
+ /**
60
+ * Script for a page with collapsible cards and a `jumpNav`. A jump pill, or
61
+ * an address ending in #id, opens its card if it was folded. Which cards are
62
+ * folded is remembered in this browser, per page, except that a card marked
63
+ * `attention` always starts open. The page works without it.
64
+ * Put it in a <script> with the response's nonce.
65
+ */
66
+ export declare const SECTIONS_SCRIPT: string;
67
+ /** A time in full: Manila first, where Robert is, then UTC. */
68
+ export declare function when(iso: string): string;
69
+ /** A short Manila time for table rows, with the UTC time on hover. */
70
+ export declare function shortWhen(iso: string): string;
71
+ /** How long until `iso`, as "42 minutes left". Empty once it has passed or when the time can't be read. */
72
+ export declare function timeLeft(iso: string, now?: number): string;
73
+ /**
74
+ * Money, always in US dollars: "US$12.50", and four decimal places under a
75
+ * dollar ("US$0.0042"), where a single AI call's cost lives. A real cost too
76
+ * small for that says so, so it never reads as free. Nothing to show is an
77
+ * en dash.
78
+ */
79
+ export declare function money(usd: number | null | undefined): string;
80
+ /**
81
+ * A duration from milliseconds: "640 ms", "2.35 s", "14.2 s", "3 min 5 s",
82
+ * "2 h 5 min". The unit is chosen after rounding. A negative time (two clocks
83
+ * that disagree) reads as 0 ms, and nothing to show is an en dash.
84
+ */
85
+ export declare function duration(ms: number | null | undefined): string;
86
+ export interface TopBarOptions {
87
+ /** The page's name in the bar, such as "Workbench Control". Plain text. */
88
+ name: string;
89
+ /** Where the name links to. Left out, the name is not a link. */
90
+ href?: string;
91
+ /** The environment tag after the name: "staging", "production" or "development". */
92
+ env?: string;
93
+ /** Links on the right, as [label, address]. */
94
+ links?: readonly (readonly [label: string, href: string])[];
95
+ /** HTML after the links, such as a page's one filled button. */
96
+ extra?: string;
97
+ /** HTML for a second row that stays on screen with the bar, such as `jumpNav`. */
98
+ below?: string;
99
+ }
100
+ /** The sticky bar on top of every page: the name, the environment tag, then links. */
101
+ export declare function topBar(opts: TopBarOptions): string;
102
+ export interface ShellOptions {
103
+ /** The page's heading and the first half of the tab title. Plain text. */
104
+ title: string;
105
+ /** The second half of the tab title, such as "Workbench Control". Plain text. */
106
+ site: string;
107
+ /** The top bar, from `topBar`. */
108
+ top: string;
109
+ /** The page below its heading, as HTML. */
110
+ body: string;
111
+ /** HTML for the end of the head, such as a page's own <style> after the shared one. */
112
+ head?: string;
113
+ /** HTML after the page, such as a <script> with the response's nonce. */
114
+ tail?: string;
115
+ }
116
+ /** A whole page: the shared look, the top bar, the heading, then `body`. */
117
+ export declare function shell(opts: ShellOptions): string;
package/dist/index.js ADDED
@@ -0,0 +1,162 @@
1
+ // Workbench pages: one look and one set of words for every page Robert sees
2
+ // (Control, the Gateway, the probe console and each project's starter page).
3
+ // Everything here returns HTML text; every value given as plain text is
4
+ // escaped here, and arguments documented as HTML are trusted as they are.
5
+ import { STYLE } from "./style.js";
6
+ export { CSS, STYLE } from "./style.js";
7
+ /** Plain text made safe to put in HTML, in text or in a quoted attribute. */
8
+ export const escape = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
9
+ /** A coloured outcome pill. `text` is plain text. */
10
+ export function pill(tone, text) {
11
+ return `<span class="pill ${tone}">${escape(text)}</span>`;
12
+ }
13
+ /** A small square pill that follows an outcome pill: whether anything needs doing. `text` is plain text. */
14
+ export function chip(tone, text) {
15
+ return `<span class="chip ${tone}">${escape(text)}</span>`;
16
+ }
17
+ /** A card: a heading bar over `inner`, which is HTML. */
18
+ export function card(title, inner, opts = {}) {
19
+ const id = opts.id ? ` id="${escape(opts.id)}"` : "";
20
+ const counts = opts.counts ? `<span class="counts">${opts.counts}</span>` : "";
21
+ const about = opts.about ? `<p class="about">${escape(opts.about)}</p>` : "";
22
+ if (opts.collapsible) {
23
+ // Only the heading and its sentence fold the card: pills that are links sit below, so a near miss can't fold it.
24
+ const sentence = opts.about ? `<span class="about">${escape(opts.about)}</span>` : "";
25
+ const chipId = opts.id ? ` id="${escape(opts.id)}-chip"` : "";
26
+ const summary = opts.summary ? `<span class="chip ${opts.summary.tone}"${chipId}>${escape(opts.summary.text)}</span>` : "";
27
+ return `<details class="card"${id}${opts.attention ? " data-attention" : ""} open><summary><h2>${escape(title)}</h2>${sentence}${summary}</summary>${counts}${inner}</details>`;
28
+ }
29
+ return `<section class="card"${id}><header><h2>${escape(title)}</h2>${counts}${about}</header>${inner}</section>`;
30
+ }
31
+ /**
32
+ * A row of pills that jump to the page's cards, for `topBar`'s `below`. Each
33
+ * can carry a chip, so the bar says at a glance whether anything needs doing.
34
+ * A chip's element has the id `jump-<id>-chip`, for a page script that keeps it current
35
+ * (a folded card's own chip, from `card`'s `summary`, is `<id>-chip`).
36
+ */
37
+ export function jumpNav(items) {
38
+ const links = items.map((i) => `<a href="#${escape(i.id)}">${escape(i.label)}${i.chip ? `<span class="chip ${i.chip.tone}" id="jump-${escape(i.id)}-chip">${escape(i.chip.text)}</span>` : ""}</a>`);
39
+ return `<nav class="jump" aria-label="Sections">${links.join("")}</nav>`;
40
+ }
41
+ /**
42
+ * Script for a page with collapsible cards and a `jumpNav`. A jump pill, or
43
+ * an address ending in #id, opens its card if it was folded. Which cards are
44
+ * folded is remembered in this browser, per page, except that a card marked
45
+ * `attention` always starts open. The page works without it.
46
+ * Put it in a <script> with the response's nonce.
47
+ */
48
+ export const SECTIONS_SCRIPT = `(() => {
49
+ const key = "wb-folded:" + location.pathname;
50
+ let folded = [];
51
+ try { folded = JSON.parse(localStorage.getItem(key) || "[]"); if (!Array.isArray(folded)) folded = []; } catch (e) {}
52
+ const cards = [...document.querySelectorAll("details.card[id]")];
53
+ const save = () => { try { localStorage.setItem(key, JSON.stringify(folded)); } catch (e) {} };
54
+ // The card a #hash names, or nothing: a mangled hash must never stop the page's other scripts.
55
+ const named = (hash) => {
56
+ let id = hash.slice(1);
57
+ try { id = decodeURIComponent(id); } catch (e) {}
58
+ const el = id ? document.getElementById(id) : null;
59
+ return el && el.matches("details.card") ? el : null;
60
+ };
61
+ // Opening a card to show it (a pill, a link) is not the reader unfolding it, so it isn't remembered.
62
+ const shown = new Set();
63
+ const show = (el, scroll) => { if (!el) return; if (!el.open) { shown.add(el.id); el.open = true; } if (scroll) el.scrollIntoView(); };
64
+ // A card that needs the reader stays open on load, whatever was folded before.
65
+ for (const c of cards) if (folded.includes(c.id) && !c.hasAttribute("data-attention")) c.open = false;
66
+ show(named(location.hash), true);
67
+ for (const c of cards) c.addEventListener("toggle", () => {
68
+ if (shown.delete(c.id)) return;
69
+ folded = folded.filter((id) => id !== c.id);
70
+ if (!c.open) folded.push(c.id);
71
+ save();
72
+ });
73
+ addEventListener("hashchange", () => show(named(location.hash), true));
74
+ for (const a of document.querySelectorAll("nav.jump a")) a.addEventListener("click", () => show(named(a.hash), false));
75
+ })();`;
76
+ const utc = (d) => d.toISOString().replace(".000", "");
77
+ const LONG = new Intl.DateTimeFormat("en-AU", { timeZone: "Asia/Manila", dateStyle: "medium", timeStyle: "medium" });
78
+ const SHORT = new Intl.DateTimeFormat("en-AU", { timeZone: "Asia/Manila", day: "numeric", month: "short", hour: "numeric", minute: "2-digit" });
79
+ /** A time in full: Manila first, where Robert is, then UTC. */
80
+ export function when(iso) {
81
+ const d = new Date(iso);
82
+ if (Number.isNaN(d.getTime()))
83
+ return escape(iso);
84
+ return `${escape(LONG.format(d))} Manila (${escape(utc(d))})`;
85
+ }
86
+ /** A short Manila time for table rows, with the UTC time on hover. */
87
+ export function shortWhen(iso) {
88
+ const d = new Date(iso);
89
+ if (Number.isNaN(d.getTime()))
90
+ return escape(iso);
91
+ return `<span title="${escape(utc(d))}">${escape(SHORT.format(d))}</span>`;
92
+ }
93
+ /** How long until `iso`, as "42 minutes left". Empty once it has passed or when the time can't be read. */
94
+ export function timeLeft(iso, now = Date.now()) {
95
+ const ms = new Date(iso).getTime() - now;
96
+ if (!Number.isFinite(ms) || ms <= 0)
97
+ return "";
98
+ const minutes = Math.ceil(ms / 60_000);
99
+ if (minutes < 60)
100
+ return `${minutes} ${minutes === 1 ? "minute" : "minutes"} left`;
101
+ const hours = Math.floor(minutes / 60);
102
+ const rest = minutes % 60;
103
+ return `${hours} ${hours === 1 ? "hour" : "hours"}${rest ? ` ${rest} min` : ""} left`;
104
+ }
105
+ /**
106
+ * Money, always in US dollars: "US$12.50", and four decimal places under a
107
+ * dollar ("US$0.0042"), where a single AI call's cost lives. A real cost too
108
+ * small for that says so, so it never reads as free. Nothing to show is an
109
+ * en dash.
110
+ */
111
+ export function money(usd) {
112
+ if (usd === null || usd === undefined || !Number.isFinite(usd))
113
+ return "–";
114
+ if (usd === 0)
115
+ return "US$0";
116
+ const sign = usd < 0 ? "-" : "";
117
+ const amount = Math.abs(usd);
118
+ if (amount < 0.00005)
119
+ return `${sign}under US$0.0001`;
120
+ // Choose the decimal places after rounding, so 0.99996 reads "US$1.00".
121
+ const small = Number(amount.toFixed(4)) < 1;
122
+ return `${sign}US$${amount.toFixed(small ? 4 : 2)}`;
123
+ }
124
+ /**
125
+ * A duration from milliseconds: "640 ms", "2.35 s", "14.2 s", "3 min 5 s",
126
+ * "2 h 5 min". The unit is chosen after rounding. A negative time (two clocks
127
+ * that disagree) reads as 0 ms, and nothing to show is an en dash.
128
+ */
129
+ export function duration(ms) {
130
+ if (ms === null || ms === undefined || !Number.isFinite(ms))
131
+ return "–";
132
+ const whole = Math.max(0, Math.round(ms));
133
+ if (whole < 1000)
134
+ return `${whole} ms`;
135
+ if (whole < 9995)
136
+ return `${(whole / 1000).toFixed(2)} s`;
137
+ if (whole < 59_950)
138
+ return `${(whole / 1000).toFixed(1)} s`;
139
+ const seconds = Math.round(whole / 1000);
140
+ if (seconds < 3600)
141
+ return `${Math.floor(seconds / 60)} min${seconds % 60 ? ` ${seconds % 60} s` : ""}`;
142
+ const minutes = Math.round(seconds / 60);
143
+ return `${Math.floor(minutes / 60)} h${minutes % 60 ? ` ${minutes % 60} min` : ""}`;
144
+ }
145
+ /** The sticky bar on top of every page: the name, the environment tag, then links. */
146
+ export function topBar(opts) {
147
+ const name = opts.href ? `<a class="brand" href="${escape(opts.href)}">${escape(opts.name)}</a>` : `<span class="brand">${escape(opts.name)}</span>`;
148
+ // Only "production" has its own colour; any other environment is amber.
149
+ const env = opts.env ? `<span class="env${opts.env === "production" ? " production" : ""}">${escape(opts.env)}</span>` : "";
150
+ const links = opts.links?.length
151
+ ? `<nav class="links" aria-label="Pages">${opts.links.map(([label, href]) => `<a href="${escape(href)}">${escape(label)}</a>`).join("")}</nav>`
152
+ : "";
153
+ const below = opts.below ? `<div class="wrap below">${opts.below}</div>` : "";
154
+ return `<header class="top"><div class="wrap">${name}${env}${links}${opts.extra ?? ""}</div>${below}</header>`;
155
+ }
156
+ /** A whole page: the shared look, the top bar, the heading, then `body`. */
157
+ export function shell(opts) {
158
+ return `<!doctype html><html lang="en-AU"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="dark">
159
+ <title>${escape(opts.title)} · ${escape(opts.site)}</title>${STYLE}${opts.head ?? ""}
160
+ ${opts.top}
161
+ <main class="wrap"><h1>${escape(opts.title)}</h1>${opts.body}</main>${opts.tail ?? ""}</html>`;
162
+ }
@@ -0,0 +1,4 @@
1
+ /** The shared rules, without a <style> tag, for a page that adds its own after them. */
2
+ export declare const CSS: string;
3
+ /** The shared rules as a <style> tag. */
4
+ export declare const STYLE: string;
package/dist/style.js ADDED
@@ -0,0 +1,157 @@
1
+ // The one stylesheet for every Workbench page. Colours are tokens, and every
2
+ // page is dark whatever the computer is set to (docs/spec.md §10, 11 November
3
+ // 2026). A page adds its own rules after this, never a second copy of these.
4
+ /** The shared rules, without a <style> tag, for a page that adds its own after them. */
5
+ export const CSS = `:root{color-scheme:dark;--bg:#121214;--surface:#1b1b1f;--raised:#25252b;--text:#e8e8ec;--muted:#9a9aa6;
6
+ --line:#33333b;--bar:rgba(18,18,20,.92);--accent:#4c8dff;--accent-hover:#6aa1ff;--accent-text:#0b0b0d;--ok:#5cc87a;--bad:#ff6b66;--warn:#f0a43a;
7
+ --focus:rgba(76,141,255,.4);--pass:#5cc87a;--refused:#b48cff;--fail:#ff6b66;--skip:#f0a43a;--run:#4c8dff;
8
+ --pass-bg:rgba(92,200,122,.1);--refused-bg:rgba(180,140,255,.1);--fail-bg:rgba(255,107,102,.12);--skip-bg:rgba(240,164,58,.1);--run-bg:rgba(76,141,255,.12);
9
+ --mono:ui-monospace,"Cascadia Code",Consolas,monospace;--width:max(64rem,80vw)}
10
+ *{box-sizing:border-box}
11
+ html{background:var(--bg)}
12
+ body{font:15px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;margin:0;color:var(--text);background:var(--bg)}
13
+ .wrap{max-width:var(--width);margin:0 auto;padding:0 1rem}
14
+ main.wrap{padding-top:1.75rem;padding-bottom:3rem}
15
+ main.wrap>p:not(.note):not(.warn){max-width:60rem}
16
+ header.top{position:sticky;top:0;z-index:10;background:var(--bar);backdrop-filter:blur(8px);border-bottom:1px solid var(--line)}
17
+ header.top .wrap{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1rem;padding-top:.75rem;padding-bottom:.75rem}
18
+ .brand{font-size:1.15rem;font-weight:700;line-height:1.2;color:var(--text);text-decoration:none}
19
+ a.brand:hover{color:var(--text)}
20
+ .env{font-size:.7rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:.2rem .55rem;border-radius:999px;
21
+ border:1px solid var(--warn);color:var(--warn);white-space:nowrap}
22
+ .env.production{border-color:var(--bad);color:var(--bad)}
23
+ nav.links{display:flex;flex-wrap:wrap;gap:.4rem;margin-left:auto}
24
+ nav.links a{font-size:.85rem;text-decoration:none;color:var(--text);padding:.25rem .75rem;border:1px solid var(--line);border-radius:999px;background:var(--surface)}
25
+ nav.links a:hover{border-color:var(--accent);color:var(--accent-hover)}
26
+ h1{font-size:1.6rem;line-height:1.2;margin:0 0 .6rem}
27
+ h2{font-size:1.05rem;margin:2rem 0 .75rem}
28
+ a{color:var(--accent)}a:hover{color:var(--accent-hover)}
29
+ code{font:.85em/1.4 var(--mono)}
30
+ small{font-size:.8rem}
31
+ pre{font:.85rem/1.5 var(--mono);white-space:pre-wrap;overflow-wrap:anywhere;padding:.75rem 1rem;margin:.75rem 0;
32
+ background:var(--surface);border:1px solid var(--line);border-radius:8px;max-height:28rem;overflow:auto}
33
+ button{font:inherit;font-size:.9rem;font-weight:600;padding:.5rem 1.1rem;border:1px solid var(--accent);border-radius:6px;background:var(--accent);
34
+ color:var(--accent-text);cursor:pointer;line-height:1.2;white-space:nowrap}
35
+ button:hover{background:var(--accent-hover);border-color:var(--accent-hover)}
36
+ button[value=reject],button[value=deny]{background:transparent;color:var(--text);border-color:var(--line)}
37
+ button[value=reject]:hover,button[value=deny]:hover{background:var(--raised);border-color:var(--muted)}
38
+ button:disabled{opacity:.45;cursor:not-allowed}
39
+ button+button{margin-left:.5rem}
40
+ input:not([type=hidden]){font:inherit;color:var(--text);background:var(--surface);border:1px solid var(--line);border-radius:6px;
41
+ padding:.45rem .6rem;line-height:1.2}
42
+ input[type=number]{width:7.5rem;font-variant-numeric:tabular-nums}
43
+ button:focus-visible,input:focus-visible,a:focus-visible{outline:none;box-shadow:0 0 0 3px var(--focus)}
44
+ .warn{padding:.6rem .9rem;border-left:3px solid var(--warn);background:var(--surface);border-radius:0 6px 6px 0}
45
+ .note{padding:.6rem .9rem;border-left:3px solid var(--line);background:var(--surface);border-radius:0 6px 6px 0}
46
+ .note.good{border-left-color:var(--pass)}.note.bad{border-left-color:var(--fail);color:var(--text)}
47
+ .muted{color:var(--muted);font-size:.875rem}
48
+ .ok{color:var(--ok)}.bad{color:var(--bad)}
49
+ .quick{display:inline-flex;align-items:baseline;gap:1rem;white-space:nowrap}.quick form{display:inline;margin:0}
50
+ .quick button.link{font:inherit;padding:0;border:0;border-radius:0;background:none;color:var(--accent);text-decoration:underline;cursor:pointer}
51
+ .quick button.link:hover{background:none;color:var(--accent-hover)}
52
+ .actions{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem;margin:1rem 0}.actions form{margin:0}
53
+ .actions label{display:flex;align-items:center;gap:.5rem}
54
+ .card{background:var(--surface);border:1px solid var(--line);border-radius:10px;margin:0 0 1.5rem;overflow:hidden;scroll-margin-top:8rem}
55
+ .card>header,details.card>summary{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem 1rem;padding:.85rem 1.1rem}
56
+ .card>header,details.card[open]>summary{border-bottom:1px solid var(--line)}
57
+ .card>header h2,details.card>summary h2{font-size:1.05rem;margin:0}
58
+ .card>header .about,details.card>summary .about{margin:0;flex-basis:100%;color:var(--muted);font-size:.875rem}
59
+ .card>header .counts,details.card>.counts{display:flex;flex-wrap:wrap;gap:.35rem}
60
+ details.card>.counts{padding:.7rem 1.1rem;border-bottom:1px solid var(--line)}
61
+ details.card>summary{cursor:pointer;list-style:none}
62
+ details.card:not([open])>summary .about,details.card[open]>summary>.chip{display:none}
63
+ details.card>summary>.chip{font-size:.75rem}
64
+ details.card>summary>.chip.pass::before,nav.jump .chip.pass::before{content:"\\2713\\00a0"}
65
+ details.card>summary::-webkit-details-marker{display:none}
66
+ details.card>summary:hover{background:var(--raised)}
67
+ details.card>summary h2{display:flex;align-items:center;gap:.5rem}
68
+ details.card>summary h2::before{content:"";width:.5rem;height:.5rem;border-right:2px solid var(--muted);border-bottom:2px solid var(--muted);
69
+ transform:rotate(-45deg);transition:transform .15s;flex:none}
70
+ details.card[open]>summary h2::before{transform:rotate(45deg)}
71
+ details.card>summary:focus-visible{outline:none;box-shadow:inset 0 0 0 3px var(--focus)}
72
+ header.top .wrap.below{padding-top:0;padding-bottom:.6rem}
73
+ nav.jump{display:flex;gap:.4rem;overflow-x:auto;white-space:nowrap}
74
+ nav.jump a{display:inline-flex;align-items:center;gap:.45rem;font-size:.85rem;text-decoration:none;color:var(--text);padding:.25rem .5rem .25rem .75rem;
75
+ border:1px solid var(--line);border-radius:999px;background:var(--surface)}
76
+ nav.jump a:hover{border-color:var(--accent);color:var(--accent-hover)}
77
+ nav.jump .chip{vertical-align:0}
78
+ .card:target{border-color:var(--accent)}
79
+ .card .body{padding:.85rem 1.1rem}
80
+ .card .body>:first-child{margin-top:0}.card .body>:last-child{margin-bottom:0}
81
+ .card>.body+.scroll,.card>div+.body{border-top:1px solid var(--line)}
82
+ .card>pre{margin:0;border:0;border-radius:0;background:transparent;max-height:none}
83
+ .card .scroll{margin:0;border:0;border-radius:0}
84
+ .card .body>p.bad,.card .body>p:only-child{margin:0}
85
+ .scroll{overflow-x:auto;margin:.75rem 0;border:1px solid var(--line);border-radius:8px;background:var(--surface)}
86
+ table{border-collapse:collapse;width:100%}
87
+ th,td{text-align:left;vertical-align:top;padding:.6rem 1.1rem}
88
+ thead th{font-size:.72rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);background:var(--raised);
89
+ border-bottom:1px solid var(--line);white-space:nowrap}
90
+ tbody tr+tr td,tbody tr+tr th{border-top:1px solid var(--line)}
91
+ tbody tr:hover td,tbody tr:hover th{background:var(--raised)}
92
+ table.kv th{width:12rem;font-weight:600;white-space:nowrap;color:var(--muted);font-size:.875rem}
93
+ td.nowrap,td code,.nowrap{white-space:nowrap}
94
+ td small{display:block;color:var(--muted);margin-top:.15rem}
95
+ tbody tr td:first-child,tbody tr th:first-child{box-shadow:inset 3px 0 0 var(--edge,transparent)}
96
+ tr.o-pass{--edge:var(--pass)}tr.o-refused{--edge:var(--refused)}tr.o-fail{--edge:var(--fail)}tr.o-skip{--edge:var(--skip)}tr.o-run{--edge:var(--run)}
97
+ tr.o-fail td{background:var(--fail-bg)}
98
+ .pill{display:inline-block;font-size:.75rem;font-weight:600;line-height:1.3;padding:.15rem .6rem;border-radius:999px;border:1px solid currentColor;
99
+ white-space:nowrap;vertical-align:.05em}
100
+ .pill.pass{color:var(--pass);background:var(--pass-bg)}
101
+ .pill.refused{color:var(--refused);background:var(--refused-bg)}
102
+ .pill.fail{color:var(--fail);background:var(--fail-bg)}
103
+ .pill.skip{color:var(--skip);background:var(--skip-bg)}
104
+ .pill.none{color:var(--muted);border-color:var(--line)}
105
+ .pill.running{color:var(--run);background:var(--run-bg)}
106
+ .pill.running::before{content:"";display:inline-block;width:.6em;height:.6em;margin-right:.4em;border-radius:50%;border:2px solid currentColor;
107
+ border-right-color:transparent;vertical-align:-.05em;animation:spin .8s linear infinite}
108
+ @keyframes spin{to{transform:rotate(360deg)}}
109
+ .pill[title]{cursor:help}
110
+ .chip{display:inline-block;font-size:.68rem;font-weight:600;line-height:1.3;padding:.05rem .45rem;border-radius:4px;border:1px solid var(--line);
111
+ background:var(--raised);white-space:nowrap;vertical-align:.1em}
112
+ .chip.pass{color:var(--pass)}.chip.running{color:var(--run)}.chip.fail{color:var(--fail)}.chip.skip{color:var(--skip)}.chip.refused{color:var(--refused)}.chip.none{color:var(--muted)}
113
+ td.outcome{min-width:22rem}
114
+ td.outcome p{margin:.3rem 0 0;font-size:.875rem;overflow-wrap:anywhere}
115
+ td.outcome p.means{color:var(--muted)}
116
+ td.outcome code{white-space:normal;overflow-wrap:anywhere}
117
+ details.asked{margin-top:.35rem;font-size:.85rem}
118
+ details.asked summary{cursor:pointer;color:var(--accent);width:max-content}
119
+ dl.facts{display:grid;grid-template-columns:9rem 1fr;gap:.3rem 1rem;margin:.4rem 0 0;padding:.6rem .75rem;background:var(--bg);border:1px solid var(--line);border-radius:8px}
120
+ dl.facts dt{color:var(--muted);font-size:.8rem}
121
+ dl.facts dd{margin:0;overflow-wrap:anywhere}
122
+ dl.facts ul{margin:0;padding-left:1.1rem}
123
+ .filters{display:flex;flex-wrap:wrap;gap:.35rem}
124
+ .filters a.pill{text-decoration:none;cursor:pointer}
125
+ .filters a.pill:hover{box-shadow:0 0 0 2px var(--line)}
126
+ .filters a.pill[aria-current]{box-shadow:0 0 0 2px currentColor}
127
+ .filters.on a.pill:not([aria-current]){opacity:.45}
128
+ .filters.on a.pill:not([aria-current]):hover{opacity:.8}
129
+ .filter-note{font-size:.875rem;color:var(--muted)}
130
+ .pager{display:flex;flex-wrap:wrap;align-items:center;gap:.35rem;margin:.75rem 0;font-size:.9rem}
131
+ .pager a,.pager strong{display:inline-block;min-width:2.1rem;text-align:center;padding:.3rem .6rem;border:1px solid var(--line);
132
+ border-radius:6px;text-decoration:none;background:var(--surface)}
133
+ .pager strong{background:var(--accent);border-color:var(--accent);color:var(--accent-text)}
134
+ .pager .gap{color:var(--muted);padding:0 .2rem}
135
+ .pager.end{justify-content:flex-end}
136
+ .split{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem 1.5rem;margin:0 0 .75rem}
137
+ .split>*{margin:0}
138
+ footer.page{color:var(--muted);font-size:.8rem;margin-top:1.5rem}
139
+ .tech{font:.78rem/1.4 var(--mono);color:var(--muted)}
140
+ details.more{margin:1.5rem 0}
141
+ details.more summary{cursor:pointer;color:var(--accent);width:max-content;max-width:100%;font-size:.875rem}
142
+ .lbl{font-size:.7rem;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--muted);margin:1rem 0 .3rem}
143
+ dl.plain{display:grid;grid-template-columns:minmax(8rem,13rem) 1fr;gap:.45rem 1rem;margin:.6rem 0 0}
144
+ dl.plain dt{color:var(--muted);font-size:.875rem;font-weight:600}
145
+ dl.plain dd{margin:0;min-width:0;overflow-wrap:anywhere}
146
+ dl.plain dd>pre{margin:0;max-height:none}
147
+ dl.plain ul{margin:0;padding-left:1.1rem}
148
+ dl.plain dl.plain{grid-template-columns:1fr;gap:.1rem;margin:0;padding:.5rem .75rem;border:1px solid var(--line);border-radius:8px;background:var(--bg)}
149
+ dl.plain dl.plain>dd{margin-bottom:.5rem}dl.plain dl.plain>dd:last-child{margin-bottom:0}
150
+ .exact{white-space:pre-wrap}
151
+ .bool{font-size:.8rem;font-weight:600;padding:0 .4rem;border:1px solid var(--line);border-radius:4px;background:var(--raised)}
152
+ @media (max-width:640px){dl.plain{grid-template-columns:1fr;gap:.1rem}dl.plain dd{margin-bottom:.5rem}}
153
+ @media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
154
+ @media (max-width:640px){nav.links{margin-left:0}th,td{padding:.55rem .7rem}table.kv th{width:auto}}
155
+ `;
156
+ /** The shared rules as a <style> tag. */
157
+ export const STYLE = `<style>\n${CSS}</style>`;
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.2",
4
+ "description": "Workbench pages: one dark look, a top bar with the environment tag, cards, outcome pills, and one format for times, money and durations.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mccaskie-labs/workbench.git",
10
+ "directory": "packages/ui"
11
+ },
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "CHANGELOG.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json",
33
+ "test": "vitest run",
34
+ "build": "node scripts/build.mjs",
35
+ "prepack": "node scripts/build.mjs"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "24.19.2",
39
+ "vitest": "^5.1.0"
40
+ }
41
+ }