@mccaskie-labs/workbench-ui 0.4.1 → 0.5.0
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 +6 -0
- package/dist/cli.js +7 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -21
- package/dist/style.d.ts +4 -2
- package/dist/style.js +78 -127
- package/dist/styles.js +1 -1
- package/dist/ui-styles.d.ts +3 -0
- package/dist/ui-styles.js +165 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-ui
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Breaking: what the helpers draw is on `wb-ui-*` classes, listed as `UI_STYLES` (exported, and at `./styles`), so a project restyles a Workbench page in its project.css. `shell` puts `wb-ui` on `<html>` and draws `wb-ui-main` and `wb-ui-title`; `topBar` draws `wb-ui-bar`, `-bar-row`, `-bar-below`, `-name`, `-env` (with `data-env`), `-links` and `-link`; `card` draws `wb-ui-card`, `-card-head`, `-card-title`, `-card-about` and `-card-counts`; `jumpNav` draws `wb-ui-jump` and `-jump-link`; `pill` and `chip` draw `wb-ui-pill` and `wb-ui-chip` with the tone in `data-tone` (was a second class). Every colour and size is a `--wb-ui-*` variable (`--bg` is `--wb-ui-background`, `--text` is `--wb-ui-text`, and so on), so none clashes with a project's own. `CSS` keeps the page conventions for markup a page writes itself (tables, buttons, notes, inputs; `.card .body` is `.wb-ui-card .body`); `UI_CSS` is UI_STYLES as plain rules, and `STYLE` holds both. `npx workbench-ui styles` always includes UI_STYLES.
|
|
8
|
+
|
|
3
9
|
## 0.4.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from
|
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { dirname, join, resolve } from "node:path";
|
|
20
20
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
21
|
+
import { UI_STYLES } from "./ui-styles.js";
|
|
21
22
|
import { renderStyles, STYLE_FILES, STYLED_SCOPE, starterProjectCss, unknownNames } from "./styles.js";
|
|
22
23
|
const USAGE = "usage: workbench-ui styles [--check] [dir]";
|
|
23
24
|
const read = (path) => readFileSync(path, "utf8").replace(/\r\n/g, "\n");
|
|
@@ -51,7 +52,12 @@ export async function installedStyles(dir) {
|
|
|
51
52
|
tools.push({ styles: found[0], version: manifest.version });
|
|
52
53
|
}
|
|
53
54
|
const own = JSON.parse(read(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json")));
|
|
54
|
-
|
|
55
|
+
const uiVersion = version("@mccaskie-labs/workbench-ui") ?? own.version;
|
|
56
|
+
// The page look's own classes are always there: this command is workbench-ui.
|
|
57
|
+
if (!tools.some((t) => t.styles.package === UI_STYLES.package))
|
|
58
|
+
tools.push({ styles: UI_STYLES, version: uiVersion });
|
|
59
|
+
tools.sort((a, b) => (a.styles.package < b.styles.package ? -1 : 1));
|
|
60
|
+
return { tools, uiVersion };
|
|
55
61
|
}
|
|
56
62
|
/** What `styles` writes in `dir`, and what --check would fail on, without touching the disk. */
|
|
57
63
|
export function planStyles(dir, tools, uiVersion) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { CSS, STYLE } from "./style.ts";
|
|
1
|
+
export { CSS, STYLE, UI_CSS } from "./style.ts";
|
|
2
|
+
export { UI_STYLES } from "./ui-styles.ts";
|
|
2
3
|
export { FORM_SCRIPT } from "./form-script.ts";
|
|
3
4
|
export { renderStyles, STYLE_FILES, STYLED_SCOPE, styleNames, styleProblems, STYLESHEETS, starterProjectCss, unknownNames, type InstalledStyles, type StyleClass, type StyleState, type StyleVariable, type ToolStyles, } from "./styles.ts";
|
|
4
5
|
/** Plain text made safe to put in HTML, in text or in a quoted attribute. */
|
package/dist/index.js
CHANGED
|
@@ -3,32 +3,33 @@
|
|
|
3
3
|
// Everything here returns HTML text; every value given as plain text is
|
|
4
4
|
// escaped here, and arguments documented as HTML are trusted as they are.
|
|
5
5
|
import { STYLE } from "./style.js";
|
|
6
|
-
export { CSS, STYLE } from "./style.js";
|
|
6
|
+
export { CSS, STYLE, UI_CSS } from "./style.js";
|
|
7
|
+
export { UI_STYLES } from "./ui-styles.js";
|
|
7
8
|
export { FORM_SCRIPT } from "./form-script.js";
|
|
8
9
|
export { renderStyles, STYLE_FILES, STYLED_SCOPE, styleNames, styleProblems, STYLESHEETS, starterProjectCss, unknownNames, } from "./styles.js";
|
|
9
10
|
/** Plain text made safe to put in HTML, in text or in a quoted attribute. */
|
|
10
11
|
export const escape = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
11
12
|
/** A coloured outcome pill. `text` is plain text. */
|
|
12
13
|
export function pill(tone, text) {
|
|
13
|
-
return `<span class="pill ${tone}">${escape(text)}</span>`;
|
|
14
|
+
return `<span class="wb-ui-pill" data-tone="${tone}">${escape(text)}</span>`;
|
|
14
15
|
}
|
|
15
16
|
/** A small square pill that follows an outcome pill: whether anything needs doing. `text` is plain text. */
|
|
16
17
|
export function chip(tone, text) {
|
|
17
|
-
return `<span class="chip ${tone}">${escape(text)}</span>`;
|
|
18
|
+
return `<span class="wb-ui-chip" data-tone="${tone}">${escape(text)}</span>`;
|
|
18
19
|
}
|
|
19
20
|
/** A card: a heading bar over `inner`, which is HTML. */
|
|
20
21
|
export function card(title, inner, opts = {}) {
|
|
21
22
|
const id = opts.id ? ` id="${escape(opts.id)}"` : "";
|
|
22
|
-
const counts = opts.counts ? `<span class="counts">${opts.counts}</span>` : "";
|
|
23
|
-
const about = opts.about ? `<p class="about">${escape(opts.about)}</p>` : "";
|
|
23
|
+
const counts = opts.counts ? `<span class="wb-ui-card-counts">${opts.counts}</span>` : "";
|
|
24
|
+
const about = opts.about ? `<p class="wb-ui-card-about">${escape(opts.about)}</p>` : "";
|
|
24
25
|
if (opts.collapsible) {
|
|
25
26
|
// Only the heading and its sentence fold the card: pills that are links sit below, so a near miss can't fold it.
|
|
26
|
-
const sentence = opts.about ? `<span class="about">${escape(opts.about)}</span>` : "";
|
|
27
|
+
const sentence = opts.about ? `<span class="wb-ui-card-about">${escape(opts.about)}</span>` : "";
|
|
27
28
|
const chipId = opts.id ? ` id="${escape(opts.id)}-chip"` : "";
|
|
28
|
-
const summary = opts.summary ? `<span class="chip ${opts.summary.tone}"${chipId}>${escape(opts.summary.text)}</span>` : "";
|
|
29
|
-
return `<details class="card"${id}${opts.attention ? " data-attention" : ""} open><summary><h2>${escape(title)}</h2>${sentence}${summary}</summary>${counts}${inner}</details>`;
|
|
29
|
+
const summary = opts.summary ? `<span class="wb-ui-chip" data-tone="${opts.summary.tone}"${chipId}>${escape(opts.summary.text)}</span>` : "";
|
|
30
|
+
return `<details class="wb-ui-card"${id}${opts.attention ? " data-attention" : ""} open><summary class="wb-ui-card-head"><h2 class="wb-ui-card-title">${escape(title)}</h2>${sentence}${summary}</summary>${counts}${inner}</details>`;
|
|
30
31
|
}
|
|
31
|
-
return `<section class="card"${id}><header><h2>${escape(title)}</h2>${counts}${about}</header>${inner}</section>`;
|
|
32
|
+
return `<section class="wb-ui-card"${id}><header class="wb-ui-card-head"><h2 class="wb-ui-card-title">${escape(title)}</h2>${counts}${about}</header>${inner}</section>`;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* A row of pills that jump to the page's cards, for `topBar`'s `below`. Each
|
|
@@ -37,8 +38,8 @@ export function card(title, inner, opts = {}) {
|
|
|
37
38
|
* (a folded card's own chip, from `card`'s `summary`, is `<id>-chip`).
|
|
38
39
|
*/
|
|
39
40
|
export function jumpNav(items) {
|
|
40
|
-
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>`);
|
|
41
|
-
return `<nav class="jump" aria-label="Sections">${links.join("")}</nav>`;
|
|
41
|
+
const links = items.map((i) => `<a class="wb-ui-jump-link" href="#${escape(i.id)}">${escape(i.label)}${i.chip ? `<span class="wb-ui-chip" data-tone="${i.chip.tone}" id="jump-${escape(i.id)}-chip">${escape(i.chip.text)}</span>` : ""}</a>`);
|
|
42
|
+
return `<nav class="wb-ui-jump" aria-label="Sections">${links.join("")}</nav>`;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* Script for a page with collapsible cards and a `jumpNav`. A jump pill, or
|
|
@@ -51,14 +52,14 @@ export const SECTIONS_SCRIPT = `(() => {
|
|
|
51
52
|
const key = "wb-folded:" + location.pathname;
|
|
52
53
|
let folded = [];
|
|
53
54
|
try { folded = JSON.parse(localStorage.getItem(key) || "[]"); if (!Array.isArray(folded)) folded = []; } catch (e) {}
|
|
54
|
-
const cards = [...document.querySelectorAll("details.card[id]")];
|
|
55
|
+
const cards = [...document.querySelectorAll("details.wb-ui-card[id]")];
|
|
55
56
|
const save = () => { try { localStorage.setItem(key, JSON.stringify(folded)); } catch (e) {} };
|
|
56
57
|
// The card a #hash names, or nothing: a mangled hash must never stop the page's other scripts.
|
|
57
58
|
const named = (hash) => {
|
|
58
59
|
let id = hash.slice(1);
|
|
59
60
|
try { id = decodeURIComponent(id); } catch (e) {}
|
|
60
61
|
const el = id ? document.getElementById(id) : null;
|
|
61
|
-
return el && el.matches("details.card") ? el : null;
|
|
62
|
+
return el && el.matches("details.wb-ui-card") ? el : null;
|
|
62
63
|
};
|
|
63
64
|
// Opening a card to show it (a pill, a link) is not the reader unfolding it, so it isn't remembered.
|
|
64
65
|
const shown = new Set();
|
|
@@ -73,7 +74,7 @@ export const SECTIONS_SCRIPT = `(() => {
|
|
|
73
74
|
save();
|
|
74
75
|
});
|
|
75
76
|
addEventListener("hashchange", () => show(named(location.hash), true));
|
|
76
|
-
for (const a of document.querySelectorAll("
|
|
77
|
+
for (const a of document.querySelectorAll("a.wb-ui-jump-link")) a.addEventListener("click", () => show(named(a.hash), false));
|
|
77
78
|
})();`;
|
|
78
79
|
const utc = (d) => d.toISOString().replace(".000", "");
|
|
79
80
|
const LONG = new Intl.DateTimeFormat("en-AU", { timeZone: "Asia/Manila", dateStyle: "medium", timeStyle: "medium" });
|
|
@@ -146,19 +147,19 @@ export function duration(ms) {
|
|
|
146
147
|
}
|
|
147
148
|
/** The sticky bar on top of every page: the name, the environment tag, then links. */
|
|
148
149
|
export function topBar(opts) {
|
|
149
|
-
const name = opts.href ? `<a class="
|
|
150
|
+
const name = opts.href ? `<a class="wb-ui-name" href="${escape(opts.href)}">${escape(opts.name)}</a>` : `<span class="wb-ui-name">${escape(opts.name)}</span>`;
|
|
150
151
|
// Only "production" has its own colour; any other environment is amber.
|
|
151
|
-
const env = opts.env ? `<span class="env${opts.env
|
|
152
|
+
const env = opts.env ? `<span class="wb-ui-env" data-env="${escape(opts.env)}">${escape(opts.env)}</span>` : "";
|
|
152
153
|
const links = opts.links?.length
|
|
153
|
-
? `<nav class="links" aria-label="Pages">${opts.links.map(([label, href]) => `<a href="${escape(href)}">${escape(label)}</a>`).join("")}</nav>`
|
|
154
|
+
? `<nav class="wb-ui-links" aria-label="Pages">${opts.links.map(([label, href]) => `<a class="wb-ui-link" href="${escape(href)}">${escape(label)}</a>`).join("")}</nav>`
|
|
154
155
|
: "";
|
|
155
|
-
const below = opts.below ? `<div class="
|
|
156
|
-
return `<header class="
|
|
156
|
+
const below = opts.below ? `<div class="wb-ui-bar-below">${opts.below}</div>` : "";
|
|
157
|
+
return `<header class="wb-ui-bar"><div class="wb-ui-bar-row">${name}${env}${links}${opts.extra ?? ""}</div>${below}</header>`;
|
|
157
158
|
}
|
|
158
159
|
/** A whole page: the shared look, the top bar, the heading, then `body`. */
|
|
159
160
|
export function shell(opts) {
|
|
160
|
-
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">
|
|
161
|
+
return `<!doctype html><html lang="en-AU" class="wb-ui"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="dark">
|
|
161
162
|
<title>${escape(opts.title)} · ${escape(opts.site)}</title>${opts.stylesheets ? opts.stylesheets.map((href) => `<link rel="stylesheet" href="${escape(href)}">`).join("") : STYLE}${opts.head ?? ""}
|
|
162
163
|
${opts.top}
|
|
163
|
-
<main class="
|
|
164
|
+
<main class="wb-ui-main"><h1 class="wb-ui-title">${escape(opts.title)}</h1>${opts.body}</main>${opts.tail ?? ""}</html>`;
|
|
164
165
|
}
|
package/dist/style.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** The
|
|
1
|
+
/** The page conventions, without a <style> tag (the helpers' classes are UI_STYLES). */
|
|
2
2
|
export declare const CSS: string;
|
|
3
|
-
/**
|
|
3
|
+
/** UI_STYLES as plain rules: the variables on :root, then each class and its states. */
|
|
4
|
+
export declare const UI_CSS: string;
|
|
5
|
+
/** The whole look as a <style> tag: the page conventions, then the helpers' classes, which win. */
|
|
4
6
|
export declare const STYLE: string;
|
package/dist/style.js
CHANGED
|
@@ -1,162 +1,113 @@
|
|
|
1
|
-
// The one stylesheet for every Workbench page. Colours are
|
|
2
|
-
// page is dark whatever the computer is set to (docs/spec.md §10, 11
|
|
3
|
-
// 2026).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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}
|
|
1
|
+
// The one stylesheet for every Workbench page. Colours are --wb-ui-* variables,
|
|
2
|
+
// and every page is dark whatever the computer is set to (docs/spec.md §10, 11
|
|
3
|
+
// November 2026). What the helpers draw (shell, topBar, card, pill, chip,
|
|
4
|
+
// jumpNav) is UI_STYLES (ui-styles.ts); CSS holds the page conventions for
|
|
5
|
+
// markup a page writes itself (tables, buttons, notes, inputs). A page adds its
|
|
6
|
+
// own rules after these, never a second copy of them.
|
|
7
|
+
import { UI_STYLES } from "./ui-styles.js";
|
|
8
|
+
/** The page conventions, without a <style> tag (the helpers' classes are UI_STYLES). */
|
|
9
|
+
export const CSS = `*{box-sizing:border-box}
|
|
10
|
+
body{margin:0}
|
|
11
|
+
.wb-ui-main>p:not(.note):not(.warn){max-width:60rem}
|
|
27
12
|
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)}
|
|
13
|
+
a{color:var(--wb-ui-accent)}a:hover{color:var(--wb-ui-accent-hover)}
|
|
14
|
+
code{font:.85em/1.4 var(--wb-ui-mono)}
|
|
30
15
|
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)}
|
|
16
|
+
pre{font:.85rem/1.5 var(--wb-ui-mono);white-space:pre-wrap;overflow-wrap:anywhere;padding:.75rem 1rem;margin:.75rem 0;
|
|
17
|
+
background:var(--wb-ui-surface);border:1px solid var(--wb-ui-line);border-radius:8px;max-height:28rem;overflow:auto}
|
|
18
|
+
button{font:inherit;font-size:.9rem;font-weight:600;padding:.5rem 1.1rem;border:1px solid var(--wb-ui-accent);border-radius:6px;background:var(--wb-ui-accent);
|
|
19
|
+
color:var(--wb-ui-accent-text);cursor:pointer;line-height:1.2;white-space:nowrap}
|
|
20
|
+
button:hover{background:var(--wb-ui-accent-hover);border-color:var(--wb-ui-accent-hover)}
|
|
21
|
+
button[value=reject],button[value=deny]{background:transparent;color:var(--wb-ui-text);border-color:var(--wb-ui-line)}
|
|
22
|
+
button[value=reject]:hover,button[value=deny]:hover{background:var(--wb-ui-raised);border-color:var(--wb-ui-muted)}
|
|
38
23
|
button:disabled{opacity:.45;cursor:not-allowed}
|
|
39
24
|
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;
|
|
25
|
+
input:not([type=hidden]){font:inherit;color:var(--wb-ui-text);background:var(--wb-ui-surface);border:1px solid var(--wb-ui-line);border-radius:6px;
|
|
41
26
|
padding:.45rem .6rem;line-height:1.2}
|
|
42
27
|
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)}
|
|
28
|
+
button:focus-visible,input:focus-visible,a:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wb-ui-focus)}
|
|
29
|
+
.warn{padding:.6rem .9rem;border-left:3px solid var(--wb-ui-warn);background:var(--wb-ui-surface);border-radius:0 6px 6px 0}
|
|
30
|
+
.note{padding:.6rem .9rem;border-left:3px solid var(--wb-ui-line);background:var(--wb-ui-surface);border-radius:0 6px 6px 0}
|
|
31
|
+
.note.good{border-left-color:var(--wb-ui-pass)}.note.bad{border-left-color:var(--wb-ui-fail);color:var(--wb-ui-text)}
|
|
32
|
+
.muted{color:var(--wb-ui-muted);font-size:.875rem}
|
|
33
|
+
.ok{color:var(--wb-ui-ok)}.bad{color:var(--wb-ui-bad)}
|
|
49
34
|
.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)}
|
|
35
|
+
.quick button.link{font:inherit;padding:0;border:0;border-radius:0;background:none;color:var(--wb-ui-accent);text-decoration:underline;cursor:pointer}
|
|
36
|
+
.quick button.link:hover{background:none;color:var(--wb-ui-accent-hover)}
|
|
52
37
|
.actions{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem;margin:1rem 0}.actions form{margin:0}
|
|
53
38
|
.actions label{display:flex;align-items:center;gap:.5rem}
|
|
54
|
-
.card{
|
|
55
|
-
.card
|
|
56
|
-
.card
|
|
57
|
-
.card>
|
|
58
|
-
.card
|
|
59
|
-
.card
|
|
60
|
-
|
|
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)}
|
|
39
|
+
.wb-ui-card .body{padding:.85rem 1.1rem}
|
|
40
|
+
.wb-ui-card .body>:first-child{margin-top:0}.wb-ui-card .body>:last-child{margin-bottom:0}
|
|
41
|
+
.wb-ui-card>.body+.scroll,.wb-ui-card>div+.body{border-top:1px solid var(--wb-ui-line)}
|
|
42
|
+
.wb-ui-card>pre{margin:0;border:0;border-radius:0;background:transparent;max-height:none}
|
|
43
|
+
.wb-ui-card .scroll{margin:0;border:0;border-radius:0}
|
|
44
|
+
.wb-ui-card .body>p.bad,.wb-ui-card .body>p:only-child{margin:0}
|
|
45
|
+
.scroll{overflow-x:auto;margin:.75rem 0;border:1px solid var(--wb-ui-line);border-radius:8px;background:var(--wb-ui-surface)}
|
|
86
46
|
table{border-collapse:collapse;width:100%}
|
|
87
47
|
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}
|
|
48
|
+
thead th{font-size:.72rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--wb-ui-muted);background:var(--wb-ui-raised);
|
|
49
|
+
border-bottom:1px solid var(--wb-ui-line);white-space:nowrap}
|
|
50
|
+
tbody tr+tr td,tbody tr+tr th{border-top:1px solid var(--wb-ui-line)}
|
|
51
|
+
tbody tr:hover td,tbody tr:hover th{background:var(--wb-ui-raised)}
|
|
52
|
+
table.kv th{width:12rem;font-weight:600;white-space:nowrap;color:var(--wb-ui-muted);font-size:.875rem}
|
|
93
53
|
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
|
|
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
|
-
|
|
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)}
|
|
54
|
+
td small{display:block;color:var(--wb-ui-muted);margin-top:.15rem}
|
|
55
|
+
tbody tr td:first-child,tbody tr th:first-child{box-shadow:inset 3px 0 0 var(--wb-ui-edge)}
|
|
56
|
+
tr.o-pass{--wb-ui-edge:var(--wb-ui-pass)}tr.o-refused{--wb-ui-edge:var(--wb-ui-refused)}tr.o-fail{--wb-ui-edge:var(--wb-ui-fail)}tr.o-skip{--wb-ui-edge:var(--wb-ui-skip)}tr.o-run{--wb-ui-edge:var(--wb-ui-run)}
|
|
57
|
+
tr.o-fail td{background:var(--wb-ui-fail-bg)}
|
|
58
|
+
@keyframes wb-ui-spin{to{transform:rotate(360deg)}}
|
|
113
59
|
td.outcome{min-width:22rem}
|
|
114
60
|
td.outcome p{margin:.3rem 0 0;font-size:.875rem;overflow-wrap:anywhere}
|
|
115
|
-
td.outcome p.means{color:var(--muted)}
|
|
61
|
+
td.outcome p.means{color:var(--wb-ui-muted)}
|
|
116
62
|
td.outcome code{white-space:normal;overflow-wrap:anywhere}
|
|
117
63
|
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(--
|
|
120
|
-
dl.facts dt{color:var(--muted);font-size:.8rem}
|
|
64
|
+
details.asked summary{cursor:pointer;color:var(--wb-ui-accent);width:max-content}
|
|
65
|
+
dl.facts{display:grid;grid-template-columns:9rem 1fr;gap:.3rem 1rem;margin:.4rem 0 0;padding:.6rem .75rem;background:var(--wb-ui-background);border:1px solid var(--wb-ui-line);border-radius:8px}
|
|
66
|
+
dl.facts dt{color:var(--wb-ui-muted);font-size:.8rem}
|
|
121
67
|
dl.facts dd{margin:0;overflow-wrap:anywhere}
|
|
122
68
|
dl.facts ul{margin:0;padding-left:1.1rem}
|
|
123
69
|
.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)}
|
|
70
|
+
.filters a.wb-ui-pill{text-decoration:none;cursor:pointer}
|
|
71
|
+
.filters a.wb-ui-pill:hover{box-shadow:0 0 0 2px var(--wb-ui-line)}
|
|
72
|
+
.filters a.wb-ui-pill[aria-current]{box-shadow:0 0 0 2px currentColor}
|
|
73
|
+
.filters.on a.wb-ui-pill:not([aria-current]){opacity:.45}
|
|
74
|
+
.filters.on a.wb-ui-pill:not([aria-current]):hover{opacity:.8}
|
|
75
|
+
.filter-note{font-size:.875rem;color:var(--wb-ui-muted)}
|
|
130
76
|
.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}
|
|
77
|
+
.pager a,.pager strong{display:inline-block;min-width:2.1rem;text-align:center;padding:.3rem .6rem;border:1px solid var(--wb-ui-line);
|
|
78
|
+
border-radius:6px;text-decoration:none;background:var(--wb-ui-surface)}
|
|
79
|
+
.pager strong{background:var(--wb-ui-accent);border-color:var(--wb-ui-accent);color:var(--wb-ui-accent-text)}
|
|
80
|
+
.pager .gap{color:var(--wb-ui-muted);padding:0 .2rem}
|
|
135
81
|
.pager.end{justify-content:flex-end}
|
|
136
82
|
.split{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem 1.5rem;margin:0 0 .75rem}
|
|
137
83
|
.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)}
|
|
84
|
+
footer.page{color:var(--wb-ui-muted);font-size:.8rem;margin-top:1.5rem}
|
|
85
|
+
.tech{font:.78rem/1.4 var(--wb-ui-mono);color:var(--wb-ui-muted)}
|
|
140
86
|
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}
|
|
87
|
+
details.more summary{cursor:pointer;color:var(--wb-ui-accent);width:max-content;max-width:100%;font-size:.875rem}
|
|
88
|
+
.lbl{font-size:.7rem;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--wb-ui-muted);margin:1rem 0 .3rem}
|
|
143
89
|
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}
|
|
90
|
+
dl.plain dt{color:var(--wb-ui-muted);font-size:.875rem;font-weight:600}
|
|
145
91
|
dl.plain dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
|
146
92
|
dl.plain dd>pre{margin:0;max-height:none}
|
|
147
93
|
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(--
|
|
94
|
+
dl.plain dl.plain{grid-template-columns:1fr;gap:.1rem;margin:0;padding:.5rem .75rem;border:1px solid var(--wb-ui-line);border-radius:8px;background:var(--wb-ui-background)}
|
|
149
95
|
dl.plain dl.plain>dd{margin-bottom:.5rem}dl.plain dl.plain>dd:last-child{margin-bottom:0}
|
|
150
96
|
.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)}
|
|
97
|
+
.bool{font-size:.8rem;font-weight:600;padding:0 .4rem;border:1px solid var(--wb-ui-line);border-radius:4px;background:var(--wb-ui-raised)}
|
|
152
98
|
@media (max-width:640px){dl.plain{grid-template-columns:1fr;gap:.1rem}dl.plain dd{margin-bottom:.5rem}}
|
|
153
99
|
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
|
|
154
|
-
textarea,select{font:inherit;color:var(--text);background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:.45rem .6rem;min-height:2.75rem}
|
|
100
|
+
textarea,select{font:inherit;color:var(--wb-ui-text);background:var(--wb-ui-surface);border:1px solid var(--wb-ui-line);border-radius:6px;padding:.45rem .6rem;min-height:2.75rem}
|
|
155
101
|
textarea{width:100%;min-height:6rem;max-height:20rem;field-sizing:content;resize:vertical}
|
|
156
|
-
textarea:focus-visible,select:focus-visible{outline:none;box-shadow:0 0 0 3px var(--focus)}
|
|
102
|
+
textarea:focus-visible,select:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wb-ui-focus)}
|
|
157
103
|
input:not([type=hidden]):not([type=checkbox]):not([type=radio]){min-height:2.75rem}
|
|
158
|
-
[aria-invalid=true]{border-color:var(--fail)}
|
|
159
|
-
@media (max-width:640px){
|
|
104
|
+
[aria-invalid=true]{border-color:var(--wb-ui-fail)}
|
|
105
|
+
@media (max-width:640px){th,td{padding:.55rem .7rem}table.kv th{width:auto}}
|
|
160
106
|
`;
|
|
161
|
-
/**
|
|
162
|
-
export const
|
|
107
|
+
/** UI_STYLES as plain rules: the variables on :root, then each class and its states. */
|
|
108
|
+
export const UI_CSS = [
|
|
109
|
+
`:root{${UI_STYLES.variables.map((x) => `${x.name}:${x.value}`).join(";")}}`,
|
|
110
|
+
...UI_STYLES.classes.flatMap((c) => [`.${c.name}{${c.css}}`, ...(c.states ?? []).map((st) => `.${c.name}${st.selector}{${st.css}}`)]),
|
|
111
|
+
].join("\n");
|
|
112
|
+
/** The whole look as a <style> tag: the page conventions, then the helpers' classes, which win. */
|
|
113
|
+
export const STYLE = `<style>\n${CSS}${UI_CSS}\n</style>`;
|
package/dist/styles.js
CHANGED
|
@@ -106,7 +106,7 @@ export function renderStyles(tools, uiVersion) {
|
|
|
106
106
|
...HEADER,
|
|
107
107
|
"@layer workbench.page, workbench.tools;",
|
|
108
108
|
"",
|
|
109
|
-
comment(`
|
|
109
|
+
comment(`Page conventions: @mccaskie-labs/workbench-ui ${uiVersion}, for markup a page writes itself (tables, buttons, notes, inputs). What its helpers draw is wb-ui- below.`),
|
|
110
110
|
"@layer workbench.page {",
|
|
111
111
|
page,
|
|
112
112
|
"}",
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The look of what workbench-ui's helpers draw: shell, topBar, card, pill,
|
|
2
|
+
// chip and jumpNav (docs/capabilities-manifest.md §10). Every element they put
|
|
3
|
+
// on a page carries one of these classes with a default rule, and the colours
|
|
4
|
+
// and sizes are `--wb-ui-*` variables, so a project restyles a Workbench page
|
|
5
|
+
// in its own public/styles/project.css. The names are public: renaming one is
|
|
6
|
+
// a breaking change. The page conventions for markup a page writes itself
|
|
7
|
+
// (tables, buttons, notes) stay in CSS (style.ts) and read the same variables.
|
|
8
|
+
const v = (name) => `var(--wb-ui-${name})`;
|
|
9
|
+
const TONES = ["pass", "refused", "fail", "skip", "running"];
|
|
10
|
+
const RUN = (t) => (t === "running" ? "run" : t);
|
|
11
|
+
/** The style hooks of a Workbench page. */
|
|
12
|
+
export const UI_STYLES = {
|
|
13
|
+
format: 1,
|
|
14
|
+
tool: "ui",
|
|
15
|
+
package: "@mccaskie-labs/workbench-ui",
|
|
16
|
+
title: "Workbench pages",
|
|
17
|
+
prefix: "wb-ui-",
|
|
18
|
+
variables: [
|
|
19
|
+
{ name: "--wb-ui-background", value: "#121214", about: "Behind the page" },
|
|
20
|
+
{ name: "--wb-ui-surface", value: "#1b1b1f", about: "Cards, inputs and code blocks" },
|
|
21
|
+
{ name: "--wb-ui-raised", value: "#25252b", about: "Table heads, chips and a row under the pointer" },
|
|
22
|
+
{ name: "--wb-ui-text", value: "#e8e8ec", about: "Body text" },
|
|
23
|
+
{ name: "--wb-ui-muted", value: "#9a9aa6", about: "Quieter text: a card's sentence, labels, small print" },
|
|
24
|
+
{ name: "--wb-ui-line", value: "#33333b", about: "Borders and rules" },
|
|
25
|
+
{ name: "--wb-ui-bar", value: "rgba(18,18,20,.92)", about: "The top bar, over the page as it scrolls" },
|
|
26
|
+
{ name: "--wb-ui-accent", value: "#4c8dff", about: "Links, buttons and the current page" },
|
|
27
|
+
{ name: "--wb-ui-accent-hover", value: "#6aa1ff", about: "A link or button under the pointer" },
|
|
28
|
+
{ name: "--wb-ui-accent-text", value: "#0b0b0d", about: "Text on a filled button" },
|
|
29
|
+
{ name: "--wb-ui-ok", value: "#5cc87a", about: "Words that say something worked" },
|
|
30
|
+
{ name: "--wb-ui-bad", value: "#ff6b66", about: "Words that say something failed, and the production tag" },
|
|
31
|
+
{ name: "--wb-ui-warn", value: "#f0a43a", about: "Warnings, and the tag of any environment but production" },
|
|
32
|
+
{ name: "--wb-ui-focus", value: "rgba(76,141,255,.4)", about: "The ring around whatever has the keyboard" },
|
|
33
|
+
{ name: "--wb-ui-pass", value: "#5cc87a", about: "A pill or chip that passed" },
|
|
34
|
+
{ name: "--wb-ui-refused", value: "#b48cff", about: "A pill or chip for a call that was refused" },
|
|
35
|
+
{ name: "--wb-ui-fail", value: "#ff6b66", about: "A pill or chip that failed, and a field with a problem" },
|
|
36
|
+
{ name: "--wb-ui-skip", value: "#f0a43a", about: "A pill or chip that was skipped or waits" },
|
|
37
|
+
{ name: "--wb-ui-run", value: "#4c8dff", about: "A pill or chip still running" },
|
|
38
|
+
{ name: "--wb-ui-pass-bg", value: "rgba(92,200,122,.1)", about: "Behind a passed pill" },
|
|
39
|
+
{ name: "--wb-ui-refused-bg", value: "rgba(180,140,255,.1)", about: "Behind a refused pill" },
|
|
40
|
+
{ name: "--wb-ui-fail-bg", value: "rgba(255,107,102,.12)", about: "Behind a failed pill, and a failed table row" },
|
|
41
|
+
{ name: "--wb-ui-skip-bg", value: "rgba(240,164,58,.1)", about: "Behind a skipped pill" },
|
|
42
|
+
{ name: "--wb-ui-run-bg", value: "rgba(76,141,255,.12)", about: "Behind a running pill" },
|
|
43
|
+
{ name: "--wb-ui-edge", value: "transparent", about: "The coloured edge on a table row's first cell (set per row by o-pass, o-fail and the rest)" },
|
|
44
|
+
{ name: "--wb-ui-font", value: 'system-ui,-apple-system,"Segoe UI",sans-serif', about: "The page's font" },
|
|
45
|
+
{ name: "--wb-ui-mono", value: 'ui-monospace,"Cascadia Code",Consolas,monospace', about: "Code's font" },
|
|
46
|
+
{ name: "--wb-ui-width", value: "max(64rem,80vw)", about: "Widest the page's column grows" },
|
|
47
|
+
],
|
|
48
|
+
classes: [
|
|
49
|
+
{ name: "wb-ui", element: "html", about: "The whole page: dark whatever the computer is set to", css: `color-scheme:dark;background:${v("background")};color:${v("text")};font:15px/1.55 ${v("font")}` },
|
|
50
|
+
{ name: "wb-ui-main", element: "main", about: "The page's column under the top bar", css: `display:block;max-width:${v("width")};margin:0 auto;padding:1.75rem 1rem 3rem` },
|
|
51
|
+
{ name: "wb-ui-title", element: "h1", about: "The page's heading", css: "font-size:1.6rem;line-height:1.2;margin:0 0 .6rem" },
|
|
52
|
+
{ name: "wb-ui-bar", element: "header", about: "The bar that stays on top of the page", css: `position:sticky;top:0;z-index:10;background:${v("bar")};backdrop-filter:blur(8px);border-bottom:1px solid ${v("line")}` },
|
|
53
|
+
{ name: "wb-ui-bar-row", element: "div", about: "The bar's row: the name, the environment tag and the links", css: `display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1rem;max-width:${v("width")};margin:0 auto;padding:.75rem 1rem` },
|
|
54
|
+
{ name: "wb-ui-bar-below", element: "div", about: "A second row in the bar, such as the jump pills", css: `max-width:${v("width")};margin:0 auto;padding:0 1rem .6rem` },
|
|
55
|
+
{
|
|
56
|
+
name: "wb-ui-name",
|
|
57
|
+
element: "a or span",
|
|
58
|
+
about: "The site's name in the bar",
|
|
59
|
+
css: `font-size:1.15rem;font-weight:700;line-height:1.2;color:${v("text")};text-decoration:none`,
|
|
60
|
+
states: [{ selector: ":hover", about: "The name's link under the pointer", css: `color:${v("text")}` }],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "wb-ui-env",
|
|
64
|
+
element: "span",
|
|
65
|
+
about: "The environment tag after the name",
|
|
66
|
+
css: `font-size:.7rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:.2rem .55rem;border-radius:999px;border:1px solid ${v("warn")};color:${v("warn")};white-space:nowrap`,
|
|
67
|
+
states: [{ selector: "[data-env=production]", about: "The production tag", css: `border-color:${v("bad")};color:${v("bad")}` }],
|
|
68
|
+
},
|
|
69
|
+
{ name: "wb-ui-links", element: "nav", about: "The bar's links, on the right", css: "display:flex;flex-wrap:wrap;gap:.4rem;margin-left:auto" },
|
|
70
|
+
{
|
|
71
|
+
name: "wb-ui-link",
|
|
72
|
+
element: "a",
|
|
73
|
+
about: "One of the bar's links",
|
|
74
|
+
css: `font-size:.85rem;text-decoration:none;color:${v("text")};padding:.25rem .75rem;border:1px solid ${v("line")};border-radius:999px;background:${v("surface")}`,
|
|
75
|
+
states: [{ selector: ":hover", about: "Under the pointer", css: `border-color:${v("accent")};color:${v("accent-hover")}` }],
|
|
76
|
+
},
|
|
77
|
+
{ name: "wb-ui-jump", element: "nav", about: "The pills that jump to the page's cards", css: "display:flex;gap:.4rem;overflow-x:auto;white-space:nowrap" },
|
|
78
|
+
{
|
|
79
|
+
name: "wb-ui-jump-link",
|
|
80
|
+
element: "a",
|
|
81
|
+
about: "One jump pill",
|
|
82
|
+
css: `display:inline-flex;align-items:center;gap:.45rem;font-size:.85rem;text-decoration:none;color:${v("text")};padding:.25rem .5rem .25rem .75rem;border:1px solid ${v("line")};border-radius:999px;background:${v("surface")}`,
|
|
83
|
+
states: [{ selector: ":hover", about: "Under the pointer", css: `border-color:${v("accent")};color:${v("accent-hover")}` }],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "wb-ui-card",
|
|
87
|
+
element: "section or details",
|
|
88
|
+
about: "A card: a heading bar over its contents (a details element when it folds)",
|
|
89
|
+
css: `background:${v("surface")};border:1px solid ${v("line")};border-radius:10px;margin:0 0 1.5rem;overflow:hidden;scroll-margin-top:8rem`,
|
|
90
|
+
states: [{ selector: ":target", about: "The card the address points at", css: `border-color:${v("accent")}` }],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "wb-ui-card-head",
|
|
94
|
+
element: "header or summary",
|
|
95
|
+
about: "A card's heading bar (the summary of a card that folds)",
|
|
96
|
+
css: `display:flex;flex-wrap:wrap;align-items:center;gap:.5rem 1rem;padding:.85rem 1.1rem;border-bottom:1px solid ${v("line")}`,
|
|
97
|
+
states: [
|
|
98
|
+
{ selector: ":where(details:not([open])>*)", about: "A folded card's heading bar", css: "border-bottom:0" },
|
|
99
|
+
{ selector: ":where(summary)", about: "A heading bar that folds its card", css: "cursor:pointer;list-style:none" },
|
|
100
|
+
{ selector: ":where(summary)::-webkit-details-marker", about: "Safari's own triangle, hidden", css: "display:none" },
|
|
101
|
+
{ selector: ":where(summary):hover", about: "A folding heading bar under the pointer", css: `background:${v("raised")}` },
|
|
102
|
+
{ selector: ":where(summary):focus-visible", about: "A folding heading bar with the keyboard", css: `outline:none;box-shadow:inset 0 0 0 3px ${v("focus")}` },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "wb-ui-card-title",
|
|
107
|
+
element: "h2",
|
|
108
|
+
about: "A card's heading",
|
|
109
|
+
css: "font-size:1.05rem;margin:0",
|
|
110
|
+
states: [
|
|
111
|
+
{ selector: ":where(summary>*)", about: "The heading of a card that folds, after its arrow", css: "display:flex;align-items:center;gap:.5rem" },
|
|
112
|
+
{
|
|
113
|
+
selector: ":where(summary>*)::before",
|
|
114
|
+
about: "The arrow: right when folded",
|
|
115
|
+
css: `content:"";width:.5rem;height:.5rem;border-right:2px solid ${v("muted")};border-bottom:2px solid ${v("muted")};transform:rotate(-45deg);transition:transform .15s;flex:none`,
|
|
116
|
+
},
|
|
117
|
+
{ selector: ":where(details[open]>summary>*)::before", about: "The arrow: down when open", css: "transform:rotate(45deg)" },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "wb-ui-card-about",
|
|
122
|
+
element: "p or span",
|
|
123
|
+
about: "The sentence under a card's heading on what it shows",
|
|
124
|
+
css: `margin:0;flex-basis:100%;color:${v("muted")};font-size:.875rem`,
|
|
125
|
+
states: [{ selector: ":where(details:not([open]) *)", about: "Hidden while its card is folded", css: "display:none" }],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "wb-ui-card-counts",
|
|
129
|
+
element: "span",
|
|
130
|
+
about: "The pills beside a card's heading (under it, in a card that folds)",
|
|
131
|
+
css: "display:flex;flex-wrap:wrap;gap:.35rem",
|
|
132
|
+
states: [{ selector: ":where(details>*)", about: "Under a folding card's heading", css: `padding:.7rem 1.1rem;border-bottom:1px solid ${v("line")}` }],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "wb-ui-pill",
|
|
136
|
+
element: "span or a",
|
|
137
|
+
about: "An outcome pill; its data-tone is pass, refused, fail, skip, running or none",
|
|
138
|
+
css: "display:inline-block;font-size:.75rem;font-weight:600;line-height:1.3;padding:.15rem .6rem;border-radius:999px;border:1px solid currentColor;white-space:nowrap;vertical-align:.05em",
|
|
139
|
+
states: [
|
|
140
|
+
...TONES.map((t) => ({ selector: `[data-tone=${t}]`, about: `A ${t} pill`, css: `color:${v(RUN(t))};background:${v(`${RUN(t)}-bg`)}` })),
|
|
141
|
+
{ selector: "[data-tone=none]", about: "A pill with nothing to report", css: `color:${v("muted")};border-color:${v("line")}` },
|
|
142
|
+
{
|
|
143
|
+
selector: "[data-tone=running]::before",
|
|
144
|
+
about: "The spinner in a running pill",
|
|
145
|
+
css: `content:"";display:inline-block;width:.6em;height:.6em;margin-right:.4em;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;vertical-align:-.05em;animation:wb-ui-spin .8s linear infinite`,
|
|
146
|
+
},
|
|
147
|
+
{ selector: "[title]", about: "A pill that explains itself on hover", css: "cursor:help" },
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "wb-ui-chip",
|
|
152
|
+
element: "span",
|
|
153
|
+
about: "A small square tag after a pill or in a jump pill: whether anything needs doing; same tones as a pill",
|
|
154
|
+
css: `display:inline-block;font-size:.68rem;font-weight:600;line-height:1.3;padding:.05rem .45rem;border-radius:4px;border:1px solid ${v("line")};background:${v("raised")};white-space:nowrap;vertical-align:.1em`,
|
|
155
|
+
states: [
|
|
156
|
+
...TONES.map((t) => ({ selector: `[data-tone=${t}]`, about: `A ${t} chip`, css: `color:${v(RUN(t))}` })),
|
|
157
|
+
{ selector: "[data-tone=none]", about: "A chip with nothing to report", css: `color:${v("muted")}` },
|
|
158
|
+
{ selector: ":where(.wb-ui-jump-link>*)", about: "In a jump pill", css: "vertical-align:0" },
|
|
159
|
+
{ selector: ":where(.wb-ui-card-head>*)", about: "Beside a folded card's heading", css: "font-size:.75rem" },
|
|
160
|
+
{ selector: ":where(details[open]>.wb-ui-card-head>*)", about: "Hidden while its card is open", css: "display:none" },
|
|
161
|
+
{ selector: "[data-tone=pass]:where(.wb-ui-jump-link>*, .wb-ui-card-head>*)::before", about: "A tick before a passed chip in a jump pill or a folded heading", css: 'content:"\\2713\\00a0"' },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
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
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./styles": {
|
|
22
|
+
"types": "./dist/ui-styles.d.ts",
|
|
23
|
+
"default": "./dist/ui-styles.js"
|
|
24
|
+
},
|
|
21
25
|
"./package.json": "./package.json"
|
|
22
26
|
},
|
|
23
27
|
"bin": {
|