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

A fantastic component library: a living gallery, the missing parts (search picker first), a drift gate, and a cold-read UI audit #16926

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/5817-a-fantastic-component-library-a-living-g → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/5817-a-fantastic-component-library-a-living-g was merged into main as 5371f5e.

Review

Sign in to review this change.
5 files changed +37 −3
docs/design/sections/5-components.md +4
@@ -42,6 +42,10 @@ specification.
4242 | **tooltip** | `[data-tip]` | `data-tip-side=bottom` | hover/focus; hidden on coarse pointers | a status-bar hint |
4343 | **toast / flash** `toast()` | `.toast` | `data-tone=success\|danger\|attn` | one per page load, cookie-driven | a one-line banner |
4444 | **skeleton** `skeleton()` | `.skeleton` (a `.card`), `.skeleton-bar` | `shape=list\|card` | real `.list` rows or a real `.card` holding grey bars, so the swap shifts nothing; `role="status"`, `aria-busy`, "Loading…" for a screen reader; bars hold still under reduced motion | the same card, no pulse |
45 | **inline field error** `field({ error })` | `.field .error` | `[aria-invalid]` | the message sits under the control and is wired by `aria-describedby`; long text wraps | a red line under the value |
46 | **copy button** `copyField()` | `.btn.btn-icon` beside a read-only field | `copy=<id>` | script-only; without script the field stays selectable | the value to select |
47 | **confirm action** `confirmAction()` | `.btn[data-variant=danger]` | `size=sm` | a link to a confirm page, a dialog with script | a `y/n` line |
48 | **search picker** `pickList()` | `.pick` (`.pick-bar`, `.pick-chip`, `.pick-list`) | `data-pick-plain`, `data-invalid` | plain checkboxes without script; filter, chips and count with it; holds 200 items in a box that scrolls | a filtered list, one key to tick |
4549 | **command palette** | `.palette` | — | JS only; degrades to `/search` | a fuzzy-find overlay |
4650 | **page head** `pageHead()` (`chrome.ts`) | `.page-head` (`h1`, `.page-head-sub`; a `.spacer` before the actions) | `lead` before the title, `actions` right-aligned, `sub` on its own line below | wraps; the title's `min-width: 0` lets a long one shrink beside the actions | the title line, actions right, a dim subtitle under it |
4751 | **breadcrumb** `crumbs()` | `.crumbs` | `.mono` | `aria-current` on the last | `a / b / c` |
src/web/pages/design-components.ts +13 −2
@@ -15,14 +15,21 @@ import type { Ctx } from "../../http/context.ts";
1515 import { Html, html, raw } from "../html.ts";
1616 import { pageHead } from "../chrome.ts";
1717 import { page } from "../layout.ts";
18 import { pickList } from "../pick.ts";
1819 import {
19 labelCss, avatar, badge, btn, card, counts, crumbs, disclosure, dot, empty, field, iconBtn, kbd, labelChip,
20 copyField, confirmAction, labelCss, avatar, badge, btn, card, counts, crumbs, disclosure, dot, empty, field, iconBtn, kbd, labelChip,
2021 listCard, menu, meter, nameMark, pager, pill, row, seg, sha, stat, stateBadge, tabs, tlComment,
2122 tlEvent, dialogParts, skeleton, toast, userTag, verdictBadge, runStateBadge, envStateBadge,
2223 } from "../ui.ts";
2324
2425 const r = (markup: string): Html => raw(markup);
2526
27 /** 200 options, every seventh with a long name: the states the picker must hold. */
28 const PICK_ITEMS = Array.from({ length: 200 }, (_, i) => ({
29 value: `a${i + 1}`,
30 label: i % 7 === 0 ? `app-${i + 1}-with-a-name-long-enough-to-wrap-on-a-phone-and-still-read` : `app-${i + 1}`,
31 }));
32
2633 const sampleRows = [
2734 row({ href: "#", title: "Make the feed answer in under 50 ms", meta: html`#41 · opened by <b>scout</b>`, state: "open" }),
2835 row({ href: "#", title: "Escape every output", meta: html`#38 · merged`, state: "merged" }),
@@ -55,7 +62,11 @@ export const samples: readonly (readonly [name: string, sample: Html])[] = [
5562 ["colour field", html`<label class="color-field"><input type="color" value="${THEMES.light.tokens.accent}" aria-label="Colour" /> <span>accent</span></label>`],
5663 ["table", r(`<table class="table"><thead><tr><th>Name</th><th>State</th></tr></thead><tbody><tr><td>feed</td><td>live</td></tr><tr><td>map</td><td>live</td></tr></tbody></table>`)],
5764 ["tabs", tabs([{ label: "Issues", href: "#", count: 4, current: true }, { label: "Pulls", href: "#", current: false }], "Gallery tabs")],
58 ["segmented control", seg([{ label: "Open", href: "#", current: true }, { label: "Closed", href: "#", current: false }])],
65 ["segmented control", html`<div class="gallery-col">${seg([{ label: "Open", href: "#", current: true }, { label: "Closed", href: "#", current: false }, { label: "Closed, merged and everything else that has ever happened here", href: "#", current: false }])}${seg([{ label: "Only", href: "#", current: true }])}</div>`],
66 ["inline field error", html`<div class="gallery-col">${field({ label: "Name", name: "gallery-bad", value: "Not Valid!", error: "Lowercase letters and dashes only." })}${field({ label: "Address", name: "gallery-long", value: "x", error: "That address is not one we can reach: ".repeat(4) })}</div>`],
67 ["copy button", html`<div class="gallery-col">${copyField("gallery-copy", "https://forge.example/sample", "Link", "Copy the link")}${copyField("gallery-copy-long", "https://forge.example/".concat("a-very-long-path/".repeat(8)), "Long link", "Copy the link")}</div>`],
68 ["confirm action", html`<div class="gallery-line">${confirmAction({ action: "/admin/invites/sample/revoke", verb: "Delete" })}${confirmAction({ action: "/admin/invites/sample/revoke", verb: "Remove", size: "sm", label: "Remove the gallery sample" })}</div>`],

The confirm samples target /admin/invites/sample/revoke, a real route for an invite that does not exist. Prefer a target the confirm page labels as a sample so nobody sees a live-looking Delete for nothing.

69 ["search picker", html`<div class="gallery-col">${pickList({ legend: "Few", name: "gallery-few", items: PICK_ITEMS.slice(0, 3), chosen: ["a1"], noun: "apps", plainUpTo: 5 })}${pickList({ legend: "None to pick", name: "gallery-none", items: [], chosen: [], noun: "apps" })}${pickList({ legend: "Long names, 200 items, one picked", name: "gallery-many", items: PICK_ITEMS, chosen: ["a7"], noun: "apps" })}${pickList({ legend: "With an error", name: "gallery-err", items: PICK_ITEMS.slice(0, 8), chosen: [], noun: "apps", error: "Pick at least one app." })}</div>`],
5970 ["menu", menu({ trigger: "Actions", items: [{ label: "Rename", href: "#" }, { label: "Archive", href: "#" }] })],
6071 ["disclosure", disclosure("More detail", html`<p>Hidden until opened.</p>`)],
6172 ["dialog", html`<div class="dialog gallery-static" role="dialog" aria-label="Sample dialog">${dialogParts({ titleId: "gallery-dialog-title", title: "Delete this?", body: html`<p>It cannot be undone.</p>`, foot: html`<button class="btn" type="button">Cancel</button>${btn("Delete", { variant: "danger" })}` })}</div>`],

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs