From 9a17c513cbb6d7c5b08ec1df4ae0902d3fb1f20d Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 18:23:51 -0500 Subject: [PATCH 01/17] components-settings: marathon 0.23.0 and mise-action v5.3.0 - marathon 0.22.0 -> 0.23.0; .claude/marathon.toml takes the new [remote] checks key ("gh pr checks --watch"), and merge drops its own checks wait. - jdx/mise-action v5.2.10 -> v5.3.0 in ci.yml and release.yml, keeping the repository's tag pin form. - The web-foundation v0.3.0 hold stays; the next slice ends it. --- .claude/marathon.toml | 3 ++- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- mise.toml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.claude/marathon.toml b/.claude/marathon.toml index f776fa4..2157ba8 100644 --- a/.claude/marathon.toml +++ b/.claude/marathon.toml @@ -6,7 +6,8 @@ currency = "mise run currency" [remote] platform = "github" publish = "gh pr create" -merge = "gh pr checks --watch && gh pr merge --merge --delete-branch" +checks = "gh pr checks --watch" +merge = "gh pr merge --merge --delete-branch" ci = ''' sha=$(git rev-parse HEAD) for _ in $(seq 30); do diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aea5dee..bdb91fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v7.0.1 - - uses: jdx/mise-action@v5.2.10 + - uses: jdx/mise-action@v5.3.0 - name: mise run install run: mise run install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15c8c53..d93605e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: exit 1 fi - - uses: jdx/mise-action@v5.2.10 + - uses: jdx/mise-action@v5.3.0 - name: mise run install run: mise run install diff --git a/mise.toml b/mise.toml index 4b780c5..25e5ffc 100644 --- a/mise.toml +++ b/mise.toml @@ -10,7 +10,7 @@ HOLDS = ''' ''' [tools] -"github:standards-lab/claude-plugins" = { version = "0.22.0", version_prefix = "marathon/v" } +"github:standards-lab/claude-plugins" = { version = "0.23.0", version_prefix = "marathon/v" } actionlint = "1.7.12" node = "26.13.1" pnpm = "12.21.0" From 7b1ff5e09f00919fa969748cb64ef2350379b5c9 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 18:25:38 -0500 Subject: [PATCH 02/17] components-settings: web-foundation v0.4.0 The foundation peer range is ^0.4.0 and the development install takes it at its v0.4.0 tag. The v0.3.0 hold is gone, and with it mise.toml's [env] HOLDS, which currency.sh reads as empty when unset. The components read v0.4.0's role hooks, --color-accent and --color-primary, in place of --accent-color and --interaction-color, each keeping its hue fallback; the tests and docs/layout.md follow. No other v0.4.0 breaking change (theme menu, keys help, setOpen/isOpen, Listed's run) reaches the components. --- docs/layout.md | 4 ++-- mise.toml | 5 ----- package.json | 4 ++-- pnpm-lock.yaml | 12 ++++++------ src/chat-thread.css | 2 +- src/entry.css | 6 +++--- src/stage-timeline.css | 10 +++++----- src/upload-dropzone.css | 4 ++-- test/browser/components.test.ts | 18 +++++++++--------- test/browser/themes.test.ts | 2 +- 10 files changed, 31 insertions(+), 36 deletions(-) diff --git a/docs/layout.md b/docs/layout.md index a4c2223..95e2985 100644 --- a/docs/layout.md +++ b/docs/layout.md @@ -11,8 +11,8 @@ layout each one promises. details and summary, and the focus outline their look. The sheet is unlayered, so it sits above both, and it gives a native control no look of its own beyond its layout. - A sheet reads only the foundation's baseline tokens, which a shadow root inherits from the page's - entry. A component in progress takes `--accent-color`, the foundation's hook for what is current - or in progress, falling back to `--magenta`; an interaction takes `--interaction-color`, falling + entry. A component in progress takes `--color-accent`, the foundation's hook for what is current + or in progress, falling back to `--magenta`; an interaction takes `--color-primary`, falling back to `--blue`. - A component that draws one frame around content that scrolls (the artifact viewer, the event log, the chat thread) makes it a flex child of a flex-column host with `min-block-size: 0`, so a diff --git a/mise.toml b/mise.toml index 25e5ffc..8899956 100644 --- a/mise.toml +++ b/mise.toml @@ -4,11 +4,6 @@ [settings] task.run_auto_install = false -[env] -HOLDS = ''' -@standards-lab/web-foundation v0.3.0: v0.4.0 renames --accent-color and --interaction-color and changes adopted element rules; v1.client.stack's components-settings takes it with its design review -''' - [tools] "github:standards-lab/claude-plugins" = { version = "0.23.0", version_prefix = "marathon/v" } actionlint = "1.7.12" diff --git a/package.json b/package.json index 543d9c9..ea8e481 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,12 @@ "marked": "18.2.1" }, "peerDependencies": { - "@standards-lab/web-foundation": "^0.3.0" + "@standards-lab/web-foundation": "^0.4.0" }, "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "4.8.1", "@eslint/js": "10.0.1", - "@standards-lab/web-foundation": "github:standards-lab/web-foundation#v0.3.0", + "@standards-lab/web-foundation": "github:standards-lab/web-foundation#v0.4.0", "@standards-lab/web-tooling": "github:standards-lab/web-tooling#v0.1.0", "@types/node": "26.6.6", "eslint": "10.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e3b0859..1588905 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,8 +22,8 @@ importers: specifier: 10.0.1 version: 10.0.1(eslint@10.15.0(supports-color@7.2.0)) '@standards-lab/web-foundation': - specifier: github:standards-lab/web-foundation#v0.3.0 - version: https://codeload.github.com/standards-lab/web-foundation/tar.gz/f8b3edc0dc658cfff64ec4eb60b5dd7019798b0b + specifier: github:standards-lab/web-foundation#v0.4.0 + version: https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f '@standards-lab/web-tooling': specifier: github:standards-lab/web-tooling#v0.1.0 version: https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794 @@ -158,9 +158,9 @@ packages: '@lit/reactive-element@2.1.2': resolution: {integrity: sha512-pbCDiVMnne1lYUIaYNN5wrwQXDtHaYtg7YEFPeW+hws6U47WeFvISGUWekPGKWOP1ygrs0ef0o1VJMk1exos5A==} - '@standards-lab/web-foundation@https://codeload.github.com/standards-lab/web-foundation/tar.gz/f8b3edc0dc658cfff64ec4eb60b5dd7019798b0b': - resolution: {gitHosted: true, integrity: sha512-yOEDzhuWiRQt9+0KTv3hj4GOqGOx6uvQQLi7es9GqR+gENMp2nM+LZ/fp1vNYP3VktDeyXIxTLjyjLGysYTtWA==, tarball: https://codeload.github.com/standards-lab/web-foundation/tar.gz/f8b3edc0dc658cfff64ec4eb60b5dd7019798b0b} - version: 0.3.0 + '@standards-lab/web-foundation@https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f': + resolution: {gitHosted: true, integrity: sha512-XHEQUH+IRxncWqdaNLgRFjpF6f4Jc9WJWTh/7weKEbrjbha2nDgfj+pdwsKITbcuXOqqgqc2Dyx1lr/q7nlQsg==, tarball: https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f} + version: 0.4.0 '@standards-lab/web-tooling@https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794': resolution: {gitHosted: true, integrity: sha512-D+0nTntEPlGCsjg82qXCVPb0INy38/uyiEbYbewQ+gq7pGSMMd9Mw1BDL2/VbuIQMI17cxXRKnnPZDrvP9eAyg==, tarball: https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794} @@ -938,7 +938,7 @@ snapshots: dependencies: '@lit-labs/ssr-dom-shim': 1.6.0 - '@standards-lab/web-foundation@https://codeload.github.com/standards-lab/web-foundation/tar.gz/f8b3edc0dc658cfff64ec4eb60b5dd7019798b0b': {} + '@standards-lab/web-foundation@https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f': {} '@standards-lab/web-tooling@https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794': {} diff --git a/src/chat-thread.css b/src/chat-thread.css index 30ea720..1ac9d47 100644 --- a/src/chat-thread.css +++ b/src/chat-thread.css @@ -132,7 +132,7 @@ summary, inline-size: 0.5em; block-size: 0.5em; border-radius: var(--radius-full); - background-color: var(--accent-color, var(--magenta)); + background-color: var(--color-accent, var(--magenta)); } @media (prefers-reduced-motion: no-preference) { .status.in_progress::before { diff --git a/src/entry.css b/src/entry.css index 13148f5..2a3b3d1 100644 --- a/src/entry.css +++ b/src/entry.css @@ -21,8 +21,8 @@ text-align: start; } :host([selected]) .entry:not(:focus-visible) { - border-color: var(--accent-color, var(--magenta)); - box-shadow: inset 0 0 0 var(--line-s) var(--accent-color, var(--magenta)); + border-color: var(--color-accent, var(--magenta)); + box-shadow: inset 0 0 0 var(--line-s) var(--color-accent, var(--magenta)); } .head { display: flex; @@ -46,7 +46,7 @@ white-space: nowrap; } :host([status-tone="active"]) .status { - color: var(--accent-color, var(--magenta)); + color: var(--color-accent, var(--magenta)); } :host([status-tone="complete"]) .status { color: var(--green); diff --git a/src/stage-timeline.css b/src/stage-timeline.css index 5bdcf0c..0a6def2 100644 --- a/src/stage-timeline.css +++ b/src/stage-timeline.css @@ -63,9 +63,9 @@ stroke-linejoin: round; } .active .marker { - border-color: var(--accent-color, var(--magenta)); - background-color: color-mix(in srgb, var(--accent-color, var(--magenta)) 12%, transparent); - color: var(--accent-color, var(--magenta)); + border-color: var(--color-accent, var(--magenta)); + background-color: color-mix(in srgb, var(--color-accent, var(--magenta)) 12%, transparent); + color: var(--color-accent, var(--magenta)); font-weight: 600; } .complete .marker { @@ -83,7 +83,7 @@ content: ""; position: absolute; inset: calc(-1 * var(--line-m)); - border: var(--line-m) solid var(--accent-color, var(--magenta)); + border: var(--line-m) solid var(--color-accent, var(--magenta)); border-radius: var(--radius-full); animation: ring 1.6s ease-out infinite; } @@ -134,7 +134,7 @@ white-space: nowrap; } .active .label { - color: var(--accent-color, var(--magenta)); + color: var(--color-accent, var(--magenta)); } .complete .label { color: var(--green); diff --git a/src/upload-dropzone.css b/src/upload-dropzone.css index e304b1a..fda07d4 100644 --- a/src/upload-dropzone.css +++ b/src/upload-dropzone.css @@ -24,8 +24,8 @@ } .zone.over { border-style: solid; - border-color: var(--interaction-color, var(--blue)); - background-color: color-mix(in srgb, var(--interaction-color, var(--blue)) 10%, transparent); + border-color: var(--color-primary, var(--blue)); + background-color: color-mix(in srgb, var(--color-primary, var(--blue)) 10%, transparent); color: var(--fg); } @media (prefers-reduced-motion: no-preference) { diff --git a/test/browser/components.test.ts b/test/browser/components.test.ts index 34d0056..982b1e7 100644 --- a/test/browser/components.test.ts +++ b/test/browser/components.test.ts @@ -299,7 +299,7 @@ describe("components", { timeout: 60_000 }, () => { byAttribute.item = { id: "d-attr", name: "designs", status: "failed", updated_at: "2026-10-12T16:41:07Z" }; main.append(byAttribute); } - ${hook ? `main.style.setProperty("--accent-color", "rgb(1, 2, 3)");` : ""} + ${hook ? `main.style.setProperty("--color-accent", "rgb(1, 2, 3)");` : ""} const entries = [...main.querySelectorAll("sl-entry")]; await Promise.all(entries.map((entry) => entry.updateComplete)); const root = entries[0].shadowRoot; @@ -311,7 +311,7 @@ describe("components", { timeout: 60_000 }, () => { return resolved; }; const hues = { - accent: resolve("var(--accent-color, var(--magenta))"), + accent: resolve("var(--color-accent, var(--magenta))"), green: resolve("var(--green)"), orange: resolve("var(--orange)"), red: resolve("var(--red)"), @@ -328,7 +328,7 @@ describe("components", { timeout: 60_000 }, () => { }; })()`); for (const hook of [false, true]) { - const where = hook ? "--accent-color set" : "at the accent hook's fallback"; + const where = hook ? "--color-accent set" : "at the accent hook's fallback"; const shown: { distinct: boolean; entries: unknown[][] } = await read(hook); assert.ok(shown.distinct, `${where}: the hues differ`); assert.deepEqual( @@ -1016,7 +1016,7 @@ describe("components", { timeout: 60_000 }, () => { const root = entry.shadowRoot; const button = root.querySelector(".entry"); const probe = root.appendChild(document.createElement("span")); - probe.style.color = "var(--accent-color, var(--magenta))"; + probe.style.color = "var(--color-accent, var(--magenta))"; const accent = getComputedStyle(probe).color; probe.remove(); const look = () => { @@ -1069,7 +1069,7 @@ describe("components", { timeout: 60_000 }, () => { const entry = document.querySelector("#focus sl-entry"); const button = entry.shadowRoot.querySelector(".entry"); const probe = entry.shadowRoot.appendChild(document.createElement("span")); - probe.style.color = "var(--accent-color, var(--magenta))"; + probe.style.color = "var(--color-accent, var(--magenta))"; const accent = getComputedStyle(probe).color; probe.remove(); const style = getComputedStyle(button); @@ -1182,11 +1182,11 @@ describe("components", { timeout: 60_000 }, () => { probe.remove(); return resolved; }; - const accent = resolve("color", "var(--accent-color, var(--magenta))"); - const interaction = resolve("color", "var(--interaction-color, var(--blue))"); + const accent = resolve("color", "var(--color-accent, var(--magenta))"); + const interaction = resolve("color", "var(--color-primary, var(--blue))"); const tint = resolve( "backgroundColor", - "color-mix(in srgb, var(--accent-color, var(--magenta)) 12%, transparent)", + "color-mix(in srgb, var(--color-accent, var(--magenta)) 12%, transparent)", ); const root = (selector) => subtree.querySelector(selector).shadowRoot; const [framed, focused] = [...subtree.querySelectorAll("sl-entry")] @@ -1233,7 +1233,7 @@ describe("components", { timeout: 60_000 }, () => { "the drag-over zone's border": "interaction", "the focus ring": "interaction", }; - for (const hook of ["", "--accent-color", "--interaction-color"]) { + for (const hook of ["", "--color-accent", "--color-primary"]) { const shown: { distinct: boolean; focused: boolean; over: boolean; marks: object } = await read(hook); const { marks, ...state } = shown; diff --git a/test/browser/themes.test.ts b/test/browser/themes.test.ts index ad29d74..31ffaa3 100644 --- a/test/browser/themes.test.ts +++ b/test/browser/themes.test.ts @@ -86,7 +86,7 @@ const READ = `async (choice) => { return resolved; }; const tokens = Object.fromEntries(${JSON.stringify(TOKENS)}.map((token) => [token, resolve("var(" + token + ")")])); - const interaction = resolve("var(--interaction-color, var(--blue))"); + const interaction = resolve("var(--color-primary, var(--blue))"); const texts = []; const walk = (root, path) => { for (const element of root.querySelectorAll("*")) { From 36d1b64e32da7ea239abfe5efb95c45c0ff0ea70 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 18:43:53 -0500 Subject: [PATCH 03/17] components-settings: the foundation's sheets in place of the local copies Each component adopts web-foundation v0.4.0's opt-in sheets it uses, after reset and elements and before its own: utilities.css in every component but the status badge; dialog.css in the drawer (its header row); motion.css in the drawer (the slide), the upload dropzone (the drag-over change), the chat thread (the streaming dot's pulse) and the stage timeline (the active marker's ring). glyph-button.css is adopted by none yet: sl-drawer's glyph Close is slice 5. The local copies go: visually hidden names, bare lists, nowrap and tabular values, unbroken ids, the truncated values, scrolling frames, the alternatives slots, head rows, quiet type and the status line take the utilities' classes; the pulse and ring keyframes, the 120ms and 200ms durations take motion.css; the composer's disabled-field rule goes to the elements layer's. Decisions: - The pulse dot and the ring were ::before and ::after; .motion-pulse and .motion-ring need an element, so each is now an aria-hidden span. The ring stays drawn only under no-preference, as before. - Spacing the components set themselves stays local: a list's margin: 0 (the utilities' .list-bare keeps the flow step), the drawer header's padding, border and margin-block-end: 0 over .dialog-header's --space-m, and the event log's dd max-inline-size: 100%, which .text-truncate needs in a flex column. - Where the foundation intentionally differs, its rule is taken: the search match's head row gains the --space-3xs row gap; the search status gains the status line's 1lh minimum; the drawer header's Close no longer shrinks; the artifact viewer's region aligns its content to the start. - The composer's growth cap and the dropzone's strut and row gap read --control-edge, --control-block-size and --focus-reach, the values they restated, the 2px literal among them. - Left local, since no class can reach marked's output: the chat thread's inline code (inline-block, capped) and its tables' and pres' scroll. - Field sizing stays local (composer 12ch, page field 3ch content-box); the foundation's .field-grow is in structure.css, outside this slice's sheets. - Tests: the adoption case names each component's sheets in order; a new case runs the pulse and ring by name inside the shadow roots and the drag-over in --duration-s, none under reduce; the drawer case follows --duration-m; the event log's cases select dd.text-truncate; LINES counts text-node lines, so the dot's own box isn't a line. Before/after specimen captures (--all) differ only by animation phase and the native video spinner. --- README.md | 3 +- docs/layout.md | 13 ++-- src/artifact-viewer.css | 30 ++------- src/artifact-viewer.ts | 15 ++--- src/chat-thread.css | 46 ++------------ src/chat-thread.ts | 41 ++++++++----- src/composer.css | 27 ++------ src/composer.ts | 13 ++-- src/document-list.css | 18 +----- src/document-list.ts | 16 ++--- src/drawer.css | 29 +++------ src/drawer.ts | 11 ++-- src/entry.css | 37 ++--------- src/entry.ts | 17 ++--- src/event-log.css | 31 ++-------- src/event-log.ts | 19 +++--- src/pagination.css | 13 +--- src/pagination.ts | 9 +-- src/search-results.css | 30 ++------- src/search-results.ts | 15 ++--- src/stage-timeline.css | 41 ++----------- src/stage-timeline.ts | 16 ++--- src/upload-dropzone.css | 27 +++----- src/upload-dropzone.ts | 18 +++--- test/browser/components.test.ts | 99 +++++++++++++++++++++++++----- test/browser/document-list.test.ts | 6 +- test/browser/drawer.test.ts | 13 ++++ 27 files changed, 276 insertions(+), 377 deletions(-) diff --git a/README.md b/README.md index ebf110e..a416f18 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ package keeps the standard syntax, with no pack-time rewrite. The package is `@standards-lab/web-components`. Each module defines its element when it is imported, and the element's shadow root adopts the foundation's reset and elements sheets, then -its own layout-only sheet. The modules import `lit` and the foundation by package name and their +the foundation's utilities, dialog, and motion sheets where it uses them, then its own layout-only +sheet. The modules import `lit` and the foundation by package name and their sheets as CSS module scripts, so a page reaches them through an import map or a bundler, and links the foundation's `page.css`: diff --git a/docs/layout.md b/docs/layout.md index 95e2985..7f9452a 100644 --- a/docs/layout.md +++ b/docs/layout.md @@ -8,8 +8,12 @@ layout each one promises. - Each component adopts its sheet into its shadow root after the foundation's `baseline/reset.css` and `baseline/elements.css`, which give the native controls, the pre, the rendered Markdown, the - details and summary, and the focus outline their look. The sheet is unlayered, so it sits above - both, and it gives a native control no look of its own beyond its layout. + details and summary, and the focus outline their look. Between those and its own, it adopts the + foundation's opt-in sheets whose classes it uses: `utilities.css` (every component but the status + badge), `dialog.css` (the drawer's header row), and `motion.css` (the drawer's slide, the + dropzone's drag-over change, the chat thread's pulse, and the stage timeline's ring). Its own + sheet is unlayered, so it sits above all of them, and it gives a native control no look of its own + beyond its layout. - A sheet reads only the foundation's baseline tokens, which a shadow root inherits from the page's entry. A component in progress takes `--color-accent`, the foundation's hook for what is current or in progress, falling back to `--magenta`; an interaction takes `--color-primary`, falling @@ -160,9 +164,8 @@ layout each one promises. - The field and the control are siblings in a row, each its own native frame, never one inside another; the control sits at the row's block end, beside the field's last line. - The field's bound is eight lines inside its padding and border; past it the field scrolls. -- The elements sheet styles a disabled button but not a disabled field, so the composer gives its - disabled field the first elevated surface, a divider's border, and text a tier quieter, still - apart from the placeholder's `--fg-3`. +- A disabled field takes the elements sheet's disabled look: the first elevated surface, a + divider's border, and text a tier quieter, still apart from the placeholder's `--fg-3`. ## Pagination diff --git a/src/artifact-viewer.css b/src/artifact-viewer.css index ae50689..f73dcd5 100644 --- a/src/artifact-viewer.css +++ b/src/artifact-viewer.css @@ -1,9 +1,11 @@ /* From spike-html-apps-components (10dde51): src/artifact-viewer.css. */ /* - * The artifact viewer's shadow-root sheet: a header of the name and content type over one - * frame that holds a note, the scrolling region, or a native view. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * The artifact viewer's shadow-root sheet: a header of the name and content type, on the + * utilities' head row, over one frame that holds a note, the utilities' scrolling frame as the + * region, or a native view. + * Unlayered, above the foundation's reset, elements, and utilities sheets; it reads only the + * baseline tokens. * See docs/layout.md */ @@ -13,26 +15,13 @@ } .header { flex: none; - display: flex; - flex-wrap: wrap; - align-items: baseline; - gap: var(--space-3xs) var(--space-xs); margin-block-end: var(--space-2xs); - min-inline-size: 0; overflow-wrap: anywhere; } .name { - flex: 1 1 16ch; - max-inline-size: max-content; - min-inline-size: 0; font-size: var(--text-s); font-weight: 600; } -.type { - margin-inline-start: auto; - font-size: var(--text-s); - color: var(--fg-2); -} .frame { flex: 1 1 auto; display: flex; @@ -42,11 +31,6 @@ border-radius: var(--radius-sm); } .body { - flex: 1 1 auto; - display: grid; - grid-template-columns: minmax(0, 1fr); - min-block-size: 0; - overflow: auto; margin: 0; padding: 0; border: 0; @@ -87,10 +71,6 @@ .error > .label { color: var(--red); } -.detail { - font-size: var(--text-s); - color: var(--fg-2); -} .download { justify-self: start; } diff --git a/src/artifact-viewer.ts b/src/artifact-viewer.ts index c3fd4b1..ff173a7 100644 --- a/src/artifact-viewer.ts +++ b/src/artifact-viewer.ts @@ -10,6 +10,7 @@ import { html, LitElement, nothing, type PropertyDeclarations, type PropertyValu import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; import { formatJson } from "./json.ts"; import { markdown } from "./markdown.ts"; @@ -170,7 +171,7 @@ function pretty(content: string): Json { * native element. Display-only: it sends no event. */ export class ArtifactViewer extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, styles]; static properties = { name: { type: String }, @@ -286,11 +287,11 @@ export class ArtifactViewer extends LitElement { #region(content: unknown, markdownView = false, describedBy: string | typeof nothing = nothing) { return markdownView - ? html`
+ ? html`
${content}
` : html`
       ${label}
-      ${detail === nothing ? nothing : html`${detail}`} ${action}
+      ${detail === nothing ? nothing : html`${detail}`} ${action}
     

`; } @@ -392,9 +393,9 @@ export class ArtifactViewer extends LitElement { render() { const header = !this.noHeader && (this.name || this.contentType) - ? html`
- ${this.name ? html`${this.name}` : nothing} - ${this.contentType ? html`${this.contentType}` : nothing} + ? html`
+ ${this.name ? html`${this.name}` : nothing} + ${this.contentType ? html`${this.contentType}` : nothing}
` : nothing; return html`${header}${this.#frame()}`; diff --git a/src/chat-thread.css b/src/chat-thread.css index 1ac9d47..9321907 100644 --- a/src/chat-thread.css +++ b/src/chat-thread.css @@ -1,9 +1,11 @@ /* From spike-html-apps-components (10dde51): src/chat-thread.css. */ /* - * The chat thread's shadow-root sheet: one frame that scrolls the list of items, each message's - * place and label row, a verbose item's line, a refusal's mark, and the streaming indicator. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * The chat thread's shadow-root sheet: the utilities' scrolling frame around the bare list of + * items, each message's place and label row, a verbose item's line, a refusal's mark, and the + * streaming indicator's dot, which the motion sheet's pulse runs. + * Unlayered, above the foundation's reset, elements, utilities, and motion sheets; it reads only + * the baseline tokens. * See docs/layout.md */ @@ -12,12 +14,6 @@ flex-direction: column; } .frame { - flex: 1 1 auto; - display: grid; - grid-template-columns: minmax(0, 1fr); - align-content: start; - min-block-size: 0; - overflow: auto; border: var(--line-s) solid var(--border); border-radius: var(--radius-sm); } @@ -27,11 +23,9 @@ gap: var(--space-s); margin: 0; padding: var(--space-s); - list-style: none; } .thread > .item { min-inline-size: 0; - margin: 0; } .thread > .user { align-self: flex-end; @@ -48,8 +42,6 @@ align-items: baseline; gap: var(--space-3xs) var(--space-xs); font-family: var(--font-ui); - font-size: var(--text-s); - color: var(--fg-2); } .message > .meta { display: flex; @@ -61,8 +53,6 @@ summary, .line { font-family: var(--font-ui); - font-size: var(--text-s); - color: var(--fg-2); } .gutter { display: inline list-item; @@ -83,17 +73,8 @@ summary, font-weight: 600; } .kind, -.name, -.id, .status { display: inline-block; - white-space: nowrap; -} -.name, -.id { - max-inline-size: 100%; - white-space: normal; - overflow-wrap: anywhere; } .id { color: var(--fg-3); @@ -124,8 +105,7 @@ summary, .refusal > .label { color: var(--orange); } -.status.in_progress::before { - content: ""; +.status > .dot { display: inline-block; margin-inline-end: var(--space-3xs); vertical-align: 0.1em; @@ -134,16 +114,6 @@ summary, border-radius: var(--radius-full); background-color: var(--color-accent, var(--magenta)); } -@media (prefers-reduced-motion: no-preference) { - .status.in_progress::before { - animation: pulse 1.4s ease-in-out infinite; - } -} -@keyframes pulse { - 50% { - opacity: 0.25; - } -} .status.incomplete { color: var(--orange); } @@ -160,7 +130,3 @@ summary, padding: var(--space-xs) var(--space-s); color: var(--fg-2); } -.empty { - font-size: var(--text-s); - color: var(--fg-2); -} diff --git a/src/chat-thread.ts b/src/chat-thread.ts index cdeef2d..5ee74a8 100644 --- a/src/chat-thread.ts +++ b/src/chat-thread.ts @@ -18,6 +18,8 @@ import { repeat } from "lit/directives/repeat.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; import { formatJson } from "./json.ts"; import { markdown } from "./markdown.ts"; @@ -157,7 +159,7 @@ function end(frame: HTMLElement) { * holds it to a height. */ export class ChatThread extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, motion, styles]; static properties = { items: { attribute: false }, @@ -252,7 +254,11 @@ export class ChatThread extends LitElement { #status(status: ItemStatus | undefined) { const label = status ? STATUS_LABELS[status] : undefined; if (!label) return nothing; - return html`${label}`; + const dot = + status === "in_progress" + ? html`` + : nothing; + return html`${dot}${label}`; } #message(item: MessageItem) { @@ -275,14 +281,14 @@ export class ChatThread extends LitElement { class="message ${item.role}" aria-busy=${item.status === "in_progress" ? "true" : nothing} > -
${role}${this.#status(item.status)}
+
${role}${this.#status(item.status)}
${parts}
`; } #line(item: ThreadItem, kind: string, names: TemplateResult[], described: TemplateResult[]) { const status = this.#status(item.status); - const parts = [html`${kind}`, ...names]; + const parts = [html`${kind}`, ...names]; if (status !== nothing) parts.push(status); parts.push(...described); return parts.map((part, index) => (index ? html` ${part}` : part)); @@ -296,7 +302,7 @@ export class ChatThread extends LitElement { described: TemplateResult[] = [], ) { return html`
- ${this.#line(item, kind, names, described)} + ${this.#line(item, kind, names, described)}
${body}
`; } @@ -314,7 +320,7 @@ export class ChatThread extends LitElement { if (summary && !thought) { const gutter = html``; const line = this.#line(item, "Reasoning", [], described); - return html`

${gutter}${line}

`; + return html`

${gutter}${line}

`; } return this.#details( item, @@ -322,7 +328,7 @@ export class ChatThread extends LitElement { [], thought ? content.map((part) => html`

${part.text}

`) - : html`

No reasoning text.

`, + : html`

No reasoning text.

`, described, ); } @@ -332,8 +338,13 @@ export class ChatThread extends LitElement { return this.#details( item, "Function call", - [html`${item.name}`, html`${item.call_id}`], - args.trim() ? html`
${pretty(args)}
` : html`

No arguments.

`, + [ + html`${item.name}`, + html`${item.call_id}`, + ], + args.trim() + ? html`
${pretty(args)}
` + : html`

No arguments.

`, ); } @@ -349,10 +360,12 @@ export class ChatThread extends LitElement { item, "Function output", [ - ...(name ? [html`${name}`] : []), - html`${item.call_id}`, + ...(name ? [html`${name}`] : []), + html`${item.call_id}`, ], - output.trim() ? html`
${pretty(output)}
` : html`

No output.

`, + output.trim() + ? html`
${pretty(output)}
` + : html`

No output.

`, ); } @@ -381,10 +394,10 @@ export class ChatThread extends LitElement { return; } }); - return html`
+ return html`
${ shown.length - ? html`
    + ? html`
      ${repeat( shown, ({ key }) => key, diff --git a/src/composer.css b/src/composer.css index 98e0d20..8c6c792 100644 --- a/src/composer.css +++ b/src/composer.css @@ -2,22 +2,15 @@ /* * The composer's shadow-root sheet: the row of the growing field and its send or stop control, - * and the visually hidden label. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * the action stacking both its names on the utilities' alternatives. + * Unlayered, above the foundation's reset, elements, and utilities sheets; it reads only the + * baseline tokens. * See docs/layout.md */ :host { display: block; } -.label { - position: absolute; - inline-size: 1px; - block-size: 1px; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; -} .composer { display: flex; align-items: end; @@ -26,24 +19,12 @@ textarea { flex: 1 1 0; min-inline-size: 12ch; - max-block-size: calc(8lh + 2 * var(--space-3xs) + 2 * var(--line-s)); + max-block-size: calc(8lh + var(--control-edge)); field-sizing: content; resize: none; overflow-wrap: anywhere; } -textarea:disabled { - border-color: var(--border); - background-color: var(--bg-1); - color: var(--fg-2); -} .action { flex: none; - display: grid; justify-items: center; } -.action > span { - grid-area: 1 / 1; -} -.action > .off { - visibility: hidden; -} diff --git a/src/composer.ts b/src/composer.ts index df12887..d351b45 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -5,11 +5,12 @@ // Adapted from spike-html-apps-components (10dde51): src/composer.ts, on @standards-lab/web-foundation. // See docs/internals.md -import { html, LitElement, type PropertyDeclarations } from "lit"; +import { html, LitElement, nothing, type PropertyDeclarations } from "lit"; import { live } from "lit/directives/live.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define, emit } from "@standards-lab/web-foundation/dom.js"; import styles from "./composer.css" with { type: "css" }; @@ -43,7 +44,7 @@ export type StopDetail = Record; * field, where the reader writes next. */ export class Composer extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, styles]; static properties = { value: { type: String }, @@ -105,7 +106,7 @@ export class Composer extends LitElement { render() { const busy = this.busy; - return html` + return html`
      `; } diff --git a/src/document-list.css b/src/document-list.css index 202e02d..b9fa577 100644 --- a/src/document-list.css +++ b/src/document-list.css @@ -2,8 +2,9 @@ /* * The document list's shadow-root sheet: the status line, on the pagination's summary line or - * a line of its own, and the list of entries. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * a line of its own, the utilities' status line, and the list of entries, a bare list. + * Unlayered, above the foundation's reset, elements, and utilities sheets; it reads only the + * baseline tokens. * See docs/layout.md */ @@ -17,18 +18,10 @@ .status[slot="status"] { display: inline; } -.status[slot="status"] .label { - white-space: nowrap; -} .status[slot="status"] .label::before { content: "·" / ""; margin-inline: 0.5ch; } -.status:not([slot]) { - min-block-size: 1lh; - font-size: var(--text-s); - color: var(--fg-2); -} .status .empty { color: var(--fg-3); } @@ -37,9 +30,4 @@ } .documents { margin: 0; - padding: 0; - list-style: none; -} -.documents > li { - margin: 0; } diff --git a/src/document-list.ts b/src/document-list.ts index 5a23b00..a09e788 100644 --- a/src/document-list.ts +++ b/src/document-list.ts @@ -12,6 +12,7 @@ import { repeat } from "lit/directives/repeat.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; import "./entry.ts"; import type { FileItem, StatusTone } from "./entry.ts"; @@ -73,7 +74,7 @@ function entryItem(item: DocumentItem): FileItem { * busy, so a page change doesn't empty and refill the list; an error lists none. */ export class DocumentList extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, styles]; static properties = { items: { attribute: false }, @@ -118,15 +119,16 @@ export class DocumentList extends LitElement { this.disabled = false; } - #status(documents: readonly DocumentItem[]) { + #status(documents: readonly DocumentItem[], joins: boolean) { + const label = joins ? "label text-nowrap" : "label"; switch (this.state) { case "loading": - return html`Loading documents…`; + return html`Loading documents…`; case "error": - return html`Couldn't load the documents. + return html`Couldn't load the documents. ${this.message ? html`${this.message}` : nothing}`; } - return documents.length ? nothing : html`No documents.`; + return documents.length ? nothing : html`No documents.`; } #entry(item: DocumentItem) { @@ -151,10 +153,10 @@ export class DocumentList extends LitElement { .pageSizes=${this.pageSizes} .disabled=${this.disabled} > -

      ${this.#status(documents)}

      +

      ${this.#status(documents, joins)}

      ${ documents.length - ? html`
        + ? html`
          ${repeat( documents, (item) => item.id, diff --git a/src/drawer.css b/src/drawer.css index 2dc1927..15b9458 100644 --- a/src/drawer.css +++ b/src/drawer.css @@ -2,8 +2,10 @@ /* * The drawer's shadow-root sheet: the docked aside's frame and the modal dialog covering the - * viewport, each a header over a scrolling body, and the dialog's slide. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * viewport, each a dialog header over a scrolling body, and the dialog's slide, in the motion + * sheet's --duration-m. + * Unlayered, above the foundation's reset, elements, utilities, dialog, and motion sheets; it reads + * only the baseline tokens. * See docs/layout.md */ @@ -44,20 +46,13 @@ dialog[open] { translate: 0 0; } header { - display: flex; - align-items: center; - justify-content: space-between; - gap: var(--space-s); + margin-block-end: 0; padding: var(--space-s); border-block-end: var(--line-s) solid var(--border); } h2 { - margin: 0; font-size: var(--text-l); } -h2[tabindex="-1"]:focus { - outline: none; -} .body { flex: 1 1 auto; min-block-size: 0; @@ -66,20 +61,12 @@ h2[tabindex="-1"]:focus { padding: var(--space-s); scroll-padding: var(--space-s); } -.hidden { - position: absolute; - inline-size: 1px; - block-size: 1px; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; -} @media (prefers-reduced-motion: no-preference) { dialog { transition: - translate 200ms ease-out, - overlay 200ms allow-discrete, - display 200ms allow-discrete; + translate var(--duration-m) ease-out, + overlay var(--duration-m) allow-discrete, + display var(--duration-m) allow-discrete; } @starting-style { dialog[open] { diff --git a/src/drawer.ts b/src/drawer.ts index 86942c8..cdbff42 100644 --- a/src/drawer.ts +++ b/src/drawer.ts @@ -11,6 +11,9 @@ import { html, LitElement, type PropertyDeclarations, type PropertyValues } from import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import dialogSheet from "@standards-lab/web-foundation/dialog.css" with { type: "css" }; +import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define, emit } from "@standards-lab/web-foundation/dom.js"; import styles from "./drawer.css" with { type: "css" }; @@ -58,7 +61,7 @@ export type CloseDetail = Record; * is the custom state `docked` or `drawer`, which a page may style. */ export class Drawer extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, dialogSheet, motion, styles]; static properties = { open: { type: Boolean, reflect: true }, @@ -181,15 +184,15 @@ export class Drawer extends LitElement { render() { if (!this.#narrow) { return html``; } return html` -
          +

          ${this.label}

          diff --git a/src/entry.css b/src/entry.css index 2a3b3d1..3cb89da 100644 --- a/src/entry.css +++ b/src/entry.css @@ -1,9 +1,10 @@ /* From spike-html-apps-components (10dde51): src/entry.css. */ /* - * The entry's shadow-root sheet: the button's head of the name and status, its meta line, the - * status tones, and the selected frame. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * The entry's shadow-root sheet: the button's head of the name and status on the utilities' head + * row, its meta line, the status tones, and the selected frame. + * Unlayered, above the foundation's reset, elements, and utilities sheets; it reads only the + * baseline tokens. * See docs/layout.md */ @@ -24,27 +25,11 @@ border-color: var(--color-accent, var(--magenta)); box-shadow: inset 0 0 0 var(--line-s) var(--color-accent, var(--magenta)); } -.head { - display: flex; - flex-wrap: wrap; - align-items: baseline; - gap: var(--space-3xs) var(--space-xs); - min-inline-size: 0; -} .name { - flex: 1 1 16ch; - max-inline-size: max-content; - min-inline-size: 0; font-size: var(--text-m); font-weight: 600; overflow-wrap: anywhere; } -.status { - margin-inline-start: auto; - font-size: var(--text-xs); - color: var(--fg-2); - white-space: nowrap; -} :host([status-tone="active"]) .status { color: var(--color-accent, var(--magenta)); } @@ -57,31 +42,17 @@ :host([status-tone="failed"]) .status { color: var(--red); } -.kind { - position: absolute; - inline-size: 1px; - block-size: 1px; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; -} .meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-3xs) var(--space-xs); min-inline-size: 0; - font-size: var(--text-s); - color: var(--fg-2); } .type { min-inline-size: 0; overflow-wrap: break-word; } -.size, -time > .clock { - white-space: nowrap; -} time { min-inline-size: 0; overflow-wrap: break-word; diff --git a/src/entry.ts b/src/entry.ts index 6a9aa7a..64b8732 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -6,6 +6,7 @@ import { html, LitElement, nothing, type PropertyDeclarations } from "lit"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define, emit } from "@standards-lab/web-foundation/dom.js"; import { formatBytes, formatDate, formatDateTime } from "@standards-lab/web-foundation/format.js"; import styles from "./entry.css" with { type: "css" }; @@ -67,7 +68,7 @@ function renderTime(updatedAt: string) { return html``; @@ -87,7 +88,7 @@ function renderTime(updatedAt: string) { * consumer's reading of the status, not the item's data, so the item keeps its API's shape. */ export class Entry extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, styles]; static properties = { item: { attribute: false }, @@ -121,15 +122,15 @@ export class Entry extends LitElement { const file = "content_type" in item ? item : null; return html` `; } @@ -203,10 +204,10 @@ export class SearchResults extends LitElement { const needle = needleOf(this.#answered); const answered = needle.join(""); const matches = this.state === "error" ? [] : (this.items ?? []); - return html`

          ${this.#status(query, answered, matches)}

          + return html`

          ${this.#status(query, answered, matches)}

          ${ matches.length - ? html`
            + ? html`
              ${repeat( matches, (match) => match.id, diff --git a/src/stage-timeline.css b/src/stage-timeline.css index 0a6def2..27f942f 100644 --- a/src/stage-timeline.css +++ b/src/stage-timeline.css @@ -1,9 +1,11 @@ /* From spike-html-apps-components (10dde51): src/stage-timeline.css. */ /* - * The stage timeline's shadow-root sheet: the list of steps, each a marker, a connector to the - * next, a name, a detail line of the state's label and time, and a failed stage's reason. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * The stage timeline's shadow-root sheet: the bare list of steps, each a marker, with the active + * one's ring, which the motion sheet's ring runs, a connector to the next, a name, a detail line of + * the state's label and time, each on the utilities' alternatives, and a failed stage's reason. + * Unlayered, above the foundation's reset, elements, utilities, and motion sheets; it reads only + * the baseline tokens. * See docs/layout.md */ @@ -12,15 +14,12 @@ } .stages { margin: 0; - padding: 0; - list-style: none; } .stage { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto var(--space-s); column-gap: var(--space-xs); - margin: 0; } .stage:last-child { grid-template-rows: auto auto auto; @@ -79,23 +78,11 @@ color: var(--bg); } @media (prefers-reduced-motion: no-preference) { - .active .marker::after { - content: ""; + .marker > .ring { position: absolute; inset: calc(-1 * var(--line-m)); border: var(--line-m) solid var(--color-accent, var(--magenta)); border-radius: var(--radius-full); - animation: ring 1.6s ease-out infinite; - } -} -@keyframes ring { - from { - opacity: 0.6; - transform: scale(1); - } - to { - opacity: 0; - transform: scale(1.6); } } .name { @@ -115,23 +102,13 @@ flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-xs); - font-size: var(--text-s); - color: var(--fg-2); } .slot { - display: inline-grid; justify-items: start; } -.slot > * { - grid-area: 1 / 1; -} -.slot > .hold { - visibility: hidden; -} .label { font-family: var(--font-ui); font-weight: 600; - white-space: nowrap; } .active .label { color: var(--color-accent, var(--magenta)); @@ -142,15 +119,9 @@ .failed .label { color: var(--red); } -.when { - white-space: nowrap; - font-variant-numeric: tabular-nums; -} .reason { grid-column: 2; grid-row: 3; contain: inline-size; - font-size: var(--text-s); - color: var(--fg-2); overflow-wrap: anywhere; } diff --git a/src/stage-timeline.ts b/src/stage-timeline.ts index dbdea62..a03cfaa 100644 --- a/src/stage-timeline.ts +++ b/src/stage-timeline.ts @@ -10,6 +10,8 @@ import { repeat } from "lit/directives/repeat.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; import { formatDateTime } from "@standards-lab/web-foundation/format.js"; import styles from "./stage-timeline.css" with { type: "css" }; @@ -72,7 +74,7 @@ function timeOf(stage: TimelineStage): Date | null { * wrapping to the timeline's width and never widening it. */ export class StageTimeline extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, motion, styles]; static properties = { stages: { attribute: false }, @@ -93,7 +95,7 @@ export class StageTimeline extends LitElement { glyph === nothing ? html`${stage.position}` : html`${glyph}` - }` : nothing}`; } @@ -107,15 +109,15 @@ export class StageTimeline extends LitElement { > ${this.#marker(stage)} ${stage.name} - - + + ${(Object.keys(labels) as StageState[]).map((state) => state === stage.state ? html`${labels[state]}` : html``, )} - + ${ date ? html` - ${reason === null ? nothing : html`${reason}`} + ${reason === null ? nothing : html`${reason}`} `; } render() { const stages = [...(this.stages ?? [])].sort((a, b) => a.position - b.position); - return html`
                + return html`
                  ${repeat( stages, (stage) => stage.name, diff --git a/src/upload-dropzone.css b/src/upload-dropzone.css index fda07d4..415ac45 100644 --- a/src/upload-dropzone.css +++ b/src/upload-dropzone.css @@ -1,9 +1,11 @@ /* From spike-html-apps-components (10dde51): src/upload-dropzone.css. */ /* - * The upload dropzone's shadow-root sheet: the dashed zone, its drag-over and disabled looks, - * and the list of uploads, each a name, a detail line, and a trailing label or cancel control. - * Unlayered, above the foundation's reset and elements sheets; it reads only the baseline tokens. + * The upload dropzone's shadow-root sheet: the dashed zone, its drag-over and disabled looks, the + * drag-over's change in the motion sheet's --duration-s, and the bare list of uploads, each a + * name, a detail line, and a trailing label or cancel control. + * Unlayered, above the foundation's reset, elements, utilities, and motion sheets; it reads only + * the baseline tokens. * See docs/layout.md */ @@ -31,8 +33,8 @@ @media (prefers-reduced-motion: no-preference) { .zone { transition: - border-color 120ms ease-out, - background-color 120ms ease-out; + border-color var(--duration-s) ease-out, + background-color var(--duration-s) ease-out; } } :host([disabled]) .zone { @@ -41,8 +43,6 @@ } .uploads { margin: var(--space-s) 0 0; - padding: 0; - list-style: none; } .upload { display: grid; @@ -51,14 +51,13 @@ "name end" "detail end"; align-items: center; - gap: calc(var(--line-m) + 2px + var(--space-3xs)) var(--space-s); - margin: 0; + gap: calc(var(--focus-reach) + var(--space-3xs)) var(--space-s); padding-block: var(--space-2xs); } .upload::before { content: ""; grid-area: name; - min-block-size: calc(1lh + 2 * var(--space-3xs) + 2 * var(--line-s)); + min-block-size: var(--control-block-size); font-family: var(--font-ui); line-height: var(--leading-ui); } @@ -72,9 +71,6 @@ } .name { grid-area: name; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } .end { grid-area: end; @@ -87,7 +83,6 @@ .state { font-size: var(--text-s); font-weight: 600; - white-space: nowrap; } .done .state { color: var(--green); @@ -105,8 +100,6 @@ align-items: center; gap: var(--space-xs); min-block-size: 1lh; - font-size: var(--text-s); - color: var(--fg-2); } progress { flex: 1 1 0; @@ -122,8 +115,6 @@ progress { } .bytes { flex: none; - white-space: nowrap; - font-variant-numeric: tabular-nums; } .sent { display: inline-block; diff --git a/src/upload-dropzone.ts b/src/upload-dropzone.ts index b0b1c40..d565b1d 100644 --- a/src/upload-dropzone.ts +++ b/src/upload-dropzone.ts @@ -10,6 +10,8 @@ import { repeat } from "lit/directives/repeat.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; +import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; +import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define, emit } from "@standards-lab/web-foundation/dom.js"; import { formatBytes } from "@standards-lab/web-foundation/format.js"; import styles from "./upload-dropzone.css" with { type: "css" }; @@ -66,7 +68,7 @@ function carriesFiles(event: DragEvent): boolean { * cancelled. */ export class UploadDropzone extends LitElement { - static styles = [reset, elements, styles]; + static styles = [reset, elements, utilities, motion, styles]; static properties = { uploads: { attribute: false }, @@ -155,18 +157,18 @@ export class UploadDropzone extends LitElement { > Cancel ` - : html`${finished[upload.state]}`; + : html`${finished[upload.state]}`; const sent = Math.min(Math.max(upload.sent, 0), upload.size); const detail = uploading ? html`${formatBytes(sent)} of ${size}` + >${formatBytes(sent)} of ${size}` : upload.state === "failed" && upload.message - ? html`${size}${upload.message}` - : html`${size}`; + ? html`${size}${upload.message}` + : html`${size}`; return html`
                1. - ${upload.name} + ${upload.name} ${end} - ${detail} + ${detail}
                2. `; } @@ -195,7 +197,7 @@ export class UploadDropzone extends LitElement {
${ uploads.length - ? html`
    + ? html`
      ${repeat( uploads, (upload) => upload.id, diff --git a/test/browser/components.test.ts b/test/browser/components.test.ts index 982b1e7..de273c0 100644 --- a/test/browser/components.test.ts +++ b/test/browser/components.test.ts @@ -132,7 +132,7 @@ describe("components", { timeout: 60_000 }, () => { assert.match(verdict, /^ok: /, verdict); }); - test(`each component adopts the foundation's reset and elements sheets, then its own, ${run.name}`, async () => { + test(`each component adopts the foundation's reset and elements sheets, then the opt-in sheets it uses, then its own, ${run.name}`, async () => { const page = await open(run); try { const { adopted, label }: { adopted: Record; label: string } = @@ -142,6 +142,14 @@ describe("components", { timeout: 60_000 }, () => { const foundation = "@standards-lab/web-foundation"; const reset = await sheet(foundation + "/baseline/reset.css"); const elements = await sheet(foundation + "/baseline/elements.css"); + const named = new Map([ + [reset, "reset"], + [elements, "elements"], + [await sheet(foundation + "/utilities.css"), "utilities"], + [await sheet(foundation + "/glyph-button.css"), "glyph-button"], + [await sheet(foundation + "/dialog.css"), "dialog"], + [await sheet(foundation + "/motion.css"), "motion"], + ]); const components = [ ["sl-drawer", "drawer", "drawer.css"], ["sl-document-list", "document-list", "document-list.css"], @@ -163,15 +171,23 @@ describe("components", { timeout: 60_000 }, () => { const element = document.body.appendChild(document.createElement(tag)); await element.updateComplete; adopted[tag] = element.shadowRoot.adoptedStyleSheets.map((s) => - s === reset ? "reset" : s === elements ? "elements" : s === ownSheet ? "own" : "other"); + s === ownSheet ? "own" : named.get(s) ?? "other"); } const badge = document.querySelector("sl-status-badge"); badge.label = "Draft"; await badge.updateComplete; return { adopted, label: badge.shadowRoot.querySelector("button").textContent }; })()`); + const base = ["reset", "elements"]; + const expected: Record = { + "sl-drawer": [...base, "utilities", "dialog", "motion", "own"], + "sl-stage-timeline": [...base, "utilities", "motion", "own"], + "sl-upload-dropzone": [...base, "utilities", "motion", "own"], + "sl-chat-thread": [...base, "utilities", "motion", "own"], + "sl-status-badge": [...base, "own"], + }; for (const tag of tags) { - assert.deepEqual(adopted[tag], ["reset", "elements", "own"], tag); + assert.deepEqual(adopted[tag], expected[tag] ?? [...base, "utilities", "own"], tag); } assert.equal(label, "Draft"); } finally { @@ -235,7 +251,7 @@ describe("components", { timeout: 60_000 }, () => { root.querySelector("button").click(); const meta = root.querySelector(".meta"); return { - parts: [...meta.children].map((part) => part.className || part.localName), + parts: [...meta.children].map((part) => part.classList[0] ?? part.localName), meta: meta.textContent.replace(/\\s+/g, " ").trim(), opened, }; @@ -571,9 +587,13 @@ describe("components", { timeout: 60_000 }, () => { } const LINES = `(element) => { - const range = document.createRange(); - range.selectNodeContents(element); - const rects = [...range.getClientRects()].filter((rect) => rect.width > 0); + const texts = document.createTreeWalker(element, NodeFilter.SHOW_TEXT); + const rects = []; + for (let text = texts.nextNode(); text; text = texts.nextNode()) { + const range = document.createRange(); + range.selectNodeContents(text); + rects.push(...[...range.getClientRects()].filter((rect) => rect.width > 0)); + } return new Set(rects.map((rect) => Math.round(rect.top))).size; }`; const ENTRIES = `(section) => [...document.querySelectorAll(section + " sl-entry")] @@ -598,7 +618,7 @@ describe("components", { timeout: 60_000 }, () => { return { name: entry.item.name, sizes: { name: size(".name"), status: size(".status"), meta: size(".meta") }, - first: first.className || first.localName, + first: first.classList[0] ?? first.localName, starts: [rect(root.querySelector(".name")).left, rect(first).left], under: rect(first).top >= rect(root.querySelector(".name")).bottom - 0.5, }; @@ -701,7 +721,7 @@ describe("components", { timeout: 60_000 }, () => { .flatMap((selector) => [...root.querySelectorAll(selector)]); return { name: entry.item.name, - parts: [...time.children].map((part) => part.className), + parts: [...time.children].map((part) => part.classList[0]), lines: values.map((value) => [value.textContent, (${LINES})(value)]), }; }) })`; @@ -1206,10 +1226,10 @@ describe("components", { timeout: 60_000 }, () => { "the active marker's border": is(style.borderTopColor), "the active marker's tint": style.backgroundColor === tint ? "accent" : style.backgroundColor, "the active marker's glyph": is(style.color), - "the active marker's ring": is(getComputedStyle(marker, "::after").borderTopColor), + "the active marker's ring": is(getComputedStyle(marker.querySelector(".ring")).borderTopColor), "the active label": is(getComputedStyle(timeline.querySelector(".active .label")).color), "the streaming dot": is(getComputedStyle( - root("sl-chat-thread").querySelector(".status.in_progress"), "::before").backgroundColor), + root("sl-chat-thread").querySelector(".status.in_progress > .dot")).backgroundColor), "the selected frame's border": is(getComputedStyle(framed).borderTopColor), "the selected frame's shadow": getComputedStyle(framed).boxShadow.includes(accent) ? "accent" : getComputedStyle(framed).boxShadow, @@ -1250,6 +1270,57 @@ describe("components", { timeout: 60_000 }, () => { } }); + test("the motion sheet runs the streaming dot's pulse and the active marker's ring inside their shadow roots, and the drag-over's change in its --duration-s; under reduced motion none of them", async () => { + const page = await browser.open(`${server.origin}/test/fixtures/components.html`); + try { + await page.evaluate(`window.verdict.then(async () => { + await Promise.all(["stage-timeline", "chat-thread", "upload-dropzone"] + .map((name) => import("/dist/" + name + ".js"))); + window.motion = async () => { + const subtree = document.createElement("div"); + subtree.append( + Object.assign(document.createElement("sl-stage-timeline"), { stages: [ + { name: "extraction", position: 1, state: "active", completedAt: null }, + ] }), + Object.assign(document.createElement("sl-chat-thread"), { items: [ + { type: "message", id: "m-1", role: "assistant", status: "in_progress", + content: [{ type: "output_text", text: "Reading" }] }, + ] }), + Object.assign(document.createElement("sl-upload-dropzone"), { uploads: [] }), + ); + document.querySelector("main").replaceChildren(subtree); + await Promise.all([...subtree.children].map((element) => element.updateComplete)); + const [timeline, thread, dropzone] = [...subtree.children].map((element) => element.shadowRoot); + const names = (element) => element.getAnimations().map((animation) => animation.animationName); + const zone = dropzone.querySelector(".zone"); + const durations = () => getComputedStyle(zone).transitionDuration; + const before = durations(); + dropzone.host.style.setProperty("--duration-s", "345ms"); + return { + ring: names(timeline.querySelector(".active .marker > .ring")), + dot: names(thread.querySelector(".status.in_progress > .dot")), + zone: [before, durations()], + }; + }; + })`); + const shown = (): Promise<{ ring: string[]; dot: string[]; zone: string[] }> => + page.evaluate(`window.motion()`); + await page.cdp("Emulation.setEmulatedMedia", { + features: [{ name: "prefers-reduced-motion", value: "no-preference" }], + }); + const moving = await shown(); + assert.deepEqual([moving.ring, moving.dot], [["ring"], ["pulse"]]); + assert.notEqual(moving.zone[0], "0s", "the motion sheet's --duration-s resolves"); + assert.equal(moving.zone[1], "0.345s, 0.345s", "the drag-over's change takes --duration-s"); + await page.cdp("Emulation.setEmulatedMedia", { + features: [{ name: "prefers-reduced-motion", value: "reduce" }], + }); + assert.deepEqual(await shown(), { ring: [], dot: [], zone: ["0s", "0s"] }); + } finally { + await page.close(); + } + }); + const VIEWERS = `(section) => [...document.querySelectorAll(section + " sl-artifact-viewer")]`; test("the artifact viewer's specimen renders every state, at full size or held, within 20rem, in every profile", async () => { @@ -1825,8 +1896,8 @@ describe("components", { timeout: 60_000 }, () => { .filter((part) => lines(part) > 1) .map((part) => part.textContent), identifiers: [...root.querySelectorAll(".event")].map((event, index) => ({ - texts: [...event.querySelectorAll("dd.cut")].map((dd) => dd.textContent), - titles: [...event.querySelectorAll("dd.cut")].map((dd) => dd.title), + texts: [...event.querySelectorAll("dd.text-truncate")].map((dd) => dd.textContent), + titles: [...event.querySelectorAll("dd.text-truncate")].map((dd) => dd.title), expected: [log.events[index].subject, log.events[index].id].filter(Boolean), })), scrolls: frame.scrollHeight > frame.clientHeight, @@ -1904,7 +1975,7 @@ describe("components", { timeout: 60_000 }, () => { width: box.width / rem, events: log.events.length, values: [...root.querySelectorAll(".event")].flatMap((event, index) => - [...event.querySelectorAll("dd.cut")].map((dd, at) => { + [...event.querySelectorAll("dd.text-truncate")].map((dd, at) => { const rect = dd.getBoundingClientRect(); return { expected: [log.events[index].subject, log.events[index].id].filter(Boolean)[at], diff --git a/test/browser/document-list.test.ts b/test/browser/document-list.test.ts index d70f299..ffc0e98 100644 --- a/test/browser/document-list.test.ts +++ b/test/browser/document-list.test.ts @@ -337,7 +337,7 @@ describe("document list", { timeout: 60_000 }, () => { await mount({ total: 0 }); const { state, status, statusSlot, summary, list, entries } = await read(); assert.equal(state, "ready"); - assert.deepEqual(status, ["status", "No documents.", "status ready"]); + assert.deepEqual(status, ["status", "No documents.", "status ready status-line"]); assert.deepEqual([summary, statusSlot], [null, ""]); assert.equal(list, null); assert.deepEqual(entries, []); @@ -362,7 +362,7 @@ describe("document list", { timeout: 60_000 }, () => { await mount({ state: "loading" }); let shown = await read(); assert.equal(shown.state, "loading"); - assert.deepEqual(shown.status, ["status", "Loading documents…", "status loading"]); + assert.deepEqual(shown.status, ["status", "Loading documents…", "status loading status-line"]); assert.equal(shown.statusSlot, "", "a first load has no summary to join"); assert.equal(shown.list, null); await mount({ ...paging, items: documents }); @@ -413,7 +413,7 @@ describe("document list", { timeout: 60_000 }, () => { assert.deepEqual(status, [ "status", "Couldn't load the documents. 503 Service Unavailable.", - "status error", + "status error status-line", ]); assert.equal(list, null); assert.deepEqual(entries, []); diff --git a/test/browser/drawer.test.ts b/test/browser/drawer.test.ts index 1606388..9da4891 100644 --- a/test/browser/drawer.test.ts +++ b/test/browser/drawer.test.ts @@ -889,6 +889,19 @@ describe("drawer", { timeout: 60_000 }, () => { await mount(NARROW); const motion = await running(); assert.ok(motion.transitions.includes("translate"), `transitions ${motion.transitions}`); + const durations = (duration: string) => new Set(duration.split(", ")); + assert.equal(durations(motion.duration).size, 1, `durations ${motion.duration}`); + assert.notEqual( + motion.duration.split(", ")[0], + "0s", + "the motion sheet's --duration-m resolves", + ); + await mount(NARROW, {}, "", HEIGHT, { attributes: 'style="--duration-m: 345ms"' }); + assert.deepEqual( + durations((await running()).duration), + new Set(["0.345s"]), + "the slide takes --duration-m", + ); await page.cdp("Emulation.setEmulatedMedia", { features: [{ name: "prefers-reduced-motion", value: "reduce" }], }); From cc33849ac666fcb1ca18a0944a21218e37b0fdd5 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 18:46:09 -0500 Subject: [PATCH 04/17] components-settings: the foundation's JSON formatter in place of json.js src/json.ts and its browser test go: the artifact viewer and the chat thread format JSON with @standards-lab/web-foundation/format.js's tryFormatJson, which the foundation tests. The viewer's local pretty() and Json type were tryFormatJson and FormattedJson already, the parse check and RangeError fallback included, so the viewer takes them as they are; the chat thread shows tryFormatJson's text when it parses and the raw text otherwise, as before. Behavior is unchanged. The components' own JSON cases and support/deep.ts stay, now checking the foundation's formatter through the views. README and docs/components.md drop the json module; docs/testing.md drops the notes on cases that lived only in json.test.ts. The pack test lists dist/ as built, so it needed no change. --- README.md | 1 - docs/components.md | 13 +-- docs/internals.md | 6 +- docs/testing.md | 7 -- src/artifact-viewer.ts | 30 ++---- src/chat-thread.ts | 10 +- src/json.ts | 140 -------------------------- test/browser/json.test.ts | 185 ----------------------------------- test/browser/support/deep.ts | 4 +- 9 files changed, 19 insertions(+), 377 deletions(-) delete mode 100644 src/json.ts delete mode 100644 test/browser/json.test.ts diff --git a/README.md b/README.md index a416f18..6788a90 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ the foundation's `page.css`: - `./drawer.js`: `sl-drawer`, its children docked inline on a wide viewport, in a modal drawer below. - `./markdown.js`: `markdown(source)`, a Markdown string as a Lit template of plain elements. -- `./json.js`: `formatJson(text)`, valid JSON text re-indented from its own tokens. - `./artifact-viewer.js`: `sl-artifact-viewer`, one artifact's content by its content type. - `./event-log.js`: `sl-event-log`, events as a log in the order given. - `./search-results.js`: `sl-search-results`, a search's matches under a status line. diff --git a/docs/components.md b/docs/components.md index 40ba50d..8b94c4b 100644 --- a/docs/components.md +++ b/docs/components.md @@ -48,13 +48,6 @@ the tests measure as they do. marked's lexer: raw HTML shows as text, an image as its alt text, and a link is an anchor only to an http, https, or mailto URL or a relative one. It is the one module that imports marked, which an import map then maps too. -- `./json.js`: `formatJson(text)`, valid JSON text re-indented from its own tokens, two spaces an - indent: its keys in their order, duplicates included, its number literals, and its strings with - their escapes as written, only the whitespace between tokens changed. Containers to `MAX_DEPTH`, - 64, deep are indented; one that would open deeper is kept as written on the line where it opens, - so the output's length stays linear in the text's at any depth. It never decides whether - the text is valid; its caller does, as the artifact viewer and the chat thread do with - `JSON.parse`. ## Inspection @@ -63,8 +56,8 @@ the tests measure as they do. and content type that `no-header` (`noHeader`) leaves out, for a page whose own header shows them. Every state, its content or its loading, error, invalid JSON, unsupported, or empty note, is in a region named ` content`, header or not. Valid JSON is formatted from its own - tokens by `./json.js`, never parsed and printed again, so it shows its own keys, their order, - and its numbers; JSON that doesn't parse shows as text under a note. `viewOf(contentType)` gives + tokens by the foundation's `format.js`, never parsed and printed again, so it shows its own + keys, their order, and its numbers; JSON that doesn't parse shows as text under a note. `viewOf(contentType)` gives a type's `view` and the `content` it takes, `text` or `blob`, so a consumer knows what to fetch. A text view is always safe, never a URL and never a document, so the viewer shows text whenever the content is text: "can't be shown" is left for bytes that aren't. The @@ -124,7 +117,7 @@ the tests measure as they do. labelled, and a streaming reply re-rendered in place; with `verbose`, reasoning, function calls, and their outputs too, each collapsed in a native details, a reasoning item's summary on its line and its content inside, and a call's arguments and its output that are valid JSON - formatted from their own tokens by `./json.js`. A thread its consumer holds + formatted from their own tokens by the foundation's `format.js`. A thread its consumer holds to a height scrolls inside, opening at its end and following the newest item only from its end or on a user's message; unheld, it is as tall as its content and follows nothing, so a consumer that wants it followed holds it. It exports its item types and sends no event. It imports diff --git a/docs/internals.md b/docs/internals.md index 8849d85..9eafe87 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -22,9 +22,9 @@ each sheet is laid out as it is. up to two pixels between, more where a device pixel is more than a CSS one, and within one CSS pixel the follow would stop by itself at a zoom of 0.9 or 1.1. A browser without `currentCSSZoom` is taken as unzoomed. -- Valid JSON is shown by `formatJson()` from its own tokens: `JSON.parse` decides validity alone and - its value is thrown away, since printing it would move integer-like keys first, rewrite numbers, - and drop duplicate keys. Text whose formatting would pass the longest string, a `RangeError`, +- Valid JSON is shown by the foundation's `tryFormatJson()`, formatted from its own tokens: + `JSON.parse` decides validity alone and its value is thrown away, since printing it would move + integer-like keys first, rewrite numbers, and drop duplicate keys. Text whose formatting would pass the longest string, a `RangeError`, shows as it is. ## Artifact viewer diff --git a/docs/testing.md b/docs/testing.md index 8b497d6..08711fe 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -91,13 +91,6 @@ the behavior and layout each one holds to. and drop the first duplicate, so these values show the output comes from the text's own tokens. - `test/browser/support/deep.ts` writes out the formatter's output for deep nesting rather than reading it from `formatJson`, so a test that compares a view with it checks the formatter too. -- The depth-65 case puts an opening brace in a key, an escaped quote before closing brackets, and an - escaped backslash before a string's real end, then at depth 64 a string holding the brackets that - would close it. A bracket count any of these fools ends the kept container early or late. -- The 20,000-deep case bounds the output at the text's length plus 4·64·64 characters: the 64 - formatted levels each add a line break and at most 128 spaces at their opening and closing - brackets, and the levels below are kept as written. Indenting every level would take some 800 - million spaces. ## Artifact viewer diff --git a/src/artifact-viewer.ts b/src/artifact-viewer.ts index ff173a7..afcca86 100644 --- a/src/artifact-viewer.ts +++ b/src/artifact-viewer.ts @@ -12,7 +12,7 @@ import elements from "@standards-lab/web-foundation/baseline/elements.css" with import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; -import { formatJson } from "./json.ts"; +import { type FormattedJson, tryFormatJson } from "@standards-lab/web-foundation/format.js"; import { markdown } from "./markdown.ts"; import styles from "./artifact-viewer.css" with { type: "css" }; @@ -129,28 +129,14 @@ async function textOf(blob: Blob): Promise { } } -type Json = { ok: true; text: string } | { ok: false; reason: string }; - -function pretty(content: string): Json { - try { - JSON.parse(content); - } catch (error) { - return { ok: false, reason: error instanceof Error ? error.message : String(error) }; - } - try { - return { ok: true, text: formatJson(content) }; - } catch { - return { ok: true, text: content }; - } -} - /** * Shows one artifact: a header of its name and content type over its content, or, with * `noHeader`, its content alone, for a page that already shows the name and type in a header of * its own. Markdown renders through `markdown()`; valid JSON is formatted from its own tokens by - * `formatJson()`, two spaces an indent, so its keys, their order, duplicates, numbers, and - * strings show as written, never parsed and printed again; and other text, text/html, XML, and - * SVG's source included, is shown as it is, never as a page and from no URL. JSON that doesn't + * the foundation's `formatJson()`, two spaces an indent, so its keys, their order, duplicates, + * numbers, and strings show as written, never parsed and printed again; and other text, + * text/html, XML, and SVG's source included, is shown as it is, never as a page and from no URL. + * JSON that doesn't * parse shows its raw text under a note saying so, and empty content a note saying so. Long * content scrolls inside the viewer, in a region the keyboard reaches. * @@ -198,7 +184,7 @@ export class ArtifactViewer extends LitElement { /** Leaves out the header, so the content shows alone; its region keeps its name. */ declare noHeader: boolean; - #json: Json | null = null; + #json: FormattedJson | null = null; #url = ""; #blob: Blob | null = null; #type = ""; @@ -230,7 +216,7 @@ export class ArtifactViewer extends LitElement { if (changed.has("content") || changed.has("contentType")) { const text = typeof this.content === "string" ? this.content : ""; const { view } = viewOf(this.contentType); - this.#json = view === "json" ? pretty(text) : null; + this.#json = view === "json" ? tryFormatJson(text) : null; if (view === "unknown" && this.content instanceof Blob) this.#readBlob(this.content); } this.#sync(); @@ -353,7 +339,7 @@ export class ArtifactViewer extends LitElement { case "markdown": return html`
      ${this.#region(markdown(content), true)}
      `; case "json": { - const json = this.#json ?? pretty(content); + const json = this.#json ?? tryFormatJson(content); if (json.ok) return html`
      ${this.#region(json.text)}
      `; return html`
      ${this.#note("invalid", "Invalid JSON, shown as text.", json.reason)} diff --git a/src/chat-thread.ts b/src/chat-thread.ts index 5ee74a8..31e4177 100644 --- a/src/chat-thread.ts +++ b/src/chat-thread.ts @@ -21,7 +21,7 @@ import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define } from "@standards-lab/web-foundation/dom.js"; -import { formatJson } from "./json.ts"; +import { tryFormatJson } from "@standards-lab/web-foundation/format.js"; import { markdown } from "./markdown.ts"; import styles from "./chat-thread.css" with { type: "css" }; @@ -103,12 +103,8 @@ export interface FunctionCallOutputItem { export type ThreadItem = MessageItem | ReasoningItem | FunctionCallItem | FunctionCallOutputItem; function pretty(text: string): string { - try { - JSON.parse(text); - return formatJson(text); - } catch { - return text; - } + const json = tryFormatJson(text); + return json.ok ? json.text : text; } const STATUS_LABELS: Partial> = { diff --git a/src/json.ts b/src/json.ts deleted file mode 100644 index 8b662c2..0000000 --- a/src/json.ts +++ /dev/null @@ -1,140 +0,0 @@ -// JSON formatted from its own tokens: the text is walked once, token by token, and each token is -// emitted exactly as written, with two-space indentation between them. Nothing is parsed into a -// value and printed again, so the keys keep their order, duplicates included, numbers keep their -// literals, and strings keep their escapes; only the whitespace between tokens changes. A -// container deeper than MAX_DEPTH is kept as written, whole, so no indent grows past MAX_DEPTH's, -// and the output's length stays linear in the text's however deep it nests. -// From spike-html-apps-components (10dde51): src/json.ts. - -const QUOTE = 0x22; -const COMMA = 0x2c; -const COLON = 0x3a; -const OPEN_BRACKET = 0x5b; -const BACKSLASH = 0x5c; -const CLOSE_BRACKET = 0x5d; -const OPEN_BRACE = 0x7b; -const CLOSE_BRACE = 0x7d; - -function indent(depth: number): string { - return " ".repeat(depth); -} - -function isSpace(code: number): boolean { - return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d; -} - -function endsValue(code: number): boolean { - return ( - isSpace(code) || - code === COMMA || - code === COLON || - code === CLOSE_BRACKET || - code === CLOSE_BRACE - ); -} - -/** - * The deepest container `formatJson` indents: the top-level object or array is depth 1, and a - * container that would open at depth `MAX_DEPTH + 1` is kept as written, its brackets, its tokens, - * and the whitespace between them, on the line where it opens. - */ -export const MAX_DEPTH = 64; - -/** - * Valid JSON text, re-indented: each member or element on its own line, two spaces an indent per - * depth, `": "` after each key, and an empty object or array as `{}` or `[]`. Every - * token, a string with its escapes, a number, `true`, `false`, or `null`, and each punctuation - * mark, appears as the text wrote it and in its order; whitespace outside strings is the only - * thing that changes. The text must be valid JSON, as `JSON.parse` accepts it: the walk reads - * tokens without checking their grammar, so it never decides whether the text is valid, and its - * output for text that isn't is unspecified. Containers to `MAX_DEPTH` deep are indented; one that - * would open deeper is kept as written, from its opening bracket to its matching closing one, on the - * line where it opens, and formatting resumes after it. Each token in the outer `MAX_DEPTH` levels - * adds at most a line break and an indent of `2 * MAX_DEPTH` spaces, so the output's length is - * linear in the text's, at any depth; only text whose output passes the longest string throws, a - * RangeError. - */ -export function formatJson(text: string): string { - const out: string[] = []; - const length = text.length; - let depth = 0; - let at = 0; - const skip = (from: number): number => { - while (from < length && isSpace(text.charCodeAt(from))) from++; - return from; - }; - const stringEnd = (from: number): number => { - let end = from + 1; - while (end < length) { - const inner = text.charCodeAt(end); - if (inner === BACKSLASH) end += 2; - else if (inner === QUOTE) break; - else end++; - } - return end; - }; - const containerEnd = (from: number): number => { - let open = 0; - let end = from; - while (end < length) { - const inner = text.charCodeAt(end); - if (inner === QUOTE) end = stringEnd(end); - else if (inner === OPEN_BRACE || inner === OPEN_BRACKET) open++; - else if ((inner === CLOSE_BRACE || inner === CLOSE_BRACKET) && --open === 0) return end + 1; - end++; - } - return length; - }; - while ((at = skip(at)) < length) { - const code = text.charCodeAt(at); - switch (code) { - case OPEN_BRACE: - case OPEN_BRACKET: { - if (depth === MAX_DEPTH) { - const end = containerEnd(at); - out.push(text.slice(at, end)); - at = end; - break; - } - const next = skip(at + 1); - const close = code === OPEN_BRACE ? CLOSE_BRACE : CLOSE_BRACKET; - if (text.charCodeAt(next) === close) { - out.push(code === OPEN_BRACE ? "{}" : "[]"); - at = next + 1; - } else { - depth++; - out.push(text[at], "\n", indent(depth)); - at++; - } - break; - } - case CLOSE_BRACE: - case CLOSE_BRACKET: - depth--; - out.push("\n", indent(depth), text[at]); - at++; - break; - case COMMA: - out.push(",\n", indent(depth)); - at++; - break; - case COLON: - out.push(": "); - at++; - break; - case QUOTE: { - const end = stringEnd(at); - out.push(text.slice(at, end + 1)); - at = end + 1; - break; - } - default: { - let end = at + 1; - while (end < length && !endsValue(text.charCodeAt(end))) end++; - out.push(text.slice(at, end)); - at = end; - } - } - } - return out.join(""); -} diff --git a/test/browser/json.test.ts b/test/browser/json.test.ts deleted file mode 100644 index 0ef6cef..0000000 --- a/test/browser/json.test.ts +++ /dev/null @@ -1,185 +0,0 @@ -// Adapted from spike-html-apps-components (10dde51): test/browser/json.test.ts, on @standards-lab/web-tooling. - -import assert from "node:assert/strict"; -import { after, before, describe, test } from "node:test"; - -import { launch } from "@standards-lab/web-tooling/browser.js"; -import type { Browser, Page } from "@standards-lab/web-tooling/browser.js"; -import { serve } from "@standards-lab/web-tooling/server.js"; -import type { Server } from "@standards-lab/web-tooling/server.js"; - -import { served } from "./support/served.ts"; - -const tokensOf = (text: string): string => - text.replace(/("(?:[^"\\]|\\.)*")|[ \t\n\r]+/g, (_, string?: string) => string ?? ""); - -describe("json", { timeout: 60_000 }, () => { - let server: Server; - let browser: Browser; - let page: Page; - before(async () => { - server = await serve(served); - browser = await launch(); - page = await browser.open(`${server.origin}/test/fixtures/components.html`); - await page.evaluate(`window.verdict.then(async () => { - window.formatJson = (await import("/dist/json.js")).formatJson; - })`); - }); - after(async () => { - await page?.close(); - await browser?.close(); - await server?.stop(); - }); - - const formatted = (text: string): Promise => - page.evaluate(`window.formatJson(${JSON.stringify(text)})`); - - const cases: Record = { - "keys in their order, integer-like keys where they stand": [ - '{"b":1,"10":2,"2":3,"a":4}', - '{\n "b": 1,\n "10": 2,\n "2": 3,\n "a": 4\n}', - ], - "number literals as written": [ - "[1.0,-0,1e3,1E-7,9007199254740993,0.10,-12.5e+02]", - "[\n 1.0,\n -0,\n 1e3,\n 1E-7,\n 9007199254740993,\n 0.10,\n -12.5e+02\n]", - ], - "duplicate keys, each kept": ['{"a":1,"a":2,"a":3}', '{\n "a": 1,\n "a": 2,\n "a": 3\n}'], - "strings with their escapes, byte for byte": [ - String.raw`{"q\"k":"say \"hi\"","path":"C:\\dir\\","e":"caf\u00e9 é","nl":"a\nb\/c","sp":" { [ , : ] } "}`, - String.raw`{ - "q\"k": "say \"hi\"", - "path": "C:\\dir\\", - "e": "caf\u00e9 é", - "nl": "a\nb\/c", - "sp": " { [ , : ] } " -}`, - ], - "minified text, indented two spaces a depth": [ - '{"id":"run-1","stages":[{"name":"classify","outputs":3,"ok":true,"err":null}],"done":false}', - '{\n "id": "run-1",\n "stages": [\n {\n "name": "classify",\n "outputs": 3,\n' + - ' "ok": true,\n "err": null\n }\n ],\n "done": false\n}', - ], - "oddly spaced text, normalized": [ - '\r\n { "a"\t:\n[ 1 ,\n\n 2 ] ,"b" :{ }\n, "c":[\t]} \n', - '{\n "a": [\n 1,\n 2\n ],\n "b": {},\n "c": []\n}', - ], - "nested empty objects and arrays": [ - '{"a":{},"b":[],"c":[{}, [ ], {"d":{ }}]}', - '{\n "a": {},\n "b": [],\n "c": [\n {},\n [],\n {\n "d": {}\n }\n ]\n}', - ], - "an empty object at the top": ["{ }", "{}"], - "an empty array at the top": ["[\n]", "[]"], - "a top-level array": [ - '[1,"two",[3],{"four":4}]', - '[\n 1,\n "two",\n [\n 3\n ],\n {\n "four": 4\n }\n]', - ], - "a top-level string": [' "a \\"b\\"" ', '"a \\"b\\""'], - "a top-level number": [" 1.50E+3 ", "1.50E+3"], - "a top-level literal": ["\nnull\n", "null"], - }; - for (const [kind, [text, expected]] of Object.entries(cases)) { - test(`formats ${kind}`, async () => { - const output = await formatted(text); - assert.equal(output, expected); - assert.equal(tokensOf(output), tokensOf(text), "only whitespace between tokens changed"); - }); - } - - test("changes only the whitespace between tokens, over a document of every kind", async () => { - const text = - ' { "z" : [ 1.0 , -0 , 1e3 , { "10" : "a\\u0000\\t b" , "2" : [ ] } ] , "z" : { "y" : ' + - 'true , "x" : false , "w" : null } , "\\ud83d\\ude00" : "😀" , "big" : 9007199254740993 } '; - const output = await formatted(text); - assert.equal(tokensOf(output), tokensOf(text)); - assert.ok(!/[ \t\r]\n|\n\n/.test(output), "no trailing space and no blank line"); - }); - - test("formats about 1 MB of JSON without a stall", async (t) => { - const timing: { bytes: number; lines: number; ms: number; same: boolean } = - await page.evaluate(`(() => { - const record = (i) => ({ - id: "run-" + i, "10": i, "2": -i * 1.5, note: "line \\"" + i + "\\"\\n\\u00e9", - stages: [{ name: "classify", outputs: [i, i + 1, i + 2], ok: true }, { name: "summarize", err: null }], - meta: {}, - }); - const text = JSON.stringify(Array.from({ length: 6000 }, (_, i) => record(i))); - window.formatJson(text); - const start = performance.now(); - const output = window.formatJson(text); - const ms = performance.now() - start; - return { - bytes: new TextEncoder().encode(text).length, - lines: output.split("\\n").length, - ms, - same: output.replace(/("(?:[^"\\\\]|\\\\.)*")|[ \\n]+/g, (_, s) => s ?? "") === text, - }; - })()`); - t.diagnostic(`${timing.bytes} bytes to ${timing.lines} lines in ${timing.ms.toFixed(1)} ms`); - assert.ok(timing.bytes > 900_000, `the document is ${timing.bytes} bytes`); - assert.ok(timing.same, "only whitespace between tokens changed"); - assert.ok(timing.ms < 250, `formatting took ${timing.ms} ms`); - }); - - const indent = (depth: number): string => " ".repeat(depth); - - test("formats every level of text nested 64 deep", async () => { - const text = "[".repeat(64) + "1" + "]".repeat(64); - const opening = Array.from({ length: 64 }, (_, depth) => `${indent(depth)}[`); - const closing = Array.from({ length: 64 }, (_, depth) => `${indent(63 - depth)}]`); - const expected = [...opening, `${indent(64)}1`, ...closing].join("\n"); - const output = await formatted(text); - assert.equal(output, expected); - assert.equal(tokensOf(output), tokensOf(text), "only whitespace between tokens changed"); - }); - - test("keeps a container that would open at depth 65 as written, on its line", async () => { - const inner = '[ 1 ,{"b" : "] }"} ,\t[ ] ]'; - const text = "[".repeat(63) + `{"a":${inner} , "c":3}` + "]".repeat(63); - const opening = Array.from({ length: 63 }, (_, depth) => `${indent(depth)}[`); - const closing = Array.from({ length: 63 }, (_, depth) => `${indent(62 - depth)}]`); - const object = [`${indent(63)}{`, `${indent(64)}"a": ${inner},`, `${indent(64)}"c": 3`]; - const expected = [...opening, ...object, `${indent(63)}}`, ...closing].join("\n"); - const output = await formatted(text); - assert.equal(output, expected); - assert.equal(tokensOf(output), tokensOf(text), "only whitespace between tokens changed"); - }); - - test("keeps a container at depth 65 whole when its strings hold quotes and brackets", async () => { - const kept = String.raw`{"{k\"": [ "\"]}", "\\", {"[" :"}]"} ] }`; - const after = String.raw`"]]}\"["`; - const text = "[".repeat(64) + `${kept},${after}` + "]".repeat(64); - const opening = Array.from({ length: 64 }, (_, depth) => `${indent(depth)}[`); - const closing = Array.from({ length: 64 }, (_, depth) => `${indent(63 - depth)}]`); - const inner = [`${indent(64)}${kept},`, `${indent(64)}${after}`]; - const output = await formatted(text); - assert.equal(output, [...opening, ...inner, ...closing].join("\n")); - assert.equal(tokensOf(output), tokensOf(text), "only whitespace between tokens changed"); - }); - - test("formats text nested 20,000 deep in output linear in its length, without a stall", async (t) => { - const result: { text: number; output: number; ms: number; same: boolean; tail: boolean } = - await page.evaluate(`(() => { - const text = "[".repeat(20000) + ' 1 ' + "]".repeat(20000); - window.formatJson(text); - const start = performance.now(); - const output = window.formatJson(text); - const ms = performance.now() - start; - const kept = "[".repeat(20000 - 64) + ' 1 ' + "]".repeat(20000 - 64); - return { - text: text.length, - output: output.length, - ms, - same: output.replace(/[ \\n]+/g, "") === text.replace(/ /g, ""), - tail: output.includes("\\n" + " ".repeat(64) + kept + "\\n"), - }; - })()`); - t.diagnostic(`${result.text} characters to ${result.output} in ${result.ms.toFixed(1)} ms`); - assert.ok( - result.output <= result.text + 4 * 64 * 64, - `${result.output} characters from ${result.text}`, - ); - assert.ok(result.same, "only whitespace between tokens changed"); - assert.ok(result.tail, "the levels past 64 kept as written, on their line"); - assert.ok(result.ms < 50, `formatting took ${result.ms} ms`); - }); -}); diff --git a/test/browser/support/deep.ts b/test/browser/support/deep.ts index 9cff7c2..6bccff9 100644 --- a/test/browser/support/deep.ts +++ b/test/browser/support/deep.ts @@ -1,5 +1,5 @@ -// The output formatJson owes text nested in arrays alone: the outer MAX_DEPTH levels indented, the -// levels below them kept as written. +// The output the foundation's formatJson owes text nested in arrays alone: the outer +// JSON_MAX_DEPTH levels indented, the levels below them kept as written. // From spike-html-apps-components (10dde51): test/browser/support/deep.ts. /** `"[".repeat(depth) + "1" + "]".repeat(depth)` as formatJson formats it. */ From ac315c14bb3302941e7da6be7f9d30fdeabcace2 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 18:53:37 -0500 Subject: [PATCH 05/17] components-settings: web-icons and sl-drawer's glyph Close sl-drawer's Close is a glyph button showing web-icons' octicon x-16, imported as its string module and rendered with lit's unsafeHTML, as spike-html-hosting-components (9fa5850) does. Its name, the close slot's text and the label, stays visually hidden and shows as a popover="hint" named by interestfor, on hover and keyboard focus; aria-description="" keeps the hint's text from also becoming the description. The drawer adopts the foundation's glyph-button.css after utilities, in the foundation's layer order (foundation.glyph before dialog and motion). @standards-lab/web-icons is a second peer at ^0.1.0, installed for development at github:standards-lab/web-icons#v0.1.0. The release rules check both peers alike; the test lists the two peers itself. The browser pages that load the drawer (components.html, profiles.html, the drawer demo) map the x-16 specifier onto the icons' dist/ module, and the server serves the icons under /deps/. The currency script already walks every github: devDependency and its peer range; its task text names the icons. The layer tree names webappgen directly: a Go CLI has no package name, so the layer-above case is a relative import into the sibling ../webappgen checkout, written beside the tree in the scratch workspace, drawing the layer table. web-icons joins the layers below: its package imports are allowed, and a relative path into its install is flagged as the foundation's is. --- STANDARDS.md | 2 +- demo/drawer.html | 3 +- docs/release.md | 11 +- eslint.config.js | 10 +- mise.toml | 2 +- package.json | 4 +- pnpm-lock.yaml | 14 ++ src/drawer.css | 4 +- src/drawer.ts | 53 ++++++-- test/browser/components.test.ts | 2 +- test/browser/drawer.test.ts | 119 +++++++++++++++-- test/browser/support/glyph-button.ts | 127 ++++++++++++++++++ test/browser/support/served.ts | 4 +- test/fixtures/components.html | 10 +- test/fixtures/profiles.html | 3 +- test/unit/layers-tree.ts | 42 +++++- test/unit/layers.test.ts | 12 +- test/unit/release.test.ts | 186 +++++++++++++++------------ test/unit/release.ts | 46 ++++--- 19 files changed, 502 insertions(+), 152 deletions(-) create mode 100644 test/browser/support/glyph-button.ts diff --git a/STANDARDS.md b/STANDARDS.md index 9091834..940075f 100644 --- a/STANDARDS.md +++ b/STANDARDS.md @@ -42,7 +42,7 @@ The architecture pages that apply, in the architecture repository: ## Package - The package is `@standards-lab/web-components`, the components layer of the web client stack, - built on `@standards-lab/web-foundation`, its one peer. + built on `@standards-lab/web-foundation` and `@standards-lab/web-icons`, its two peers. - lit and marked are each pinned exactly, and only the Markdown module imports marked (`test/unit/marked.test.ts` enforces it). - `dist/` lives only in a release tag's tree, the pack, never on a branch. diff --git a/demo/drawer.html b/demo/drawer.html index 4ade080..98f650e 100644 --- a/demo/drawer.html +++ b/demo/drawer.html @@ -18,7 +18,8 @@ "@lit/reactive-element": "/deps/@lit/reactive-element/reactive-element.js", "@lit/reactive-element/": "/deps/@lit/reactive-element/", "marked": "/deps/marked/lib/marked.esm.js", - "@standards-lab/web-foundation/": "/deps/@standards-lab/web-foundation/dist/" + "@standards-lab/web-foundation/": "/deps/@standards-lab/web-foundation/dist/", + "@standards-lab/web-icons/octicon/x-16": "/deps/@standards-lab/web-icons/dist/octicon/x-16.js" } } diff --git a/docs/release.md b/docs/release.md index 0ac3b8e..fe64807 100644 --- a/docs/release.md +++ b/docs/release.md @@ -36,7 +36,7 @@ the tag's tree to the pack, file for file; and creates the GitHub release from t - **CI** runs the check on each pull request to main and each push to it. `mise run install` first installs every pin `mise.toml` names, the chrome-headless-shell the browser tier runs in - included, and `node_modules`, the foundation and the tooling at their release tags. + included, and `node_modules`, the foundation, the icons, and the tooling at their release tags. - **Release** checks out every branch and tag, so the pack commit's parent and main are both at hand. The parent must be main's merge commit, so it has two parents of its own. The tagged tree must be the tarball's `package/`, file for file. The release action releases the tag its `ref` @@ -46,10 +46,11 @@ the tag's tree to the pack, file for file; and creates the GitHub release from t ## Dependencies `test/unit/release.ts` holds every release to its dependencies. lit and marked are its two -dependencies, each at one version, never a range. The foundation is a peer, by a caret range on its -versions, never a git spec, so a consumer declares it from whichever source; the -[README](../README.md#install) says why it is a peer. The repository's own install of it is a -devDependency at one release tag on GitHub, never a range, a branch, a commit, or a `#semver:` spec, +dependencies, each at one version, never a range. The foundation and the icons, +`@standards-lab/web-icons`, are its two peers, each by a caret range on its versions, never a git +spec, so a consumer declares each from whichever source; the [README](../README.md#install) says +why the foundation is a peer. The repository's own install of each is a devDependency at one +release tag on its own GitHub repository, never a range, a branch, a commit, or a `#semver:` spec, which bun fails, and a tag the peer range admits: the same leftmost nonzero part and no lower, so `^0.1.0` admits 0.1.x only. Which version, range, and tag is `package.json`'s, and `mise run currency` reports each behind its latest. The packed manifest carries no scripts, since diff --git a/eslint.config.js b/eslint.config.js index 1fe35cf..2dbf608 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -34,11 +34,13 @@ const cssImports = [ ]; const foundation = "@standards-lab/web-foundation"; -/** The layer table cut to the components: their sources, which may import themselves and three - * packages by name, lit, marked, and the foundation, which the manifest declares, the foundation as - * a peer; the foundation is reached only through its install, as a consumer reaches it. */ +const icons = "@standards-lab/web-icons"; +/** The layer table cut to the components: their sources, which may import themselves and four + * packages by name, lit, marked, the foundation, and the icons, which the manifest declares, the + * foundation and the icons as peers; each peer is reached only through its install, as a consumer + * reaches it. */ export const layers = [ - { name: "components", path: "src", may: ["components", "lit", "marked", foundation] }, + { name: "components", path: "src", may: ["components", "lit", "marked", foundation, icons] }, ]; const elements = layers.map(({ name, path }) => ({ diff --git a/mise.toml b/mise.toml index 8899956..132e598 100644 --- a/mise.toml +++ b/mise.toml @@ -105,6 +105,6 @@ raw = true run = "BROWSER_EXECUTABLE=$(mise which chrome-headless-shell) pnpm exec web-screenshots scripts/screenshots.config.ts" [tasks.currency] -description = "Report every mise tool, package.json pin, action pin, the foundation's and the tooling's tags, and the foundation's peer range behind its latest, a held pin with its reason, exiting nonzero if any isn't held; reads the network" +description = "Report every mise tool, package.json pin, action pin, the foundation's, the icons', and the tooling's tags, and the foundation's and the icons' peer ranges behind their latest, a held pin with its reason, exiting nonzero if any isn't held; reads the network" run = "scripts/currency.sh" quiet = true diff --git a/package.json b/package.json index ea8e481..5a8fb71 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,14 @@ "marked": "18.2.1" }, "peerDependencies": { - "@standards-lab/web-foundation": "^0.4.0" + "@standards-lab/web-foundation": "^0.4.0", + "@standards-lab/web-icons": "^0.1.0" }, "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "4.8.1", "@eslint/js": "10.0.1", "@standards-lab/web-foundation": "github:standards-lab/web-foundation#v0.4.0", + "@standards-lab/web-icons": "github:standards-lab/web-icons#v0.1.0", "@standards-lab/web-tooling": "github:standards-lab/web-tooling#v0.1.0", "@types/node": "26.6.6", "eslint": "10.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1588905..44f6e50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,6 +24,9 @@ importers: '@standards-lab/web-foundation': specifier: github:standards-lab/web-foundation#v0.4.0 version: https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f + '@standards-lab/web-icons': + specifier: github:standards-lab/web-icons#v0.1.0 + version: https://codeload.github.com/standards-lab/web-icons/tar.gz/499927708dcf386e0cff3de7ba84a10eaf19fa1a '@standards-lab/web-tooling': specifier: github:standards-lab/web-tooling#v0.1.0 version: https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794 @@ -162,6 +165,15 @@ packages: resolution: {gitHosted: true, integrity: sha512-XHEQUH+IRxncWqdaNLgRFjpF6f4Jc9WJWTh/7weKEbrjbha2nDgfj+pdwsKITbcuXOqqgqc2Dyx1lr/q7nlQsg==, tarball: https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f} version: 0.4.0 + '@standards-lab/web-icons@https://codeload.github.com/standards-lab/web-icons/tar.gz/499927708dcf386e0cff3de7ba84a10eaf19fa1a': + resolution: {gitHosted: true, integrity: sha512-oiiC6Qi9kuhp3arxvQt3zi4Y98DhRmIYGP2cA/W3TF4MyHYTWlFCGZ0wWIvmaK4NDTqsLdc5xfemPZin+ZP+dg==, tarball: https://codeload.github.com/standards-lab/web-icons/tar.gz/499927708dcf386e0cff3de7ba84a10eaf19fa1a} + version: 0.1.0 + peerDependencies: + vite: ^8.3.8 + peerDependenciesMeta: + vite: + optional: true + '@standards-lab/web-tooling@https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794': resolution: {gitHosted: true, integrity: sha512-D+0nTntEPlGCsjg82qXCVPb0INy38/uyiEbYbewQ+gq7pGSMMd9Mw1BDL2/VbuIQMI17cxXRKnnPZDrvP9eAyg==, tarball: https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794} version: 0.1.0 @@ -940,6 +952,8 @@ snapshots: '@standards-lab/web-foundation@https://codeload.github.com/standards-lab/web-foundation/tar.gz/67b3b6cd1a60dc4ce420039a2b584961f68d201f': {} + '@standards-lab/web-icons@https://codeload.github.com/standards-lab/web-icons/tar.gz/499927708dcf386e0cff3de7ba84a10eaf19fa1a': {} + '@standards-lab/web-tooling@https://codeload.github.com/standards-lab/web-tooling/tar.gz/24363f36750fe287250ac8b48310b6e02f22f794': {} '@types/esrecurse@4.3.1': {} diff --git a/src/drawer.css b/src/drawer.css index 15b9458..54b6ee0 100644 --- a/src/drawer.css +++ b/src/drawer.css @@ -4,8 +4,8 @@ * The drawer's shadow-root sheet: the docked aside's frame and the modal dialog covering the * viewport, each a dialog header over a scrolling body, and the dialog's slide, in the motion * sheet's --duration-m. - * Unlayered, above the foundation's reset, elements, utilities, dialog, and motion sheets; it reads - * only the baseline tokens. + * Unlayered, above the foundation's reset, elements, utilities, glyph-button, dialog, and motion + * sheets; it reads only the baseline tokens. * See docs/layout.md */ diff --git a/src/drawer.ts b/src/drawer.ts index cdbff42..dd97350 100644 --- a/src/drawer.ts +++ b/src/drawer.ts @@ -5,21 +5,28 @@ // swaps only the shadow root's wrapper and its slot, so the slotted content, the host's own // children, is never moved, disconnected, or re-created. // Adapted from spike-html-apps-components (10dde51): src/drawer.ts, on @standards-lab/web-foundation. +// Adapted from spike-html-hosting-components (9fa5850): src/drawer.ts, its Close a glyph button showing web-icons' x-16. // See docs/internals.md import { html, LitElement, type PropertyDeclarations, type PropertyValues } from "lit"; +import { unsafeHTML } from "lit/directives/unsafe-html.js"; import elements from "@standards-lab/web-foundation/baseline/elements.css" with { type: "css" }; import reset from "@standards-lab/web-foundation/baseline/reset.css" with { type: "css" }; import dialogSheet from "@standards-lab/web-foundation/dialog.css" with { type: "css" }; +import glyphButton from "@standards-lab/web-foundation/glyph-button.css" with { type: "css" }; import motion from "@standards-lab/web-foundation/motion.css" with { type: "css" }; import utilities from "@standards-lab/web-foundation/utilities.css" with { type: "css" }; import { define, emit } from "@standards-lab/web-foundation/dom.js"; +import x from "@standards-lab/web-icons/octicon/x-16"; import styles from "./drawer.css" with { type: "css" }; /** The tag the element defines. */ export const tagName = "sl-drawer"; +/** The Close button's text, before the label, unless the `close` slot replaces it. */ +const CLOSE = "Close"; + /** `open`'s detail: empty. */ export type OpenDetail = Record; @@ -39,11 +46,15 @@ export type CloseDetail = Record; * Below `dock` the drawer is closed until `show()`, `toggle()`, or `open` opens it, a * native dialog shown by `showModal()`: it covers the viewport edge to edge, sliding in from the * inline-start edge, the right in a right-to-left context, and the page behind it inert. Its - * header holds `label` as a visible `h2` that names the dialog, and a Close button whose accessible - * name adds the label, "Close Documents"; the button's visible text is the `close` slot's, "Close" - * by default, for a translation. As the dialog opens, focus moves to its heading, by the heading's - * `tabindex="-1"` and `autofocus`, not to the Close button; the heading, no control, shows no - * focus outline and is out of the Tab order, so Tab from it reaches the Close button. The header + * header holds `label` as a visible `h2` that names the dialog, and a Close button that shows + * web-icons' Octicons x-16 alone: its name is the `close` slot's text, "Close" by default, for a + * translation, then the label, "Close Documents", both visually hidden. It is a glyph button, laid + * out by the foundation's glyph-button.css, and shows its name on hover and keyboard focus in a + * hint popover, by `interestfor`, where the browser supports it, announced once as the name. As + * the dialog opens, focus moves to its heading, by the heading's `tabindex="-1"` and `autofocus`, + * not to the Close button, so the Close shows its hint only when tabbed to or hovered; the + * heading, no control, shows no focus outline and is out of the Tab order, so Tab from it reaches + * the Close button. The header * stays in view while the children scroll below it. The Close button, Escape, `close()`, * `toggle()`, or `open` set false closes it, and the dialog returns focus to the element that held * it when it opened. Under reduced motion it opens and closes at once. `open` in the markup, or @@ -61,7 +72,7 @@ export type CloseDetail = Record; * is the custom state `docked` or `drawer`, which a page may style. */ export class Drawer extends LitElement { - static styles = [reset, elements, utilities, dialogSheet, motion, styles]; + static styles = [reset, elements, utilities, glyphButton, dialogSheet, motion, styles]; static properties = { open: { type: Boolean, reflect: true }, @@ -181,6 +192,20 @@ export class Drawer extends LitElement { emit(this, "close", {}); } + #slotted = (): void => { + this.requestUpdate(); + }; + + #closeText(): string { + const assigned = [...this.children].filter((child) => child.slot === "close"); + if (assigned.length === 0) return CLOSE; + return assigned + .map((child) => child.textContent ?? "") + .join("") + .replace(/\s+/g, " ") + .trim(); + } + render() { if (!this.#narrow) { return html`
+ + + diff --git a/demo/glyphs.js b/demo/glyphs.js new file mode 100644 index 0000000..08a5497 --- /dev/null +++ b/demo/glyphs.js @@ -0,0 +1,15 @@ +// The demo pages' glyphs: each empty marker, ``, replaced as the +// module loads by the web-icons module's svg, as web-icons' iconFill() fills a Vite page's markers +// at build. The page's import map names each icon's module: question-16, gear-16, and x-16. + +import gear from "@standards-lab/web-icons/octicon/gear-16"; +import question from "@standards-lab/web-icons/octicon/question-16"; +import x from "@standards-lab/web-icons/octicon/x-16"; + +const icons = { "octicon/gear-16": gear, "octicon/question-16": question, "octicon/x-16": x }; + +for (const marker of document.querySelectorAll("svg[data-icon]")) { + const template = document.createElement("template"); + template.innerHTML = icons[marker.dataset.icon]; + marker.replaceWith(template.content); +} diff --git a/demo/settings.html b/demo/settings.html new file mode 100644 index 0000000..124d29b --- /dev/null +++ b/demo/settings.html @@ -0,0 +1,145 @@ + + + + + + settings specimen + + + + + + + + + + + + +
+ web-components +
+ + + + +
+
+
+

Settings

+

+ sl-settings, the reader's theme and keyboard settings, applied and stored at + once. Press S, or the header's Settings button, for it in the Settings dialog, + .dialog-wide; Close, or Esc, closes it. +

+ +
+

States

+
+
+ +
+

States at 20rem

+
+
+ +
+

Focus visible

+

The settings' first row, reached by the keyboard.

+ +
+
+
+ +
+

Keyboard shortcuts

+ + +
+ +
+ +
+

Settings

+ + +
+ +
+ + diff --git a/demo/shortcuts.html b/demo/shortcuts.html new file mode 100644 index 0000000..61510f3 --- /dev/null +++ b/demo/shortcuts.html @@ -0,0 +1,149 @@ + + + + + + shortcuts specimen + + + + + + + + + + + + +
+ web-components +
+ + + + +
+
+
+

Shortcuts

+

+ sl-shortcuts, the keyboard shortcuts of the dialog that holds it, as a table. + Press ?, or the header's Help button, for it in the Help dialog, + .dialog-fit; Close, or Esc, closes it. +

+ +
+

Bindings

+

The page's own bindings, besides the header's ? and S.

+

+ + + Back to the top +

+
+ +
+

States

+
+
+ +
+

States at 20rem

+
+
+
+ +
+

Keyboard shortcuts

+ + +
+ +
+ +
+

Settings

+ + +
+ +
+ + diff --git a/docs/components.md b/docs/components.md index d3b073f..b7e4fbe 100644 --- a/docs/components.md +++ b/docs/components.md @@ -172,15 +172,19 @@ the tests measure as they do. ## Demo `demo/components.html` puts the status badge, the entry, and the pagination on one page, with its -import map. Each component has a specimen page, `demo/.html`, for `status-badge`, `entry`, +import map, and the Settings and Help pattern in its header (README.md, "Settings and Help"), +which the settings and shortcuts pages carry too. `demo/glyphs.js` fills the pages' web-icons +markers. Each component has a specimen page, `demo/.html`, for `status-badge`, `entry`, `pagination`, `artifact-viewer`, `chat-thread`, `composer`, `upload-dropzone`, `stage-timeline`, -`event-log`, `search-results`, `document-list`, and `drawer`. A specimen page shows every state of +`event-log`, `search-results`, `document-list`, `drawer`, `settings`, and `shortcuts`. A specimen page shows every state of its component, labelled, then again in a section 20rem wide, and, for a component that holds a control, one instance reached by the keyboard to show its focus ring: the screenshot script focuses the focus section's `[data-focus-start]` mark, which takes focus only by script, then presses Tab as many times as the mark's value says, so `:focus-visible` matches. A page whose component draws its own frame drops the dashed one, so a capture shows the component's frame alone. The drawer's mode is the viewport's, so its page is an app's frame instead, its states the page's at two widths: docked -at 1280px, and closed, open, and open right to left at 480px. The specimen pages link the +at 1280px, and closed, open, and open right to left at 480px; its Outline drawer is `modal`, and +its captures open it at 1280px, then reach its Close by Tab. The settings and shortcuts captures add +each page's dialog, opened by its key. The specimen pages link the foundation's `page-full.css` and import its `register-full.js`, so a profile applies by its attribute on the root. diff --git a/docs/testing.md b/docs/testing.md index 08711fe..a9785e6 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -52,8 +52,11 @@ the behavior and layout each one holds to. out: it links only the lean entry, so it shows one profile. - Text in a fully transparent color shows nothing, as a hidden mark does, so it takes no color token. -- The stage timeline holds no control, so the focus ring cases skip it; a case pins that it renders - nothing focusable, so a control it gains must get a ring case. +- The stage timeline and the shortcuts list hold no control, so the focus ring cases skip their + pages; a case pins that each renders nothing focusable, so a control one gains must get a ring + case. +- `shortcut-dialogs.test.ts` runs on the demo pages that carry the Settings and Help pattern, so + the README's markup is held to working with the components. ## Components diff --git a/scripts/demo.js b/scripts/demo.js index 8873e81..cc66dea 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -22,6 +22,8 @@ for (const page of [ "search-results", "document-list", "drawer", + "settings", + "shortcuts", ]) { console.log(`${server.origin}/demo/${page}.html`); } diff --git a/scripts/screenshots.config.ts b/scripts/screenshots.config.ts index 88df0d6..4fe9257 100644 --- a/scripts/screenshots.config.ts +++ b/scripts/screenshots.config.ts @@ -1,6 +1,9 @@ // The capture description web-tooling's web-screenshots bin reads for mise run screenshots: each -// specimen page under demo/, whole in tiles, and the drawer's page in its viewport at a wide and a -// narrow width in four states; the palette, space, and type facets at the foundation's defaults; +// specimen page under demo/, whole in tiles; the drawer's page in its viewport at a wide and a +// narrow width in four states, and its modal drawer open at the wide width, then with its Close +// reached by Tab; the settings' page whole, then with the Settings dialog opened by S, wide and +// narrow, focus in its rows; the shortcuts' page whole, then with the Help dialog opened by ?, its +// Close reached by Tab; the palette, space, and type facets at the foundation's defaults; // --all's profiles; each page's registered profiles; and the repository served as the browser tier // serves it. // Adapted from spike-html-apps-components (10dde51): scripts/screenshots.config.ts, on web-tooling. @@ -33,6 +36,55 @@ const openedByEnter = })()`); }; +const tab: Step = async (page) => { + const key = { key: "Tab", code: "Tab", windowsVirtualKeyCode: 9 }; + await page.cdp("Input.dispatchKeyEvent", { type: "keyDown", ...key }); + await page.cdp("Input.dispatchKeyEvent", { type: "keyUp", ...key }); +}; + +const modalOpened = + (then?: Step): Step => + async (page) => { + await page.cdp("Emulation.setFocusEmulationEnabled", { enabled: true }); + await page.evaluate(`(async () => { + const drawer = document.querySelector("#outline"); + document.querySelector("#open-outline").click(); + await drawer.updateComplete; + const dialog = drawer.shadowRoot.querySelector("dialog"); + await Promise.all(dialog.getAnimations({ subtree: true }).map((a) => a.finished)); + })()`); + await then?.(page); + }; + +const pressed = + (key: "s" | "?", dialog: string, then?: Step): Step => + async (page) => { + await page.cdp("Emulation.setFocusEmulationEnabled", { enabled: true }); + const press = + key === "s" + ? { key: "s", code: "KeyS", windowsVirtualKeyCode: 83 } + : { key: "?", code: "Slash", windowsVirtualKeyCode: 191, modifiers: 8 }; + await page.cdp("Input.dispatchKeyEvent", { + type: "keyDown", + ...press, + text: key, + unmodifiedText: key, + }); + await page.cdp("Input.dispatchKeyEvent", { type: "keyUp", ...press }); + await page.evaluate(`(async () => { + const dialog = document.querySelector("${dialog}"); + while (!dialog.open) await new Promise((resolve) => requestAnimationFrame(resolve)); + const hosts = dialog.querySelectorAll("sl-settings, sl-shortcuts"); + await Promise.all([...hosts].map((host) => host.updateComplete)); + const settled = () => { + const active = document.activeElement; + return dialog.contains(active) && (!active.shadowRoot || active.shadowRoot.activeElement); + }; + while (!settled()) await new Promise((resolve) => requestAnimationFrame(resolve)); + })()`); + await then?.(page); + }; + const drawerStates: DescribedState[] = [ { name: "drawer-docked", @@ -60,6 +112,51 @@ const drawerStates: DescribedState[] = [ full: false, open: openedByEnter("rtl"), }, + { + name: "drawer-modal", + caption: "the modal drawer, open at 1280px", + viewport: docked, + full: false, + open: modalOpened(), + }, + { + name: "drawer-modal-close", + caption: "the modal drawer, open at 1280px, its Close reached by Tab", + viewport: docked, + full: false, + open: modalOpened(tab), + }, +]; + +const narrow = { width: 390, height: 844 }; + +const settingsStates: DescribedState[] = [ + { name: "settings", caption: "the settings", full: true }, + { + name: "settings-dialog", + caption: "the Settings dialog, opened by S", + viewport: docked, + full: false, + open: pressed("s", "#settings"), + }, + { + name: "settings-dialog-narrow", + caption: "the Settings dialog at 390px, opened by S", + viewport: narrow, + full: false, + open: pressed("s", "#settings"), + }, +]; + +const shortcutsStates: DescribedState[] = [ + { name: "shortcuts", caption: "the shortcuts", full: true }, + { + name: "shortcuts-dialog", + caption: "the Help dialog, opened by ?, then Tab to its Close", + viewport: docked, + full: false, + open: pressed("?", "#help", tab), + }, ]; const pages: DescribedPage[] = ( @@ -78,12 +175,26 @@ const pages: DescribedPage[] = ( ] satisfies [name: string, caption: string][] ) .map(([name, caption]): DescribedPage => ({ name, caption, path: `demo/${name}.html` })) - .concat({ - name: "drawer", - caption: "the drawer", - path: "demo/drawer.html", - states: drawerStates, - }); + .concat( + { + name: "drawer", + caption: "the drawer", + path: "demo/drawer.html", + states: drawerStates, + }, + { + name: "settings", + caption: "the settings", + path: "demo/settings.html", + states: settingsStates, + }, + { + name: "shortcuts", + caption: "the shortcuts", + path: "demo/shortcuts.html", + states: shortcutsStates, + }, + ); const REGISTRY = `(() => { const store = globalThis[Symbol.for("web-foundation.registry")] ?? {}; diff --git a/test/browser/shortcut-dialogs.test.ts b/test/browser/shortcut-dialogs.test.ts new file mode 100644 index 0000000..87d4132 --- /dev/null +++ b/test/browser/shortcut-dialogs.test.ts @@ -0,0 +1,212 @@ +import assert from "node:assert/strict"; +import { after, before, describe, test } from "node:test"; + +import { launch, until } from "@standards-lab/web-tooling/browser.js"; +import type { Browser, Page } from "@standards-lab/web-tooling/browser.js"; +import { serve } from "@standards-lab/web-tooling/server.js"; +import type { Server } from "@standards-lab/web-tooling/server.js"; +import gear from "@standards-lab/web-icons/octicon/gear-16"; +import question from "@standards-lab/web-icons/octicon/question-16"; +import x from "@standards-lab/web-icons/octicon/x-16"; + +import { glyphButton } from "./support/glyph-button.ts"; +import { served } from "./support/served.ts"; + +const PAGES = ["components", "settings", "shortcuts"]; + +const KEYS = { + s: { key: "s", code: "KeyS", windowsVirtualKeyCode: 83, text: "s" }, + "?": { key: "?", code: "Slash", windowsVirtualKeyCode: 191, modifiers: 8, text: "?" }, + Enter: { key: "Enter", code: "Enter", windowsVirtualKeyCode: 13, text: "\r" }, + Escape: { key: "Escape", code: "Escape", windowsVirtualKeyCode: 27 }, +}; + +async function press(page: Page, name: keyof typeof KEYS): Promise { + const { text, ...key } = { text: undefined, ...KEYS[name] }; + await page.cdp("Input.dispatchKeyEvent", { + type: text === undefined ? "rawKeyDown" : "keyDown", + ...key, + ...(text === undefined ? {} : { text, unmodifiedText: text }), + }); + await page.cdp("Input.dispatchKeyEvent", { type: "keyUp", ...key }); +} + +const DIALOGS = [ + { + id: "settings", + key: "s", + name: "Settings", + glyph: gear, + width: "dialog-wide", + holds: "sl-settings", + }, + { + id: "help", + key: "?", + name: "Help", + glyph: question, + width: "dialog-fit", + holds: "sl-shortcuts", + }, +] as const; + +type Dialog = (typeof DIALOGS)[number]; + +const opener = (dialog: Dialog): string => + `document.querySelector('[commandfor="${dialog.id}"][command="show-modal"]')`; +const closer = (dialog: Dialog): string => + `document.querySelector('#${dialog.id} > .dialog-header [commandfor="${dialog.id}"][command="close"]')`; + +/** The dialog's state, and where focus is: the focused element's id, or its tag. */ +const shown = ( + page: Page, + dialog: Dialog, +): Promise<{ open: boolean; modal: boolean; focus: string }> => + page.evaluate(`(() => { + const dialog = document.querySelector("#${dialog.id}"); + const active = document.activeElement; + return { + open: dialog.open, + modal: dialog.matches(":modal"), + focus: active === ${opener(dialog)} ? "opener" : active.id || active.localName, + }; + })()`); + +describe("the Settings and Help pattern on the demo pages", { timeout: 60_000 }, () => { + let server: Server; + let browser: Browser; + before(async () => { + server = await serve(served); + browser = await launch(); + }); + after(async () => { + await browser?.close(); + await server?.stop(); + }); + + async function open(name: string): Promise { + const page = await browser.open(`${server.origin}/demo/${name}.html`); + await page.cdp("Emulation.setFocusEmulationEnabled", { enabled: true }); + await page.evaluate(`Promise.all(["sl-settings", "sl-shortcuts"].map((tag) => + customElements.whenDefined(tag)))`); + return page; + } + + for (const name of PAGES) { + test(`the ${name} page's header holds the Help and Settings glyph buttons, each its web-icons glyph and its key, bound by data-keys`, async () => { + const page = await open(name); + try { + for (const dialog of DIALOGS) { + const button = await glyphButton(page, opener(dialog), dialog.glyph); + assert.deepEqual( + { + classed: button.classed, + glyphs: button.glyphs, + matches: button.matches, + hint: button.hint, + }, + { classed: true, glyphs: 1, matches: true, hint: dialog.name }, + dialog.name, + ); + const read: { + label: string | null; + keys: string | null; + kbd: string; + inActions: boolean; + } = await page.evaluate(`(() => { + const button = ${opener(dialog)}; + return { + label: button.getAttribute("aria-label"), + keys: button.dataset.keys ?? null, + kbd: button.querySelector("kbd")?.textContent ?? "", + inActions: button.closest("body > header .header-actions") !== null, + }; + })()`); + assert.deepEqual( + read, + { + label: dialog.name, + keys: dialog.key, + kbd: dialog.key.toUpperCase(), + inActions: true, + }, + dialog.name, + ); + } + } finally { + await page.close(); + } + }); + + test(`the ${name} page's dialogs: Settings wide holding sl-settings, Help fit holding sl-shortcuts, each headed by a Close glyph showing Esc`, async () => { + const page = await open(name); + try { + for (const dialog of DIALOGS) { + const read: { classes: string[]; holds: boolean; header: boolean; kbd: string } = + await page.evaluate(`(() => { + const dialog = document.querySelector("#${dialog.id}"); + const header = dialog.firstElementChild; + return { + classes: [...dialog.classList], + holds: dialog.querySelector("${dialog.holds}") !== null, + header: header.matches("header.dialog-header") && header.contains(${closer(dialog)}), + kbd: ${closer(dialog)}.querySelector("kbd").textContent, + }; + })()`); + assert.deepEqual( + read, + { classes: [dialog.width], holds: true, header: true, kbd: "Esc" }, + dialog.name, + ); + const close = await glyphButton(page, closer(dialog), x); + assert.deepEqual( + { classed: close.classed, matches: close.matches, hint: close.hint }, + { classed: true, matches: true, hint: "Close" }, + `${dialog.name}'s Close`, + ); + } + } finally { + await page.close(); + } + }); + + test(`on the ${name} page, S opens Settings and ? opens Help as modals, Escape closes each, and focus returns to the opener`, async () => { + const page = await open(name); + try { + for (const dialog of DIALOGS) { + await page.evaluate(`${opener(dialog)}.focus()`); + await press(page, dialog.key); + await until(page, `document.querySelector("#${dialog.id}").open`); + const opened = await shown(page, dialog); + assert.equal(opened.open && opened.modal, true, `${dialog.key} opens ${dialog.name}`); + assert.notEqual(opened.focus, "opener", `focus moves into ${dialog.name}`); + await press(page, "Escape"); + await until(page, `!document.querySelector("#${dialog.id}").open`); + assert.deepEqual( + await shown(page, dialog), + { open: false, modal: false, focus: "opener" }, + `Escape closes ${dialog.name}`, + ); + } + } finally { + await page.close(); + } + }); + + test(`on the ${name} page, each opener's Enter opens its dialog, its Close closes it, and focus returns to the opener`, async () => { + const page = await open(name); + try { + for (const dialog of DIALOGS) { + await page.evaluate(`${opener(dialog)}.focus()`); + await press(page, "Enter"); + await until(page, `document.querySelector("#${dialog.id}").open`); + await page.evaluate(`${closer(dialog)}.click()`); + await until(page, `!document.querySelector("#${dialog.id}").open`); + assert.equal((await shown(page, dialog)).focus, "opener", dialog.name); + } + } finally { + await page.close(); + } + }); + } +}); diff --git a/test/browser/themes.test.ts b/test/browser/themes.test.ts index 31ffaa3..4f11553 100644 --- a/test/browser/themes.test.ts +++ b/test/browser/themes.test.ts @@ -93,7 +93,7 @@ const READ = `async (choice) => { if (element.shadowRoot) walk(element.shadowRoot, path + " " + element.localName); if (root === document) continue; const shows = [...element.childNodes].some((node) => node.nodeType === Node.TEXT_NODE && node.data.trim()) - || (element.matches("input, textarea") && (element.value || element.placeholder)); + || (element.matches("textarea, input:not([type=radio], [type=checkbox])") && (element.value || element.placeholder)); if (!shows || element.getClientRects().length === 0) continue; const style = getComputedStyle(element); if (style.visibility !== "visible") continue; @@ -225,7 +225,9 @@ describe("themes", { timeout: 120_000 }, () => { for (let press = 0; press < presses; press++) await tab(page); } - for (const name of pages.filter((page) => page !== "stage-timeline")) { + const unfocusable = { "stage-timeline": "sl-stage-timeline", shortcuts: "sl-shortcuts" }; + + for (const name of pages.filter((page) => !Object.hasOwn(unfocusable, page))) { test(`the ${name} page's focus ring, brought by the keyboard, is the interaction color each color profile resolves, light and dark`, async () => { const page = await open(name); try { @@ -250,17 +252,25 @@ describe("themes", { timeout: 120_000 }, () => { }); } - test("the stage timeline, which the focus ring cases skip, renders nothing the keyboard can focus", async () => { - const page = await open("stage-timeline"); - try { - const focusable: string[] = - await page.evaluate(`[...document.querySelectorAll("sl-stage-timeline")] - .flatMap((timeline) => [...timeline.shadowRoot.querySelectorAll("*")]) - .filter((element) => element.tabIndex >= 0) - .map((element) => element.localName)`); - assert.deepEqual(focusable, []); - } finally { - await page.close(); - } - }); + for (const [name, tag] of Object.entries(unfocusable)) { + test(`the ${name} page's ${tag}, which the focus ring cases skip, renders nothing the keyboard can focus`, async () => { + const page = await open(name); + try { + const found: { hosts: number; focusable: string[] } = await page.evaluate(`(() => { + const hosts = [...document.querySelectorAll("${tag}")]; + return { + hosts: hosts.length, + focusable: hosts + .flatMap((host) => [...host.shadowRoot.querySelectorAll("*")]) + .filter((element) => element.tabIndex >= 0) + .map((element) => element.localName), + }; + })()`); + assert.ok(found.hosts > 0, `${name}: no ${tag} rendered`); + assert.deepEqual(found.focusable, []); + } finally { + await page.close(); + } + }); + } }); From 73e1c4c4315d23b7f3c781d32c9ade825d53c352 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:20:28 -0500 Subject: [PATCH 10/17] components-settings: release prep for v0.2.0 package.json's version is 0.2.0, and CHANGELOG.md gains its [0.2.0] section, dated 2026-11-22, breaking entries first: Removed (json.js) before Changed (peers, color tokens, the foundation's sheets and motion spans, sl-drawer's glyph Close), then the tooling bump, then Added (sl-settings, sl-shortcuts, sl-drawer's modal, the Settings and Help pattern). The link reference sits with [0.1.0]'s at the end. The README installs v0.2.0 with web-foundation v0.4.0 and web-icons v0.1.0, states both peer ranges, counts fourteen elements and no JSON formatter, and names the icons in the install and currency task lines. docs/development.md and docs/testing.md name the icons beside the foundation as a peer, a github: devDependency, and an install dist/ imports by name. The Provenance line's web-foundation v0.3.0 stays as the seed's history. --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ README.md | 29 +++++++++++++++-------------- docs/development.md | 10 +++++----- docs/testing.md | 4 ++-- package.json | 2 +- 5 files changed, 58 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b12307b..78cba05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,40 @@ All notable changes to `@standards-lab/web-components` are documented here. The [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2026-11-22 + +### Removed + +- **Breaking:** `./json.js`, with no re-export: import `formatJson` and `tryFormatJson` from the + foundation's `format.js`. + +### Changed + +- **Breaking:** the foundation peer is `@standards-lab/web-foundation` at `^0.4.0`, up from + `^0.3.0`, and `@standards-lab/web-icons` at `^0.1.0` is a second peer, whose glyphs the + components import by package name; a consumer declares both beside the components. +- **Breaking:** the components read the foundation's `--color-accent` and `--color-primary`, which + replace `--accent-color` and `--interaction-color`; a page that set the old names sets the new. +- **Breaking:** each shadow root adopts the foundation's utilities, glyph-button, dialog, and motion + sheets where it uses them, and `sl-settings` its meta and structure sheets, in place of the + components' own rules for the same, so the foundation's classes style the components' internals. + The chat thread's streaming dot and the stage timeline's running ring are spans carrying the + foundation's motion classes, no longer pseudo-elements. +- **Breaking:** `sl-drawer`'s Close is a glyph button showing web-icons' x-16; the `close` slot's + text, "Close" by default, is its name and its hint on hover and keyboard focus, no longer its + visible text. +- marathon 0.23.0 and mise-action v5.3.0, in the repository's tooling. + +### Added + +- `./settings.js`: `sl-settings`, the reader's theme and keyboard settings, applied and stored at + once. +- `./shortcuts.js`: `sl-shortcuts`, the keyboard shortcuts of the dialog that holds it, as a + plain-text table. +- `sl-drawer`'s `modal` attribute, which keeps the drawer modal at every width. +- The Settings and Help pattern, S and ? opening dialogs that hold `sl-settings` and + `sl-shortcuts`, in the README and the demo, with specimen pages for both. + ## [0.1.0] - 2026-11-18 ### Added @@ -39,4 +73,5 @@ All notable changes to `@standards-lab/web-components` are documented here. The - Releases by tag: each `v` tag marks a pack commit whose tree is the pack, the build included, and whose one parent is main's merge commit; its GitHub release carries the tarball. +[0.2.0]: https://github.com/standards-lab/web-components/releases/tag/v0.2.0 [0.1.0]: https://github.com/standards-lab/web-components/releases/tag/v0.1.0 diff --git a/README.md b/README.md index 2aa360b..0914b39 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,12 @@ # web-components -The Lit components of the standards-lab web client stack: twelve elements with a shadow root that -applications compose, their sheets, a Markdown renderer, and a JSON formatter. It is ES modules -with their type declarations and stylesheets, built on -[`@standards-lab/web-foundation`](https://github.com/standards-lab/web-foundation), which it takes -as a peer, and is released by git tag. A component takes properties and attributes, sends events, +The Lit components of the standards-lab web client stack: fourteen elements with a shadow root +that applications compose, their sheets, and a Markdown renderer. It is ES modules with their type +declarations and stylesheets, built on +[`@standards-lab/web-foundation`](https://github.com/standards-lab/web-foundation) with the glyphs +of [`@standards-lab/web-icons`](https://github.com/standards-lab/web-icons), which it takes as +peers, and is released by git tag. A component takes properties and attributes, sends events, and may hold its own UI state; it holds no services, fetches no data, and binds no key. ## Install @@ -16,18 +17,18 @@ Each release is a tag, `v`, of package as `pnpm pack` builds it: `package.json`, this README, the LICENSE, and `dist/`, the build. The build lives only in the tag's tree, so the tag installs with no build step, and its manifest has no scripts. It depends on lit 3.3.3 and marked 18.2.1, and takes the foundation as a peer at -`^0.3.0`: a consumer declares the foundation beside the components, and the one copy serves both, -so a restyle of the foundation's sheets by package name reaches the components' shadow roots too. -Install both by their tags: +`^0.4.0` and the icons at `^0.1.0`: a consumer declares each beside the components, and the one +copy serves both, so a restyle of the foundation's sheets by package name reaches the components' +shadow roots too. Install all three by their tags: ``` -pnpm add github:standards-lab/web-components#v0.1.0 github:standards-lab/web-foundation#v0.3.0 -bun add github:standards-lab/web-components#v0.1.0 github:standards-lab/web-foundation#v0.3.0 -npm install --allow-git=root github:standards-lab/web-components#v0.1.0 github:standards-lab/web-foundation#v0.3.0 +pnpm add github:standards-lab/web-components#v0.2.0 github:standards-lab/web-foundation#v0.4.0 github:standards-lab/web-icons#v0.1.0 +bun add github:standards-lab/web-components#v0.2.0 github:standards-lab/web-foundation#v0.4.0 github:standards-lab/web-icons#v0.1.0 +npm install --allow-git=root github:standards-lab/web-components#v0.2.0 github:standards-lab/web-foundation#v0.4.0 github:standards-lab/web-icons#v0.1.0 ``` npm 12 refuses git dependencies unless `--allow-git` allows them; `root` allows the ones the -project itself declares, which both packages are. Without the foundation declared, the install +project itself declares, which all three packages are. Without either peer declared, the install fails. Each GitHub release also carries the tarball. ### Safari @@ -173,7 +174,7 @@ focuses its first row. `demo/settings.html` and `demo/shortcuts.html` carry the Tasks run through [mise](https://mise.jdx.dev): ``` -mise run install # the pinned tools, and node_modules with the foundation and the tooling at their tags; reads the network +mise run install # the pinned tools, and node_modules with the foundation, the icons, and the tooling at their tags; reads the network mise run check # lint, lint-context, lint-references, types, build, and both test tiers; reads no network mise run build # src/ into dist/ mise run demo # serve the components demo page and the specimen pages on dist/ @@ -187,7 +188,7 @@ mise run screenshots --scheme dark # only the scheme named, light or dark mise run screenshots --output browser # a gallery of the captures, opened in the browser; directory keeps the files mise run screenshots --dir # write the captures into the directory named, with any of the above mise run screenshots --keep # keep the terminal output's captures, with any of the above -mise run currency # report every tool, package, and action pin, the foundation's and the tooling's tags, and the foundation's peer range, behind its latest; a held pin with its reason +mise run currency # report every tool, package, and action pin, the foundation's, the icons', and the tooling's tags, and both peer ranges, behind its latest; a held pin with its reason ``` `mise run screenshots` captures each specimen page light and dark, in vertical tiles at most diff --git a/docs/development.md b/docs/development.md index 3de6d13..a4561a8 100644 --- a/docs/development.md +++ b/docs/development.md @@ -37,8 +37,8 @@ build ships. `types:test` doesn't: the tests import nothing from `dist/`. ## pnpm -`pnpm-workspace.yaml` lists no packages: the repository is one package. The foundation, a peer, and -the tooling, each a `github:` devDependency installed at its release tag, need no setting there: +`pnpm-workspace.yaml` lists no packages: the repository is one package. The foundation and the icons, +the peers, and the tooling, each a `github:` devDependency installed at its release tag, need no setting there: pnpm guards only a git dependency below the top level (`blockExoticSubdeps`). - `allowBuilds` refuses unrs-resolver's postinstall. unrs-resolver, under eslint-plugin-import-x and @@ -52,9 +52,9 @@ pnpm guards only a git dependency below the top level (`blockExoticSubdeps`). ## Currency `scripts/currency.sh` reads mise's outdated report at the error log level: mise warns on every run -that a GitHub release has no assets. A `github:` devDependency, the foundation or the tooling, is +that a GitHub release has no assets. A `github:` devDependency, the foundation, the icons, or the tooling, is pinned to its repository's release tag, which the registry doesn't hold, so it is compared with that -repository's latest release. A peer, the foundation, is declared by a caret range, which must admit +repository's latest release. A peer, the foundation or the icons, is declared by a caret range, which must admit that latest release so a consumer can declare it beside the components, by the release test's own rule, `caretAdmits`. typescript is held to the newest version typescript-eslint's peer range accepts. A pin held back from its latest is named, with its reason, in `mise.toml`'s `HOLDS` list, @@ -94,7 +94,7 @@ The layer's import rules: - The rule judges the file an import resolves to, never the specifier's text, and `no-unresolved` fails a specifier that names no file, so no import passes by naming none. - `no-extraneous-dependencies` judges an import against `package.json`: a package name it doesn't - declare in dependencies or peerDependencies, where the foundation is (a devDependency alone ships + declare in dependencies or peerDependencies, where the foundation and the icons are (a devDependency alone ships nothing, and `includeInternal` holds the package's own name, which resolves inside it, to the same), in every import form (`includeTypes`). `no-relative-packages` refuses a relative path that reaches another package's files. diff --git a/docs/testing.md b/docs/testing.md index a9785e6..6ac6260 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -15,8 +15,8 @@ the behavior and layout each one holds to. the browser tier, `mise run demo`, and the screenshots description all serve, so the list is kept once. Of the served packages, lit's own dependencies (lit-html, lit-element, and `@lit/reactive-element`) sit beside it in pnpm's store and the server brings them with it; the - foundation is the install the components' `dist/` imports by name, reached as a consumer reaches - it. + foundation and the icons are the installs the components' `dist/` imports by name, reached as a + consumer reaches them. - `test/browser/support/types.js` is run by no page: tsc checks it with the in-page modules against the same `dist/`, so a declaration that narrows what a consumer may write fails `types:browser`. diff --git a/package.json b/package.json index 5a8fb71..4d32410 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@standards-lab/web-components", - "version": "0.1.0", + "version": "0.2.0", "license": "Apache-2.0", "type": "module", "files": [ From fcd68e6f8278bb0a424f51300005c21a498e4fbd Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:25:22 -0500 Subject: [PATCH 11/17] components-settings: standards review: comments.md's five kinds Drop the doc comments on unexported identifiers (drawer's CLOSE, the dialog test's shown, glyph-button's Described), the demo sheet's comment on an element selector, and settings.css's sentence excusing its literal lengths; rewrap the drawer's and the artifact viewer's broken doc comment lines. --- demo/demo.css | 2 -- src/artifact-viewer.ts | 5 ++--- src/drawer.ts | 12 +++++------- src/settings.css | 3 +-- test/browser/shortcut-dialogs.test.ts | 1 - test/browser/support/glyph-button.ts | 1 - 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/demo/demo.css b/demo/demo.css index c277c9d..b811470 100644 --- a/demo/demo.css +++ b/demo/demo.css @@ -10,8 +10,6 @@ padding-block: var(--space-l) var(--space-2xl); } - /* The header row over main, as wide: the page's name at the inline start, and the Help and - Settings glyph buttons, the layout sheet's .header-actions, at the inline end. */ body > header { display: flex; flex-wrap: wrap; diff --git a/src/artifact-viewer.ts b/src/artifact-viewer.ts index afcca86..3e4eca6 100644 --- a/src/artifact-viewer.ts +++ b/src/artifact-viewer.ts @@ -136,9 +136,8 @@ async function textOf(blob: Blob): Promise { * the foundation's `formatJson()`, two spaces an indent, so its keys, their order, duplicates, * numbers, and strings show as written, never parsed and printed again; and other text, * text/html, XML, and SVG's source included, is shown as it is, never as a page and from no URL. - * JSON that doesn't - * parse shows its raw text under a note saying so, and empty content a note saying so. Long - * content scrolls inside the viewer, in a region the keyboard reaches. + * JSON that doesn't parse shows its raw text under a note saying so, and empty content a note + * saying so. Long content scrolls inside the viewer, in a region the keyboard reaches. * * A PDF, an image, audio, or video shows from a Blob, natively: a PDF in an iframe, the browser's * own viewer, as tall as the viewer allows; an image no wider than the viewer and never past its diff --git a/src/drawer.ts b/src/drawer.ts index 996aed9..7774a96 100644 --- a/src/drawer.ts +++ b/src/drawer.ts @@ -25,7 +25,6 @@ import styles from "./drawer.css" with { type: "css" }; /** The tag the element defines. */ export const tagName = "sl-drawer"; -/** The Close button's text, before the label, unless the `close` slot replaces it. */ const CLOSE = "Close"; /** `open`'s detail: empty. */ @@ -55,12 +54,11 @@ export type CloseDetail = Record; * the dialog opens, focus moves to its heading, by the heading's `tabindex="-1"` and `autofocus`, * not to the Close button, so the Close shows its hint only when tabbed to or hovered; the * heading, no control, shows no focus outline and is out of the Tab order, so Tab from it reaches - * the Close button. The header - * stays in view while the children scroll below it. The Close button, Escape, `close()`, - * `toggle()`, or `open` set false closes it, and the dialog returns focus to the element that held - * it when it opened. Under reduced motion it opens and closes at once. `open` in the markup, or - * set before the element is connected, opens the drawer as the page loads below `dock`, sending - * `open`, and is undone while docked, sending nothing. + * the Close button. The header stays in view while the children scroll below it. The Close + * button, Escape, `close()`, `toggle()`, or `open` set false closes it, and the dialog returns + * focus to the element that held it when it opened. Under reduced motion it opens and closes at + * once. `open` in the markup, or set before the element is connected, opens the drawer as the page + * loads below `dock`, sending `open`, and is undone while docked, sending nothing. * * `open` and `close` go out each time the modal drawer opens or closes, however it was asked, * never on a switch between the modes. A switch, as the viewport crosses `dock`, closes an open diff --git a/src/settings.css b/src/settings.css index f54f830..133a3e8 100644 --- a/src/settings.css +++ b/src/settings.css @@ -9,8 +9,7 @@ * 48rem, above it below; .theme-menu-rows stacks the rows; .theme-menu-row is one ◀ value ▶ row, * its legend leading, its value in the code font, its other radios and every radio box hidden * visually, framed while a radio in it has visible focus; .theme-menu-preview is the card; - * .theme-menu-buttons lays out its buttons. Its fixed lengths are layout: the breakpoint, a value's - * width, and the hidden 1px box. + * .theme-menu-buttons lays out its buttons. * Unlayered, above the foundation's reset, elements, meta, structure, and utilities sheets; it * reads only the baseline tokens. */ diff --git a/test/browser/shortcut-dialogs.test.ts b/test/browser/shortcut-dialogs.test.ts index 87d4132..98ec0c5 100644 --- a/test/browser/shortcut-dialogs.test.ts +++ b/test/browser/shortcut-dialogs.test.ts @@ -57,7 +57,6 @@ const opener = (dialog: Dialog): string => const closer = (dialog: Dialog): string => `document.querySelector('#${dialog.id} > .dialog-header [commandfor="${dialog.id}"][command="close"]')`; -/** The dialog's state, and where focus is: the focused element's id, or its tag. */ const shown = ( page: Page, dialog: Dialog, diff --git a/test/browser/support/glyph-button.ts b/test/browser/support/glyph-button.ts index c6d4027..1b5e82c 100644 --- a/test/browser/support/glyph-button.ts +++ b/test/browser/support/glyph-button.ts @@ -72,7 +72,6 @@ export const glyphButton = (page: Page, button: string, markup: string): Promise }; })()`); -/** A node of the page's accessibility tree, with its name and description. */ interface Described { ignored: boolean; role?: { value: string }; From fcede2b57755ec2a77ab063048893d9c2d864a19 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:25:25 -0500 Subject: [PATCH 12/17] components-settings: standards review: consistency with the second peer and the motion spans Preflight looks for web-icons beside the foundation, as the build reads both, and docs/development.md says so; the stage timeline's ring span is hidden from assistive technology, as the chat thread's dot is. --- docs/development.md | 4 ++-- scripts/preflight.sh | 6 ++++-- src/stage-timeline.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/development.md b/docs/development.md index a4561a8..bd2dcf1 100644 --- a/docs/development.md +++ b/docs/development.md @@ -8,8 +8,8 @@ workflows. `mise.toml` pins every tool the tasks run, and no task installs a missing one: `task.run_auto_install` is off, and `mise run install` is the one task that reads the network. -The foundation is a peer, which the repository's devDependency installs at its tag, so -`scripts/preflight.sh` looks for it in `node_modules` beside lit and marked. +The foundation and the icons are peers, which the repository's devDependencies install at their +tags, so `scripts/preflight.sh` looks for each in `node_modules` beside lit and marked. Chrome for Testing publishes no checksums, so each chrome-headless-shell bump takes the sha256 and size from the download by hand. mise caches a download by its checksum, so a version bumped without diff --git a/scripts/preflight.sh b/scripts/preflight.sh index b8281e7..0ccd145 100755 --- a/scripts/preflight.sh +++ b/scripts/preflight.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Fails naming mise run install when a tool a task needs is missing: the node_modules tooling, the -# dependencies the build reads, lit, marked, and the foundation at its tag, and with `browser`, the -# pinned chrome-headless-shell. +# dependencies the build reads, lit, marked, and the foundation and the icons at their tags, and +# with `browser`, the pinned chrome-headless-shell. # See docs/development.md # Adapted from spike-html-apps-components (10dde51): scripts/preflight.sh, on web-foundation. set -euo pipefail @@ -20,6 +20,8 @@ require_node_modules() { [[ -f node_modules/marked/package.json ]] || fail "marked (dependencies)" [[ -f node_modules/@standards-lab/web-foundation/package.json ]] || fail "@standards-lab/web-foundation (devDependencies)" + [[ -f node_modules/@standards-lab/web-icons/package.json ]] || + fail "@standards-lab/web-icons (devDependencies)" } require_browser_at_pin() { diff --git a/src/stage-timeline.ts b/src/stage-timeline.ts index a03cfaa..b951896 100644 --- a/src/stage-timeline.ts +++ b/src/stage-timeline.ts @@ -95,7 +95,7 @@ export class StageTimeline extends LitElement { glyph === nothing ? html`${stage.position}` : html`${glyph}` - }${stage.state === "active" ? html`` : nothing}` : nothing}`; } From 56020c14899c61c59f034698ba050052f605f966 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:25:28 -0500 Subject: [PATCH 13/17] components-settings: standards review: tests at the seam, not restated constants The profiles case holds sl-shortcuts' note to the page's body font under each type, in place of asserting sans and mono agree; the note case checks its text against the claim, not the exported NOTE; and a shrink-to-fit case covers the note's containment, failing without it. --- test/browser/components.test.ts | 7 +++-- test/browser/shortcuts.test.ts | 46 +++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/test/browser/components.test.ts b/test/browser/components.test.ts index 612cb1a..b0d8523 100644 --- a/test/browser/components.test.ts +++ b/test/browser/components.test.ts @@ -382,7 +382,7 @@ describe("components", { timeout: 60_000 }, () => { tag: string; width: number; height: number; - look: { color: string; font: string; padding: number }; + look: { color: string; font: string; body: string; padding: number }; } test(`each component renders under each of the ${profiles.length} profile combinations`, async () => { @@ -510,6 +510,7 @@ describe("components", { timeout: 60_000 }, () => { const look = { color: style.color + " on " + style.backgroundColor, font: font.fontFamily, + body: getComputedStyle(document.body).fontFamily, padding: timeline ? parseFloat(getComputedStyle(element.shadowRoot.querySelector(".stage")).columnGap) : drawer @@ -560,7 +561,9 @@ describe("components", { timeout: 60_000 }, () => { (shown) => shown.scheme === scheme && shown.space === "compact", ); if (tag === "sl-shortcuts") { - assert.equal(sans.font, mono.font, `${tag}, ${scheme}: body text in either type`); + for (const look of [mono, sans]) { + assert.equal(look.font, look.body, `${tag}, ${scheme}: its note in the body font`); + } } else { assert.notEqual(sans.font, mono.font, `${tag}, ${scheme}: sans sets the font`); } diff --git a/test/browser/shortcuts.test.ts b/test/browser/shortcuts.test.ts index 6659cd2..9afe456 100644 --- a/test/browser/shortcuts.test.ts +++ b/test/browser/shortcuts.test.ts @@ -176,23 +176,53 @@ describe("shortcuts", { timeout: 60_000 }, () => { test("the screen-reader note follows the table, and the element holds no setting", async () => { await open(page); - const shown: { last: string; note: string; after: boolean; fields: number } = - await page.evaluate(`(async () => { - const { NOTE } = await import("/dist/shortcuts.js"); + const { note, ...shown }: { last: string; note: string; after: boolean; fields: number } = + await page.evaluate(`(() => { const note = ${SHADOW}.querySelector("p"); const table = ${SHADOW}.querySelector("table"); return { last: ${SHADOW}.lastElementChild.localName, - note: note.textContent.trim() === NOTE ? "NOTE" : note.textContent.trim(), + note: note.textContent.trim(), after: Boolean(table.compareDocumentPosition(note) & Node.DOCUMENT_POSITION_FOLLOWING), fields: ${SHADOW}.querySelectorAll("input, select, textarea, fieldset").length, }; })()`); - assert.deepEqual(shown, { last: "p", note: "NOTE", after: true, fields: 0 }); - assert.match( - await page.evaluate(`${SHADOW}.querySelector("p").textContent.trim()`), - /^Screen readers: .*NVDA.*VoiceOver\.$/, + assert.deepEqual(shown, { last: "p", after: true, fields: 0 }); + assert.match(note, /^Screen readers: .*NVDA.*VoiceOver\.$/); + await close(page); + }); + + test("in a shrink-to-fit parent the element is as wide as its table, or sixteen --space-base steps, the note wrapping within it", async () => { + await open(page); + const sized: { host: number; table: number; floor: number; note: number; lines: number } = + await page.evaluate(`(async () => { + const host = document.querySelector("sl-shortcuts"); + const parent = document.createElement("div"); + parent.style.inlineSize = "max-content"; + host.replaceWith(parent); + parent.append(host); + await host.updateComplete; + const note = ${SHADOW}.querySelector(".note"); + const lineHeight = parseFloat(getComputedStyle(note).lineHeight); + const probe = parent.appendChild(document.createElement("div")); + probe.style.inlineSize = "calc(var(--space-base) * 16)"; + const floor = probe.getBoundingClientRect().width; + probe.remove(); + return { + floor, + host: host.getBoundingClientRect().width, + table: ${SHADOW}.querySelector("table").getBoundingClientRect().width, + note: note.getBoundingClientRect().width, + lines: Math.round(note.getBoundingClientRect().height / lineHeight), + }; + })()`); + const wide = Math.max(sized.table, sized.floor); + assert.ok( + Math.abs(sized.host - wide) < 1, + `host ${sized.host}, table ${sized.table}, floor ${sized.floor}`, ); + assert.ok(sized.note <= wide + 0.5, `note ${sized.note}, host ${sized.host}`); + assert.ok(sized.lines > 1, `the note in ${sized.lines} line`); await close(page); }); From c78faa59d117a40f1210d28ba56e6684aea81edb Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:32:22 -0500 Subject: [PATCH 14/17] components-settings: spec review: captures show the Close hint The Tab states (drawer-modal-close, shortcuts-dialog) now wait, after Tab, until the focused control's interestfor hint matches :popover-open and its animations finish, rather than a fixed delay; the tab step becomes tabToHint. Their captions and the module header name the shown hint. --- scripts/screenshots.config.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/screenshots.config.ts b/scripts/screenshots.config.ts index 4fe9257..9b65cbb 100644 --- a/scripts/screenshots.config.ts +++ b/scripts/screenshots.config.ts @@ -1,11 +1,11 @@ // The capture description web-tooling's web-screenshots bin reads for mise run screenshots: each // specimen page under demo/, whole in tiles; the drawer's page in its viewport at a wide and a // narrow width in four states, and its modal drawer open at the wide width, then with its Close -// reached by Tab; the settings' page whole, then with the Settings dialog opened by S, wide and -// narrow, focus in its rows; the shortcuts' page whole, then with the Help dialog opened by ?, its -// Close reached by Tab; the palette, space, and type facets at the foundation's defaults; -// --all's profiles; each page's registered profiles; and the repository served as the browser tier -// serves it. +// reached by Tab and its hint shown; the settings' page whole, then with the Settings dialog opened +// by S, wide and narrow, focus in its rows; the shortcuts' page whole, then with the Help dialog +// opened by ?, its Close reached by Tab and its hint shown; the palette, space, and type facets at +// the foundation's defaults; --all's profiles; each page's registered profiles; and the repository +// served as the browser tier serves it. // Adapted from spike-html-apps-components (10dde51): scripts/screenshots.config.ts, on web-tooling. import type { @@ -36,10 +36,19 @@ const openedByEnter = })()`); }; -const tab: Step = async (page) => { +const tabToHint: Step = async (page) => { const key = { key: "Tab", code: "Tab", windowsVirtualKeyCode: 9 }; await page.cdp("Input.dispatchKeyEvent", { type: "keyDown", ...key }); await page.cdp("Input.dispatchKeyEvent", { type: "keyUp", ...key }); + await page.evaluate(`(async () => { + let active = document.activeElement; + while (active.shadowRoot?.activeElement) active = active.shadowRoot.activeElement; + const hint = active.getRootNode().getElementById(active.getAttribute("interestfor")); + while (!hint.matches(":popover-open")) { + await new Promise((resolve) => requestAnimationFrame(resolve)); + } + await Promise.all(hint.getAnimations().map((a) => a.finished)); + })()`); }; const modalOpened = @@ -121,10 +130,10 @@ const drawerStates: DescribedState[] = [ }, { name: "drawer-modal-close", - caption: "the modal drawer, open at 1280px, its Close reached by Tab", + caption: "the modal drawer, open at 1280px, its Close reached by Tab, its hint shown", viewport: docked, full: false, - open: modalOpened(tab), + open: modalOpened(tabToHint), }, ]; @@ -152,10 +161,10 @@ const shortcutsStates: DescribedState[] = [ { name: "shortcuts", caption: "the shortcuts", full: true }, { name: "shortcuts-dialog", - caption: "the Help dialog, opened by ?, then Tab to its Close", + caption: "the Help dialog, opened by ?, then Tab to its Close, its hint shown", viewport: docked, full: false, - open: pressed("?", "#help", tab), + open: pressed("?", "#help", tabToHint), }, ]; From 7e9b73227fec277b1511fb1abff06de397809ef0 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Sun, 22 Nov 2026 19:38:20 -0500 Subject: [PATCH 15/17] components-settings: editor pass --- CHANGELOG.md | 2 +- README.md | 35 ++++++++++++++++++----------------- context/README.md | 12 ++++++++---- docs/components.md | 43 ++++++++++++++++++++++--------------------- docs/development.md | 18 +++++++++--------- docs/internals.md | 4 ++-- docs/layout.md | 11 ++++++----- docs/release.md | 2 +- 8 files changed, 67 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78cba05..948cb4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ All notable changes to `@standards-lab/web-components` are documented here. The - **Breaking:** `sl-drawer`'s Close is a glyph button showing web-icons' x-16; the `close` slot's text, "Close" by default, is its name and its hint on hover and keyboard focus, no longer its visible text. -- marathon 0.23.0 and mise-action v5.3.0, in the repository's tooling. +- The repository's tooling takes marathon 0.23.0 and mise-action v5.3.0. ### Added diff --git a/README.md b/README.md index 0914b39..2d21e26 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ Each release is a tag, `v`, of package as `pnpm pack` builds it: `package.json`, this README, the LICENSE, and `dist/`, the build. The build lives only in the tag's tree, so the tag installs with no build step, and its manifest has no scripts. It depends on lit 3.3.3 and marked 18.2.1, and takes the foundation as a peer at -`^0.4.0` and the icons at `^0.1.0`: a consumer declares each beside the components, and the one -copy serves both, so a restyle of the foundation's sheets by package name reaches the components' -shadow roots too. Install all three by their tags: +`^0.4.0` and the icons at `^0.1.0`: a consumer declares each beside the components, so the page +and the components share one copy of each, and a restyle of the foundation's sheets by package +name reaches the components' shadow roots too. Install all three by their tags: ``` pnpm add github:standards-lab/web-components#v0.2.0 github:standards-lab/web-foundation#v0.4.0 github:standards-lab/web-icons#v0.1.0 @@ -28,8 +28,8 @@ npm install --allow-git=root github:standards-lab/web-components#v0.2.0 github:s ``` npm 12 refuses git dependencies unless `--allow-git` allows them; `root` allows the ones the -project itself declares, which all three packages are. Without either peer declared, the install -fails. Each GitHub release also carries the tarball. +project itself declares, which all three packages are. Leaving either peer undeclared fails the +install. Each GitHub release also carries the tarball. ### Safari @@ -41,9 +41,9 @@ package keeps the standard syntax, with no pack-time rewrite. The package is `@standards-lab/web-components`. Each module defines its element when it is imported, and the element's shadow root adopts the foundation's reset and elements sheets, then -the foundation's meta, structure, utilities, dialog, and motion sheets where it uses them, then its -own layout-only sheet. The modules import `lit` and the foundation by package name and their -sheets as CSS module scripts, so a page reaches them through an import map or a bundler, and links +the foundation's meta, structure, utilities, glyph-button, dialog, and motion sheets where it uses +them, then its own layout-only sheet. The modules import `lit`, the foundation, and the icons by +package name and their sheets as CSS module scripts, so a page reaches them through an import map or a bundler, and links the foundation's `page.css`: ```html @@ -78,14 +78,14 @@ documents each module in full, and its demo and specimen pages. ### Settings and Help -The components bind no key, so the page binds S and ? itself. The pattern, which -`demo/components.html` shows: two glyph buttons in the header's `.header-actions`, bound by -`data-keys` through the foundation's `keys.js`, each opening its dialog with `command="show-modal"`; -Help, a `.dialog-fit` holding `sl-shortcuts`, and Settings, a `.dialog-wide` holding `sl-settings`, -each headed by a `.dialog-header` whose Close shows the Esc hint. Close and Escape close either -with no script, and focus returns to the element that held it. The page links the foundation's -`glyph-button.css`, `dialog.css`, and `layout.css` after its entry, and the glyphs are web-icons' -markers, which `iconFill()` fills: +The components bind no key, so the page binds S and ? itself, as `demo/components.html` does. Two +glyph buttons in the header's `.header-actions` open the dialogs with `command="show-modal"`, and +the foundation's `keys.js` binds each to its key through `data-keys`. Help is a `.dialog-fit` +dialog holding `sl-shortcuts`, and Settings is a `.dialog-wide` dialog holding `sl-settings`; each +has a `.dialog-header` whose Close shows the Esc hint. Close and Escape close either dialog with no +script, and focus returns to the element that held it. The page links the foundation's +`glyph-button.css`, `dialog.css`, and `layout.css` after its entry, and web-icons' `iconFill()` +fills the glyphs' markers: ```html
@@ -192,7 +192,8 @@ mise run currency # report every tool, package, and acti ``` `mise run screenshots` captures each specimen page light and dark, in vertical tiles at most -1200px tall, and the drawer's in its viewport at each of its four states. It runs the +1200px tall; it captures the drawer's page in its viewport at each of its six states, and the +settings and shortcuts pages again with their dialogs open. It runs the `web-screenshots` bin of [web-tooling](https://github.com/standards-lab/web-tooling), the devDependency the browser tier's driver and server also come from, over the capture description `scripts/screenshots.config.ts`; `mise run screenshots -- --help` lists the flags with the pages diff --git a/context/README.md b/context/README.md index 3bc6705..0879b1c 100644 --- a/context/README.md +++ b/context/README.md @@ -1,7 +1,7 @@ # web-components context web-components is the set of Lit elements with a shadow root that applications compose, built on -web-foundation as a peer. A component takes properties and attributes, sends events, and may hold +web-foundation and web-icons as peers. A component takes properties and attributes, sends events, and may hold its own UI state; it holds no services, fetches no data, holds no application state, and never imports the SDK. An application's internal element becomes a component once a second application needs it. @@ -19,9 +19,10 @@ line; the workflows and CHANGELOG.md name theirs, web-foundation's at ceaab61. T line have their provenance here: - `package.json` is adapted from spike-html-apps-components (10dde51): package.json. It is renamed - `@standards-lab/web-components` at 0.1.0, takes `@standards-lab/web-foundation` as its peer, - and replaces the spike's foundation and tooling devDependencies with web-foundation's and - web-tooling's release tags; it pins marked and typescript-eslint exactly. + `@standards-lab/web-components` at 0.1.0, takes `@standards-lab/web-foundation` and + `@standards-lab/web-icons` as its peers, and replaces the spike's foundation and tooling + devDependencies with web-foundation's and web-tooling's release tags, adds web-icons' release + tag, and pins marked and typescript-eslint exactly. - `.prettierrc.json` is from spike-html-apps-components (10dde51): .prettierrc.json. - `LICENSE` is from spike-html-apps-components (10dde51): LICENSE, unchanged. - `pnpm-lock.yaml` is generated, not copied. @@ -38,3 +39,6 @@ line have their provenance here: list](../docs/components.md#inspection). - **Controls** (built): [the status badge, entry, pagination, and drawer](../docs/components.md#controls). +- **Settings and Help** (built): [the reader's settings and the keyboard shortcuts + list](../docs/components.md#controls), and [the page pattern that opens + them](../README.md#settings-and-help). diff --git a/docs/components.md b/docs/components.md index b7e4fbe..b214d89 100644 --- a/docs/components.md +++ b/docs/components.md @@ -32,17 +32,18 @@ the tests measure as they do. closed until `show()`, `toggle()`, or `open` opens it, `open` in the markup as the page loads too, covering the viewport and sliding in from the inline-start edge; docked, `open` in the markup is reverted to false. Its header holds `label` as an `h2` that names the dialog, staying - in view while the content scrolls, and a Close button named "Close" and the label, its text - replaceable through the `close` slot for a translation. As it opens, focus lands on its heading, + in view while the content scrolls, and a Close button, a glyph button showing web-icons' x-16, + named "Close" and the label, a name it shows as a hint on hover and keyboard focus; the `close` + slot replaces "Close" for a translation. As it opens, focus lands on its heading, `tabindex="-1"` and `autofocus`, not on the Close button; the heading shows no focus outline and is out of the Tab order, so Tab from it reaches the Close button. The Close button, Escape, `close()`, or `toggle()` closes it, and focus returns to what opened it. It dispatches `open` and `close` as the modal drawer opens and closes, never as the viewport crosses `dock`, which swaps only the wrapper, so the slotted content is never moved, disconnected, or re-created: an open drawer docks, and docked content becomes a closed drawer. It slides only when the reader - allows motion. `modal`, a reflected boolean, makes it the modal dialog at every width, `dock` - ignored; setting or removing it is a switch too, closing an open drawer silently. Its mode is the - custom state `docked` or `drawer`, which a page may style. + allows motion. `modal`, a reflected boolean, makes it the modal dialog at every width, ignoring + `dock`; setting or removing it is a switch too, so it closes an open drawer silently. Its mode is + the custom state `docked` or `drawer`, which a page may style. - `./shortcuts.js`: `sl-shortcuts`, the page's keyboard shortcuts for a help dialog, as a plain-text table of Keys and Action: exactly what the foundation's `bindings(dialog)` gives for the dialog that holds it, `bindings(null)` outside one, in its order, each key in a `kbd` as the keys @@ -81,8 +82,8 @@ the tests measure as they do. them. Every state, its content or its loading, error, invalid JSON, unsupported, or empty note, is in a region named ` content`, header or not. Valid JSON is formatted from its own tokens by the foundation's `format.js`, never parsed and printed again, so it shows its own - keys, their order, and its numbers; JSON that doesn't parse shows as text under a note. `viewOf(contentType)` gives - a type's `view` and the `content` it takes, `text` or `blob`, so a consumer knows what to + keys, their order, and its numbers; JSON that doesn't parse shows as text under a note. + `viewOf(contentType)` gives a type's `view` and the `content` it takes, `text` or `blob`, so a consumer knows what to fetch. A text view is always safe, never a URL and never a document, so the viewer shows text whenever the content is text: "can't be shown" is left for bytes that aren't. The `content-type` decides the view, never a Blob's own type, and the Blob's bytes are shown as @@ -172,19 +173,19 @@ the tests measure as they do. ## Demo `demo/components.html` puts the status badge, the entry, and the pagination on one page, with its -import map, and the Settings and Help pattern in its header (README.md, "Settings and Help"), -which the settings and shortcuts pages carry too. `demo/glyphs.js` fills the pages' web-icons -markers. Each component has a specimen page, `demo/.html`, for `status-badge`, `entry`, -`pagination`, `artifact-viewer`, `chat-thread`, `composer`, `upload-dropzone`, `stage-timeline`, -`event-log`, `search-results`, `document-list`, `drawer`, `settings`, and `shortcuts`. A specimen page shows every state of -its component, labelled, then again in a section 20rem wide, and, for a component that holds a -control, one instance reached by the keyboard to show its focus ring: the screenshot script focuses -the focus section's `[data-focus-start]` mark, which takes focus only by script, then presses Tab as -many times as the mark's value says, so `:focus-visible` matches. A page whose component draws its -own frame drops the dashed one, so a capture shows the component's frame alone. The drawer's mode is -the viewport's, so its page is an app's frame instead, its states the page's at two widths: docked -at 1280px, and closed, open, and open right to left at 480px; its Outline drawer is `modal`, and -its captures open it at 1280px, then reach its Close by Tab. The settings and shortcuts captures add -each page's dialog, opened by its key. The specimen pages link the +import map, and the [Settings and Help pattern](../README.md#settings-and-help) in its header, which +the settings and shortcuts pages carry too. `demo/glyphs.js` fills the pages' web-icons markers. +Each component has a specimen page, `demo/.html`, for `status-badge`, `entry`, `pagination`, +`artifact-viewer`, `chat-thread`, `composer`, `upload-dropzone`, `stage-timeline`, `event-log`, +`search-results`, `document-list`, `drawer`, `settings`, and `shortcuts`. A specimen page shows +every state of its component, labelled, then again in a section 20rem wide, and, for a component +that holds a control, one instance reached by the keyboard to show its focus ring: the screenshot +script focuses the focus section's `[data-focus-start]` mark, which takes focus only by script, then +presses Tab as many times as the mark's value says, so `:focus-visible` matches. A page whose +component draws its own frame drops the dashed one, so a capture shows the component's frame alone. +The drawer's mode is the viewport's, so its page is an app's frame instead, its states the page's at +two widths: docked at 1280px, and closed, open, and open right to left at 480px. Its Outline drawer +is `modal`, and its captures open it at 1280px, then reach its Close by Tab. The settings and +shortcuts captures add each page's dialog, opened by its key. The specimen pages link the foundation's `page-full.css` and import its `register-full.js`, so a profile applies by its attribute on the root. diff --git a/docs/development.md b/docs/development.md index bd2dcf1..8ab1e50 100644 --- a/docs/development.md +++ b/docs/development.md @@ -37,9 +37,9 @@ build ships. `types:test` doesn't: the tests import nothing from `dist/`. ## pnpm -`pnpm-workspace.yaml` lists no packages: the repository is one package. The foundation and the icons, -the peers, and the tooling, each a `github:` devDependency installed at its release tag, need no setting there: -pnpm guards only a git dependency below the top level (`blockExoticSubdeps`). +`pnpm-workspace.yaml` lists no packages: the repository is one package. The peers, the foundation +and the icons, and the tooling are each a `github:` devDependency installed at its release tag, and +need no setting there: pnpm guards only a git dependency below the top level (`blockExoticSubdeps`). - `allowBuilds` refuses unrs-resolver's postinstall. unrs-resolver, under eslint-plugin-import-x and eslint-import-resolver-typescript, fetches its native binding when the optional dependency @@ -52,10 +52,10 @@ pnpm guards only a git dependency below the top level (`blockExoticSubdeps`). ## Currency `scripts/currency.sh` reads mise's outdated report at the error log level: mise warns on every run -that a GitHub release has no assets. A `github:` devDependency, the foundation, the icons, or the tooling, is -pinned to its repository's release tag, which the registry doesn't hold, so it is compared with that -repository's latest release. A peer, the foundation or the icons, is declared by a caret range, which must admit -that latest release so a consumer can declare it beside the components, by the release test's own +that a GitHub release has no assets. A `github:` devDependency, the foundation, the icons, or the +tooling, is pinned to its repository's release tag, which the registry doesn't hold, so it is +compared with that repository's latest release. A peer, the foundation or the icons, is declared by +a caret range, which must admit that latest release so a consumer can declare it beside the components, by the release test's own rule, `caretAdmits`. typescript is held to the newest version typescript-eslint's peer range accepts. A pin held back from its latest is named, with its reason, in `mise.toml`'s `HOLDS` list, in the format `scripts/currency.sh` gives. Each action a workflow uses is compared with its @@ -94,8 +94,8 @@ The layer's import rules: - The rule judges the file an import resolves to, never the specifier's text, and `no-unresolved` fails a specifier that names no file, so no import passes by naming none. - `no-extraneous-dependencies` judges an import against `package.json`: a package name it doesn't - declare in dependencies or peerDependencies, where the foundation and the icons are (a devDependency alone ships - nothing, and `includeInternal` holds the package's own name, which resolves inside it, to the + declare in dependencies or peerDependencies, where the foundation and the icons are (a + devDependency alone ships nothing, and `includeInternal` holds the package's own name, which resolves inside it, to the same), in every import form (`includeTypes`). `no-relative-packages` refuses a relative path that reaches another package's files. diff --git a/docs/internals.md b/docs/internals.md index 9eafe87..2c3afef 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -24,8 +24,8 @@ each sheet is laid out as it is. is taken as unzoomed. - Valid JSON is shown by the foundation's `tryFormatJson()`, formatted from its own tokens: `JSON.parse` decides validity alone and its value is thrown away, since printing it would move - integer-like keys first, rewrite numbers, and drop duplicate keys. Text whose formatting would pass the longest string, a `RangeError`, - shows as it is. + integer-like keys first, rewrite numbers, and drop duplicate keys. Text whose formatting would + pass the longest string, a `RangeError`, shows as it is. ## Artifact viewer diff --git a/docs/layout.md b/docs/layout.md index 7f9452a..2975bf7 100644 --- a/docs/layout.md +++ b/docs/layout.md @@ -9,11 +9,12 @@ layout each one promises. - Each component adopts its sheet into its shadow root after the foundation's `baseline/reset.css` and `baseline/elements.css`, which give the native controls, the pre, the rendered Markdown, the details and summary, and the focus outline their look. Between those and its own, it adopts the - foundation's opt-in sheets whose classes it uses: `utilities.css` (every component but the status - badge), `dialog.css` (the drawer's header row), and `motion.css` (the drawer's slide, the - dropzone's drag-over change, the chat thread's pulse, and the stage timeline's ring). Its own - sheet is unlayered, so it sits above all of them, and it gives a native control no look of its own - beyond its layout. + foundation's sheets whose classes it uses: `utilities.css` (every component but the status + badge), `glyph-button.css` (the drawer's Close), `dialog.css` (the drawer's header row), + `motion.css` (the drawer's slide, the dropzone's drag-over change, the chat thread's pulse, and + the stage timeline's ring), and `meta.css` and `structure.css` (the settings' preview card). Its + own sheet is unlayered, so it sits above all of them, and it gives a native control no look of + its own beyond its layout. - A sheet reads only the foundation's baseline tokens, which a shadow root inherits from the page's entry. A component in progress takes `--color-accent`, the foundation's hook for what is current or in progress, falling back to `--magenta`; an interaction takes `--color-primary`, falling diff --git a/docs/release.md b/docs/release.md index fe64807..e84915a 100644 --- a/docs/release.md +++ b/docs/release.md @@ -49,7 +49,7 @@ the tag's tree to the pack, file for file; and creates the GitHub release from t dependencies, each at one version, never a range. The foundation and the icons, `@standards-lab/web-icons`, are its two peers, each by a caret range on its versions, never a git spec, so a consumer declares each from whichever source; the [README](../README.md#install) says -why the foundation is a peer. The repository's own install of each is a devDependency at one +why each is a peer. The repository's own install of each is a devDependency at one release tag on its own GitHub repository, never a range, a branch, a commit, or a `#semver:` spec, which bun fails, and a tag the peer range admits: the same leftmost nonzero part and no lower, so `^0.1.0` admits 0.1.x only. Which version, range, and tag is `package.json`'s, and From 1dcaf99b82bae63edabbe8143d131adf288f2ba4 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Mon, 23 Nov 2026 05:57:47 -0500 Subject: [PATCH 16/17] components-settings: redirect: sl-settings lays out by its own width The theme section's body was two columns by a viewport media query (width >= 48rem), inherited from the theme-menu dialog; in a narrow box in a wide viewport the preview card overlapped the rows and overflowed the host. Decisions: - An intrinsic wrap, no query: .theme-menu-body is a wrapping flex row, the rows flex 2 1 0 and the preview flex 3 1 0, each held at its min-content by the automatic minimum (the preview's min-inline-size: 0 dropped). The preview goes below the rows when both don't fit at their narrowest, and beside them, sharing the width two to three, when they do. A container query would need container-type on an inner element, which zeroes that element's intrinsic width and breaks shrink-to-fit parents; the wrap keeps the element's max-content width its content's. - Browser cases in a 1280px viewport: at 20rem the preview is below the rows, at 60rem beside them, and in a max-content parent the element is as wide as its content; in each, the rows and the preview don't intersect and nothing is outside or overflows the host. The 20rem case failed on the old sheet. --- src/settings.css | 17 +++----- test/browser/settings.test.ts | 82 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/src/settings.css b/src/settings.css index 133a3e8..7831526 100644 --- a/src/settings.css +++ b/src/settings.css @@ -5,8 +5,9 @@ /* * The settings' shadow-root sheet: a block host holding the theme and the keyboard sections, the - * keyboard's --space-m below the theme's. .theme-menu-body sets the rows beside the preview from - * 48rem, above it below; .theme-menu-rows stacks the rows; .theme-menu-row is one ◀ value ▶ row, + * keyboard's --space-m below the theme's. .theme-menu-body sets the preview beside the rows, + * sharing the width two to three, while the element is wide enough for both at their narrowest, + * and below them otherwise; .theme-menu-rows stacks the rows; .theme-menu-row is one ◀ value ▶ row, * its legend leading, its value in the code font, its other radios and every radio box hidden * visually, framed while a radio in it has visible focus; .theme-menu-preview is the card; * .theme-menu-buttons lays out its buttons. @@ -21,18 +22,14 @@ section + section { margin-block-start: var(--space-m); } .theme-menu-body { - display: grid; - grid-template-columns: minmax(0, 1fr); + display: flex; + flex-wrap: wrap; gap: var(--space-s); align-items: start; } -@media (width >= 48rem) { - .theme-menu-body { - grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); - } -} .theme-menu-rows { display: grid; + flex: 2 1 0; gap: var(--space-3xs); } .theme-menu-row { @@ -80,8 +77,8 @@ section + section { } .theme-menu-preview { display: grid; + flex: 3 1 0; gap: var(--space-xs); - min-inline-size: 0; padding: var(--space-s); border: var(--line-s) solid var(--border); border-radius: var(--radius-md); diff --git a/test/browser/settings.test.ts b/test/browser/settings.test.ts index a6e56f3..b9e3700 100644 --- a/test/browser/settings.test.ts +++ b/test/browser/settings.test.ts @@ -108,6 +108,49 @@ const listen = (page: Page): Promise => const changes = (page: Page): Promise => page.evaluate(`window.changes ?? []`); +interface Placed { + host: number; + rows: { left: number; right: number; top: number; bottom: number }; + preview: { left: number; right: number; top: number; bottom: number }; + outside: string[]; + overflowing: string[]; +} + +const place = (page: Page, inlineSize: string): Promise => + page.evaluate(`(async () => { + const host = document.querySelector("sl-settings"); + const box = document.createElement("div"); + box.style.inlineSize = ${JSON.stringify(inlineSize)}; + document.body.append(box); + box.append(host); + await host.updateComplete; + const bounds = host.getBoundingClientRect(); + const rect = (el) => { + const { left, right, top, bottom } = el.getBoundingClientRect(); + return { left, right, top, bottom }; + }; + const name = (el) => el.localName + (el.className ? "." + el.className : ""); + const drawn = [...${SHADOW}.querySelectorAll("*")].filter((el) => el.checkVisibility() && + el.getBoundingClientRect().width > 1); + return { + host: bounds.width, + rows: rect(${SHADOW}.querySelector(".theme-menu-rows")), + preview: rect(${SHADOW}.querySelector(".theme-menu-preview")), + outside: drawn.filter((el) => { + const { left, right } = el.getBoundingClientRect(); + return left < bounds.left - 0.5 || right > bounds.right + 0.5; + }).map(name), + overflowing: [host, ...drawn].filter((el) => el.scrollWidth > el.clientWidth + 1 && + getComputedStyle(el).display !== "inline").map(name), + }; + })()`); + +const intersect = ({ rows, preview }: Placed): boolean => + rows.left < preview.right && + preview.left < rows.right && + rows.top < preview.bottom && + preview.top < rows.bottom; + const HOST: Change = { target: "sl-settings", bubbles: true, composed: true }; async function openSettings(page: Page): Promise { @@ -536,4 +579,43 @@ describe("sl-settings", { timeout: 60_000 }, () => { "every row on again", ); }); + describe("in a wide viewport", () => { + before(async () => { + await page.cdp("Emulation.setDeviceMetricsOverride", { + width: 1280, + height: 800, + deviceScaleFactor: 1, + mobile: false, + }); + }); + after(async () => { + await page.cdp("Emulation.clearDeviceMetricsOverride"); + }); + + test("at 20rem the preview goes below the rows, nothing overlapping or overflowing the host", async () => { + const placed = await place(page, "20rem"); + assert.ok(placed.preview.top >= placed.rows.bottom, JSON.stringify(placed)); + assert.ok(!intersect(placed), JSON.stringify(placed)); + assert.deepEqual(placed.outside, []); + assert.deepEqual(placed.overflowing, []); + }); + + test("at 60rem the preview stands beside the rows, nothing overlapping or overflowing the host", async () => { + const placed = await place(page, "60rem"); + assert.ok(placed.preview.left >= placed.rows.right, JSON.stringify(placed)); + assert.ok(placed.preview.top < placed.rows.bottom, JSON.stringify(placed)); + assert.ok(!intersect(placed), JSON.stringify(placed)); + assert.deepEqual(placed.outside, []); + assert.deepEqual(placed.overflowing, []); + }); + + test("in a shrink-to-fit parent the element is as wide as its content, nothing overlapping or overflowing it", async () => { + const placed = await place(page, "max-content"); + const rows = placed.rows.right - placed.rows.left; + assert.ok(placed.host >= rows && placed.host <= 1280, JSON.stringify(placed)); + assert.ok(!intersect(placed), JSON.stringify(placed)); + assert.deepEqual(placed.outside, []); + assert.deepEqual(placed.overflowing, []); + }); + }); }); From bb2f79b2e06065e25b4a72ccc0c56b72110b58ff Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Mon, 23 Nov 2026 05:58:40 -0500 Subject: [PATCH 17/17] components-settings: redirect: the settings' preview placement in the docs --- docs/components.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/components.md b/docs/components.md index b214d89..7c00ea9 100644 --- a/docs/components.md +++ b/docs/components.md @@ -55,7 +55,8 @@ the tests measure as they do. binding, holds no setting, and renders no `[data-keys-list]`. - `./settings.js`: `sl-settings`, the reader's settings for a Settings dialog: the theme's color, scheme, space, and type rows, the registry's profile names and `SCHEMES`, each a ◀ value ▶ radio - group checked at what applies to the root, beside an inert preview card, and the keys module's + group checked at what applies to the root, with an inert preview card beside them where the + element's own width fits both and below them where it doesn't, and the keys module's character-key switch, `SWITCH_LABEL`, and wait between presses, `WAIT_LABEL`, one of `WAITS`. A click on a row's arrow steps it, wrapping; on a row, H and L step it, J and K or the down and up arrows move between rows, stopping at the ends, and the left and right arrows cycle its radios