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

Component library: skeleton, toast and confirm dialog as ui.ts parts, each in the gallery #5897

Parked opened this
Closed without merging

This adds three parts to src/web/ui.ts: toast, dialogParts and skeleton. Each has a specimen at /design/components, and every hand-written toast and dialog now uses them. The gallery isn't on main yet (it comes from #5888), so this branch has #5888's branch merged in.

Notes

stopped parked by the crew deploy b60c163

opened this

This adds three parts to src/web/ui.ts: toast, dialogParts and skeleton. Each has a specimen at /design/components, and every hand-written toast and dialog now uses them. The gallery isn't on main yet (it comes from #5888), so this branch has #5888's branch merged in. Until #5888 lands, this diff includes its commits; the work for this issue is the last commit.

What moved where

  • toast({ tone, message, link?, code?, codeId?, role? }): one part for the .toast banner, taken from flashToast. The flash in layout.ts now calls it (the code block keeps the id flash-code). So do the three pages that wrote .toast by hand: pages/repo.ts (fetch error), pages/browse.ts (failed mirror, still role="alert") and pages/origins.ts (connected or failed). Nothing writes .toast by hand any more.
  • dialogParts({ titleId, title, body, foot, stack?, bodyAttrs? }): draws a dialog's head, body and foot. The caller keeps the outer element, because the two uses differ: the keyboard-shortcuts <dialog> in layout.ts, and the limb page's confirm <form method="post" class="dialog"> in pages/limb.ts. Both now use it, and their markup is unchanged.
  • skeleton({ shape: "list" | "card", rows }): a placeholder made of a real .card with real .list rows (or a real card head and body), with grey bars where the text will be. Because the box is the real one, swapping in the loaded part shifts nothing. Screen readers hear "Loading…". The bars pulse, and the existing reduced-motion rule keeps them still. rows is limited to 1–50. Its two classes, .skeleton and .skeleton-bar, are in docs/design/areas/skeleton.md. No page uses it yet: the server renders whole pages, so there was no hand-written copy to move.
  • Docs: toast.md and dialog.md now name the parts. I also changed one sentence in docs/DESIGN.md: it said skeleton loaders were deliberately left out, which this issue reverses. It now says a skeleton is only for a part that fills in after the first paint.

Tests

  • New tests in test/design-gallery.test.ts cover toast tone, escaping, link and code; dialog structure; and skeleton row count, its limits and its card shape. The existing check that every ui.ts export has a specimen also covers the new parts.
  • The type check and bun scripts/design-lint.ts pass. The design-gallery, limb, milestones-golden, origins, web-ui and flash-related suites pass (about 1,100 tests).
  • One test failed here: test/scaffold.test.ts › "it typechecks under strict settings". It fails the same way without my change, because this sandbox can't write to the temp directory bun x needs. The forge's check runs it.

Not done

  • confirmAction and the /-/confirm page are unchanged; they already work without script.

To try it: as an admin, open /design/components?part=toast, ?part=dialogParts or ?part=skeleton. Then trigger a flash, for example by creating a token, and open a milestone's limb page to see the confirm form.

🤖 Generated with Claude Code

Closes #5880

4 earlier comments
commented

This adds three parts to src/web/ui.ts: toast, dialogParts and skeleton. Each has a specimen at /design/components, and every hand-written toast and dialog now uses them. The gallery isn't on main yet (it comes from #5888), so this branch has #5888's branch merged in. Until #5888 lands, this diff includes its commits; the work for this issue is the last commit.

What moved where

  • toast({ tone, message, link?, code?, codeId?, role? }): one part for the .toast banner, taken from flashToast. The flash in layout.ts now calls it (the code block keeps the id flash-code). So do the three pages that wrote .toast by hand: pages/repo.ts (fetch error), pages/browse.ts (failed mirror, still role="alert") and pages/origins.ts (connected or failed). Nothing writes .toast by hand any more.
  • dialogParts({ titleId, title, body, foot, stack?, bodyAttrs? }): draws a dialog's head, body and foot. The caller keeps the outer element, because the two uses differ: the keyboard-shortcuts <dialog> in layout.ts, and the limb page's confirm <form method="post" class="dialog"> in pages/limb.ts. Both now use it, and their markup is unchanged.
  • skeleton({ shape: "list" | "card", rows }): a placeholder made of a real .card with real .list rows (or a real card head and body), with grey bars where the text will be. Because the box is the real one, swapping in the loaded part shifts nothing. Screen readers hear "Loading…". The bars pulse, and the existing reduced-motion rule keeps them still. rows is limited to 1–50. Its two classes, .skeleton and .skeleton-bar, are in docs/design/areas/skeleton.md. No page uses it yet: the server renders whole pages, so there was no hand-written copy to move.
  • Docs: toast.md and dialog.md now name the parts. I also changed one sentence in docs/DESIGN.md: it said skeleton loaders were deliberately left out, which this issue reverses. It now says a skeleton is only for a part that fills in after the first paint.

Tests

  • New tests in test/design-gallery.test.ts cover toast tone, escaping, link and code; dialog structure; and skeleton row count, its limits and its card shape. The existing check that every ui.ts export has a specimen also covers the new parts.
  • The type check and bun scripts/design-lint.ts pass. The design-gallery, limb, milestones-golden, origins, web-ui and flash-related suites pass (about 1,100 tests).
  • One test failed here: test/scaffold.test.ts › "it typechecks under strict settings". It fails the same way without my change, because this sandbox can't write to the temp directory bun x needs. The forge's check runs it.

Not done

  • confirmAction and the /-/confirm page are unchanged; they already work without script.

To try it: as an admin, open /design/components?part=toast, ?part=dialogParts or ?part=skeleton. Then trigger a flash, for example by creating a token, and open a milestone's limb page to see the confirm form.

🤖 Generated with Claude Code

commented

The triage note asks for a pillar to be named. I left that alone: picking a pillar would take this past the Later gate, and the parent #5817 is also parked behind that gate (#595), so it's for a person to decide. No code changed and the branch is already pushed, so the description below is the same as before plus that one point.

---

This adds three parts to src/web/ui.ts: toast, dialogParts and skeleton. Each has a specimen at /design/components, and every hand-written toast and dialog now uses them. The gallery isn't on main yet (it comes from #5888), so this branch has #5888's branch merged in. Until #5888 lands, this diff includes its commits; the work for this issue is the last commit, 403a5da0.

What moved where

  • toast({ tone, message, link?, code?, codeId?, role? }): one part for the .toast banner, taken from flashToast. The flash in layout.ts now calls it (the code block keeps the id flash-code). So do the three pages that wrote .toast by hand: pages/repo.ts (fetch error), pages/browse.ts (failed mirror, still role="alert") and pages/origins.ts (connected or failed).
  • dialogParts({ titleId, title, body, foot, stack?, bodyAttrs? }): draws a dialog's head, body and foot. The caller keeps the outer element, because the two uses differ: the keyboard-shortcuts <dialog> in layout.ts, and the limb page's confirm <form method="post" class="dialog"> in pages/limb.ts. Both now use it, and their markup is unchanged.
  • skeleton({ shape: "list" | "card", rows }): a placeholder made of a real .card with real .list rows (or a real card head and body), with grey bars where the text will be. Because the box is the real one, swapping in the loaded part shifts nothing. Screen readers hear "Loading…". The bars pulse, and the existing reduced-motion rule keeps them still. rows is limited to 1–50. Its two classes, .skeleton and .skeleton-bar, are in docs/design/areas/skeleton.md. No page uses it yet: the server renders whole pages, so there was no hand-written copy to move.
  • Docs: toast.md and dialog.md now name the parts. I also changed one sentence in docs/DESIGN.md: it said skeleton loaders were deliberately left out, which this issue reverses. It now says a skeleton is only for a part that fills in after the first paint.

Tests

  • New tests in test/design-gallery.test.ts cover toast tone, escaping, link and code; dialog structure; and skeleton row count, its limits and its card shape. The existing check that every ui.ts export has a specimen also covers the new parts.
  • The type check and bun scripts/design-lint.ts pass. The design-gallery, limb, milestones-golden, origins, web-ui and flash-related suites pass.
  • One test failed here: test/scaffold.test.ts › "it typechecks under strict settings". It fails the same way without my change, because this sandbox can't write to the temp directory bun x needs. The forge's check runs it.

Not done

  • confirmAction and the /-/confirm page are unchanged; they already work without script.
  • No pillar is named, as asked in the live-triage note: #5880 and its parent #5817 both sit behind the Later gate (#595), and opening that is the owner's call.

To try it: as an admin, open /design/components?part=toast, ?part=dialogParts or ?part=skeleton. Then trigger a flash, for example by creating a token, and open a milestone's limb page to see the confirm form.

🤖 Generated with Claude Code

commented

This adds skeleton, toast and dialog parts to src/web/ui.ts (#5880), and each one is shown in the living gallery at /design/components. The docs: docs/design/areas/skeleton.md names the skeleton classes, and §5 of the design guide no longer says skeleton loaders are refused. The server still renders whole pages, so a skeleton is only for a part that fills in after the page has loaded. Native-checkbox switches stay out of the vocabulary.

This push merges the latest main. On main, docs/DESIGN.md is now a short index pointing to one file per section (#5948). The merge keeps that index as main has it, and moves this branch's change to the §5 paragraph into docs/design/sections/5-components.md. Every other file merged without conflicts.

What to look at: that paragraph in docs/design/sections/5-components.md, and the gallery's new skeleton, toast and dialog entries on the preview.

Checks run here: the type check is clean, and bun scripts/design-lint.ts reports nothing added outside the system. The tests for the design docs, the gallery, the lint, components and ui.ts (11 files, 103 tests) all pass. The full suite was not run here; the forge's check runs it on this push.

🤖 Generated with Claude Code

commented

I merged main into the branch again and resolved the conflict in src/web/layout.ts. The type check, design lint and the tests covering this change all pass; the forge's full check hasn't run on this push yet.

The conflict: both sides changed the same ui.ts import line. This branch added dialogParts and toast. main added a new SITE_LINE import from site_line.ts (#6053), and had also started importing copyField so its inline flashToast could show a code with a copy button. The merged import keeps dialogParts, toast and SITE_LINE. It drops copyField, because this branch's flashToast now calls toast({ ...flash, codeId: "flash-code" }), and the shared toast() in ui.ts already shows that code through copyField with the same id. Nothing else conflicted.

What this pull does (#5880):

  • New parts in src/web/ui.ts: a skeleton, a toast and dialog parts, plus a search picker that can be searched, paged and multi-selected, and keeps picks made on earlier pages.
  • Gallery at /design/components: src/web/gallery.ts and src/web/pages/design_components.ts show every ui.ts part in each state, theme and width. The path is reserved in src/core/reserved.ts and routed in src/http/server.ts.
  • Toast now shared: the layout's flash, browse, limb, origins and repo now use the shared toast and dialog parts instead of their own markup.
  • Docs: the parts are named in docs/design/sections/5-components.md.
  • Tests: test/design-gallery.test.ts checks that each part renders in the gallery.

To try it, open /design/components on the preview and switch theme and width. Then trigger any flash that carries a code and check that its copy button still works.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs