oneslash-design-system 2.20.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +34 -1
  3. package/dist/cases/about-page/profile.d.ts +1 -0
  4. package/dist/cases/about-page/profile.jsx +64 -0
  5. package/dist/cases/about-page.md +114 -0
  6. package/dist/cases/admin-inbox/list.d.ts +1 -0
  7. package/dist/cases/admin-inbox/list.jsx +104 -0
  8. package/dist/cases/admin-inbox/split.d.ts +1 -0
  9. package/dist/cases/admin-inbox/split.jsx +68 -0
  10. package/dist/cases/admin-inbox.md +254 -0
  11. package/dist/cases/api-keys.md +1 -1
  12. package/dist/cases/blog-index/cards.d.ts +1 -0
  13. package/dist/cases/blog-index/cards.jsx +45 -0
  14. package/dist/cases/blog-index/list.d.ts +1 -0
  15. package/dist/cases/blog-index/list.jsx +46 -0
  16. package/dist/cases/blog-index.md +160 -0
  17. package/dist/cases/changelog/by-month.d.ts +1 -0
  18. package/dist/cases/changelog/by-month.jsx +70 -0
  19. package/dist/cases/changelog/one-page.d.ts +1 -0
  20. package/dist/cases/changelog/one-page.jsx +70 -0
  21. package/dist/cases/changelog.md +200 -0
  22. package/dist/cases/code-sample/block.d.ts +1 -0
  23. package/dist/cases/code-sample/block.jsx +19 -0
  24. package/dist/cases/code-sample/command.d.ts +1 -0
  25. package/dist/cases/code-sample/command.jsx +17 -0
  26. package/dist/cases/code-sample.md +96 -0
  27. package/dist/cases/contact-page/form.d.ts +1 -0
  28. package/dist/cases/contact-page/form.jsx +83 -0
  29. package/dist/cases/contact-page/links.d.ts +1 -0
  30. package/dist/cases/contact-page/links.jsx +19 -0
  31. package/dist/cases/contact-page.md +142 -0
  32. package/dist/cases/docs-component-page/reference.d.ts +1 -0
  33. package/dist/cases/docs-component-page/reference.jsx +93 -0
  34. package/dist/cases/docs-component-page.md +144 -0
  35. package/dist/cases/faq/accordion.d.ts +1 -0
  36. package/dist/cases/faq/accordion.jsx +25 -0
  37. package/dist/cases/faq/open-list.d.ts +1 -0
  38. package/dist/cases/faq/open-list.jsx +27 -0
  39. package/dist/cases/faq.md +110 -0
  40. package/dist/cases/feature-grid/cards.d.ts +1 -0
  41. package/dist/cases/feature-grid/cards.jsx +33 -0
  42. package/dist/cases/feature-grid/rows.d.ts +1 -0
  43. package/dist/cases/feature-grid/rows.jsx +30 -0
  44. package/dist/cases/feature-grid.md +132 -0
  45. package/dist/cases/image-viewer/gallery.d.ts +1 -0
  46. package/dist/cases/image-viewer/gallery.jsx +32 -0
  47. package/dist/cases/image-viewer/single.d.ts +1 -0
  48. package/dist/cases/image-viewer/single.jsx +25 -0
  49. package/dist/cases/image-viewer.md +123 -0
  50. package/dist/cases/landing-hero/centered.d.ts +1 -0
  51. package/dist/cases/landing-hero/centered.jsx +22 -0
  52. package/dist/cases/landing-hero/split.d.ts +1 -0
  53. package/dist/cases/landing-hero/split.jsx +30 -0
  54. package/dist/cases/landing-hero.md +114 -0
  55. package/dist/cases/legal-page/sections.d.ts +1 -0
  56. package/dist/cases/legal-page/sections.jsx +61 -0
  57. package/dist/cases/legal-page.md +96 -0
  58. package/dist/cases/long-form-page/article.d.ts +1 -0
  59. package/dist/cases/long-form-page/article.jsx +58 -0
  60. package/dist/cases/long-form-page/with-contents.d.ts +1 -0
  61. package/dist/cases/long-form-page/with-contents.jsx +41 -0
  62. package/dist/cases/long-form-page.md +170 -0
  63. package/dist/cases/message-actions/hover-toolbar.jsx +11 -8
  64. package/dist/cases/message-actions/menu.jsx +10 -7
  65. package/dist/cases/message-actions.md +19 -13
  66. package/dist/cases/message-attachments/in-composer.jsx +2 -2
  67. package/dist/cases/message-attachments/in-message.jsx +16 -11
  68. package/dist/cases/message-attachments.md +29 -17
  69. package/dist/cases/one-main-action.md +33 -0
  70. package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
  71. package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
  72. package/dist/cases/overflow-menu.md +16 -10
  73. package/dist/cases/page-end/cta-band.d.ts +1 -0
  74. package/dist/cases/page-end/cta-band.jsx +24 -0
  75. package/dist/cases/page-end/next-link.d.ts +1 -0
  76. package/dist/cases/page-end/next-link.jsx +18 -0
  77. package/dist/cases/page-end.md +88 -0
  78. package/dist/cases/password-gate/inline.d.ts +1 -0
  79. package/dist/cases/password-gate/inline.jsx +94 -0
  80. package/dist/cases/password-gate/modal.d.ts +1 -0
  81. package/dist/cases/password-gate/modal.jsx +81 -0
  82. package/dist/cases/password-gate/page.d.ts +1 -0
  83. package/dist/cases/password-gate/page.jsx +82 -0
  84. package/dist/cases/password-gate.md +351 -0
  85. package/dist/cases/pricing-section/cards.d.ts +1 -0
  86. package/dist/cases/pricing-section/cards.jsx +40 -0
  87. package/dist/cases/pricing-section.md +85 -0
  88. package/dist/cases/product-cards/grid.d.ts +1 -0
  89. package/dist/cases/product-cards/grid.jsx +20 -0
  90. package/dist/cases/product-cards.md +71 -0
  91. package/dist/cases/reply-feedback/thumbs.jsx +11 -8
  92. package/dist/cases/reply-feedback/with-reason.jsx +11 -8
  93. package/dist/cases/reply-feedback.md +20 -14
  94. package/dist/cases/section-index/cards.d.ts +1 -0
  95. package/dist/cases/section-index/cards.jsx +25 -0
  96. package/dist/cases/section-index/list.d.ts +1 -0
  97. package/dist/cases/section-index/list.jsx +56 -0
  98. package/dist/cases/section-index.md +140 -0
  99. package/dist/cases/site-header.md +1 -1
  100. package/dist/cases/site-search/dialog.d.ts +1 -0
  101. package/dist/cases/site-search/dialog.jsx +131 -0
  102. package/dist/cases/site-search.md +176 -0
  103. package/dist/cases/tabbed-panels/tabs.d.ts +1 -0
  104. package/dist/cases/tabbed-panels/tabs.jsx +40 -0
  105. package/dist/cases/tabbed-panels.md +81 -0
  106. package/dist/cases.json +1173 -29
  107. package/dist/components/accordion.d.ts +31 -0
  108. package/dist/components/accordion.jsx +103 -0
  109. package/dist/components/codeBlock.d.ts +26 -0
  110. package/dist/components/codeBlock.jsx +101 -0
  111. package/dist/components/lightbox.d.ts +31 -0
  112. package/dist/components/lightbox.jsx +161 -0
  113. package/dist/components/linkCard.d.ts +10 -1
  114. package/dist/components/linkCard.jsx +32 -6
  115. package/dist/components/modal.d.ts +10 -2
  116. package/dist/components/modal.jsx +17 -12
  117. package/dist/components/pageHeader.jsx +1 -1
  118. package/dist/components/searchDialog.d.ts +44 -0
  119. package/dist/components/searchDialog.jsx +152 -0
  120. package/dist/components/tab.d.ts +5 -1
  121. package/dist/components/tab.jsx +2 -2
  122. package/dist/components/tabPanel.d.ts +16 -0
  123. package/dist/components/tabPanel.jsx +12 -0
  124. package/dist/components/tabsContainer.d.ts +5 -1
  125. package/dist/components/tabsContainer.jsx +2 -2
  126. package/dist/index.d.ts +5 -0
  127. package/dist/index.js +5 -0
  128. package/dist/internal/accordion.d.ts +4 -0
  129. package/dist/internal/accordion.js +53 -0
  130. package/dist/internal/combobox.d.ts +20 -0
  131. package/dist/internal/combobox.js +28 -0
  132. package/dist/internal/highlight.d.ts +5 -0
  133. package/dist/internal/highlight.js +18 -0
  134. package/dist/native-mapping.json +31 -1
  135. package/dist/stories/Accordion.stories.d.ts +11 -0
  136. package/dist/stories/Accordion.stories.jsx +93 -0
  137. package/dist/stories/Cases.generated.stories.d.ts +34 -0
  138. package/dist/stories/Cases.generated.stories.jsx +68 -0
  139. package/dist/stories/CodeBlock.stories.d.ts +12 -0
  140. package/dist/stories/CodeBlock.stories.jsx +65 -0
  141. package/dist/stories/Lightbox.stories.d.ts +8 -0
  142. package/dist/stories/Lightbox.stories.jsx +40 -0
  143. package/dist/stories/LinkCard.stories.d.ts +6 -0
  144. package/dist/stories/LinkCard.stories.jsx +17 -0
  145. package/dist/stories/PageHeader.stories.d.ts +2 -0
  146. package/dist/stories/PageHeader.stories.jsx +13 -0
  147. package/dist/stories/SearchDialog.stories.d.ts +17 -0
  148. package/dist/stories/SearchDialog.stories.jsx +111 -0
  149. package/dist/stories/TabPanel.stories.d.ts +7 -0
  150. package/dist/stories/TabPanel.stories.jsx +31 -0
  151. package/package.json +1 -1
package/dist/cases.json CHANGED
@@ -1,5 +1,55 @@
1
1
  {
2
2
  "cases": [
3
+ {
4
+ "id": "about-page",
5
+ "title": "About page",
6
+ "kind": "design",
7
+ "level": "page",
8
+ "area": "content",
9
+ "situation": "A visitor wants to know who is behind the work and whether to get in touch.",
10
+ "do": [
11
+ "Open with a `PageHeader` whose title is the person's name and whose lede says what they do in one sentence.",
12
+ "Put the few facts a visitor asks first in the header's `facts`: role, company, where they are based, years of experience.",
13
+ "Show a portrait in a `Figure` with a caption. Give the image an `alt` that says what it shows.",
14
+ "Set the work history as `NumberedRow` rows, the newest first, with a plain years range in each title.",
15
+ "Set the skills as a `Cluster` of `Tag` with `variant=\"contained\"`. Keep it to the skills the work shows.",
16
+ "Put further reading in a `List` of `Link`. Write each link as the name of the piece, not 'Read more'.",
17
+ "End the page with one `LinkCard` to the next step, as the case 'Page end' says.",
18
+ "Give each section a `SectionIntro`, so every section has a heading and an address."
19
+ ],
20
+ "dont": [
21
+ "Do not write the page in the third person when one person owns the work.",
22
+ "Do not list every job. Keep the ones that explain the work.",
23
+ "Do not rate skills with bars or stars.",
24
+ "Do not add social links that the person does not use.",
25
+ "Do not put a resume in a modal that a keyboard cannot reach."
26
+ ],
27
+ "native": "On Apple a profile is a grouped list with the name in a large title. Use a `NavigationLink` for further reading.",
28
+ "options": [
29
+ {
30
+ "id": "profile",
31
+ "title": "One person introduces their work",
32
+ "useWhen": "One person, such as a designer, writes about their work in their own voice.",
33
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport NumberedRow from 'oneslash-design-system/components/numberedRow';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Tag from 'oneslash-design-system/components/tag';\nimport List from 'oneslash-design-system/components/list';\nimport Link from 'oneslash-design-system/components/link';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { Cluster, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// A stand-in for the portrait. A real page passes its own picture.\nconst portrait =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%23eef2f6'/%3E%3Ccircle cx='600' cy='330' r='110' fill='%23c2cfdb'/%3E%3Cpath d='M380 700c0-130 100-220 220-220s220 90 220 220z' fill='%23aab8c6'/%3E%3C/svg%3E\";\n\nconst skills = ['Forms and errors', 'Billing and plans', 'Settings', 'Writing for interfaces', 'Field research', 'Workshops'];\n\nexport default function AboutPageProfile() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageSection>\n <PageHeader\n level={1}\n eyebrow=\"About\"\n title=\"Dana Lee\"\n lede=\"Designer at Acme, working on billing and account settings.\"\n facts={[\n { label: 'Role', value: 'Designer' },\n { label: 'Company', value: 'Acme' },\n { label: 'Based', value: 'Denver' },\n { label: 'Experience', value: '9 years' },\n ]}\n />\n {/* A placeholder, never a photo in the design system. A real page gives the picture a caption. */}\n <Figure crop={3 / 2} caption=\"Dana at the Acme studio.\">\n <Image src={portrait} alt=\"A portrait of Dana Lee\" width={1200} height={800} />\n </Figure>\n </PageSection>\n <PageSection>\n <SectionIntro id=\"about-page-work\" name=\"Work\" statement=\"I design the parts of a product that people have to trust.\" />\n <Stack gap=\"xlarge\">\n <NumberedRow index={0} title=\"Designer, Acme, 2023 to now\">\n <Paragraph tone=\"secondary\" measure=\"none\">I lead the design of billing, plans and the settings people change most.</Paragraph>\n </NumberedRow>\n <NumberedRow index={1} title=\"Product designer at a design studio, 2019 to 2023\">\n <Paragraph tone=\"secondary\" measure=\"none\">I built a design system for six teams and wrote the rules for forms and errors.</Paragraph>\n </NumberedRow>\n <NumberedRow index={2} title=\"Interface designer for field tools, 2017 to 2019\">\n <Paragraph tone=\"secondary\" measure=\"none\">I designed tools for field crews that worked with a poor connection.</Paragraph>\n </NumberedRow>\n </Stack>\n </PageSection>\n <PageSection>\n <SectionIntro id=\"about-page-skills\" name=\"Skills\" />\n <Cluster>\n {skills.map((skill) => (\n <Tag key={skill} variant=\"contained\" size=\"medium\" state=\"enabled\" label={skill} />\n ))}\n </Cluster>\n </PageSection>\n <PageSection>\n <SectionIntro id=\"about-page-reading\" name=\"Further reading\" />\n <List\n size=\"body1\"\n items={[\n <Link key=\"a\" href=\"#how-we-write-errors\">How we write error messages</Link>,\n <Link key=\"b\" href=\"#a-design-system-for-six-teams\">A design system for six teams</Link>,\n <Link key=\"c\" href=\"#designing-for-a-poor-connection\">Designing for a poor connection</Link>,\n ]}\n />\n </PageSection>\n {/* The page ends by pointing to one next step. */}\n <LinkCard href=\"#contact\" title=\"Write a message\" caption=\"Next: Contact\" />\n </Stack>\n </PageShell>\n );\n}\n",
34
+ "uses": [
35
+ "Cluster",
36
+ "Figure",
37
+ "Image",
38
+ "Link",
39
+ "LinkCard",
40
+ "List",
41
+ "NumberedRow",
42
+ "PageHeader",
43
+ "PageSection",
44
+ "PageShell",
45
+ "Paragraph",
46
+ "SectionIntro",
47
+ "Stack",
48
+ "Tag"
49
+ ]
50
+ }
51
+ ]
52
+ },
3
53
  {
4
54
  "id": "accept-invite",
5
55
  "title": "Invite link page",
@@ -112,6 +162,73 @@
112
162
  }
113
163
  ]
114
164
  },
165
+ {
166
+ "id": "admin-inbox",
167
+ "title": "Admin inbox",
168
+ "kind": "design",
169
+ "level": "page",
170
+ "area": "content",
171
+ "situation": "The owner of a site reads the messages that visitors sent through its contact form.",
172
+ "do": [
173
+ "Open with a `PageHeader` titled 'Messages' and a lede that counts what is unread: '3 of 12 unread'.",
174
+ "Show the sender, the date and the first lines of each message. Write the date as plain text, such as Nov 12, 2026.",
175
+ "Mark an unread message with a `Tag` that says 'Unread', so it does not rely on color.",
176
+ "Give each row an `IconButton` that toggles read and unread, in a `Tooltip` with its name. Name it for the row's message: 'Mark message from Ben Carter as read'.",
177
+ "Follow the case 'List and detail' for `split`. Name its Button 'Mark as Read' or 'Mark as Unread'.",
178
+ "Keep the header while the list loads, and show `Skeleton` rows with one label: 'Loading messages'.",
179
+ "Follow the case 'Load failure' when the list fails to load: `EmptyBox` 'Could not load messages' with a 'Try Again' Button that is `loading` while it retries.",
180
+ "Show `EmptyBox` as the case 'Empty list' says when there are no messages: `size=\"large\"` in `list`, `size=\"small\"` in the list column of `split`. Text 'No messages yet', `secondText` 'Messages from the contact form appear here.'"
181
+ ],
182
+ "dont": [
183
+ "Do not replace the whole page with a loading screen while the list loads.",
184
+ "Do not show 'No messages yet' when the list failed to load.",
185
+ "Do not name every IconButton 'Mark as read'. Name the message it acts on.",
186
+ "Do not mark a message read only by opening it, with no way to undo.",
187
+ "Do not leave a failed read or unread change with no message."
188
+ ],
189
+ "native": "On Apple use a `List` with a swipe action to mark a message read or unread, and a `NavigationSplitView` for many messages.",
190
+ "options": [
191
+ {
192
+ "id": "list",
193
+ "title": "One column of messages",
194
+ "useWhen": "A few messages arrive each week, and each one is read in full in the list.",
195
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Tag from 'oneslash-design-system/components/tag';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Button from 'oneslash-design-system/components/button';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Skeleton from 'oneslash-design-system/components/skeleton';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Message = { id: string; from: string; date: string; text: string; read: boolean };\n\nconst first: Message[] = [\n { id: 'm1', from: 'Ben Carter', date: 'Nov 16, 2026', text: 'I saw your page about error messages. Do you give talks? We are planning a day for our design team in January.', read: false },\n { id: 'm2', from: 'Omar Reyes', date: 'Nov 15, 2026', text: 'Is the plan changes case study open to everyone? I would like to share it with my team.', read: false },\n { id: 'm3', from: 'Maya Brooks', date: 'Nov 14, 2026', text: 'Thank you for the reading list. I read the piece on poor connections twice.', read: false },\n { id: 'm4', from: 'Leo Park', date: 'Nov 12, 2026', text: 'Could you share the password for the case studies? I would like to show it to my team.', read: true },\n { id: 'm5', from: 'Sara Idris', date: 'Nov 10, 2026', text: 'We are hiring a designer in the spring. Would you like to talk?', read: true },\n { id: 'm6', from: 'Noah Quinn', date: 'Nov 9, 2026', text: 'Your design system notes helped our team. Is there a newsletter?', read: true },\n { id: 'm7', from: 'Ana Silva', date: 'Nov 7, 2026', text: 'A small thing: the link to the second case study on the About page does not open.', read: true },\n { id: 'm8', from: 'Tom Hale', date: 'Nov 6, 2026', text: 'Can I use one of your diagrams in a talk? I will credit you.', read: true },\n { id: 'm9', from: 'Iris Chen', date: 'Nov 4, 2026', text: 'I would like to ask about the tools you use for prototyping.', read: true },\n { id: 'm10', from: 'Sam Ortiz', date: 'Nov 2, 2026', text: 'Congratulations on the new page. The facts row is very clear.', read: true },\n { id: 'm11', from: 'Eve Lund', date: 'Oct 29, 2026', text: 'We met at the meetup in October. I would like to stay in touch.', read: true },\n { id: 'm12', from: 'Raj Patel', date: 'Oct 22, 2026', text: 'Is the About page available as a printable resume?', read: true },\n];\n\nexport default function AdminInboxList() {\n const [messages, setMessages] = useState(first);\n const [failed, setFailed] = useState(false);\n const [busy, setBusy] = useState(false);\n const [refreshes, setRefreshes] = useState(0);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const unread = messages.filter((m) => !m.read).length;\n\n function toggle(id: string) {\n setMessages((list) => list.map((m) => (m.id === id ? { ...m, read: !m.read } : m)));\n }\n\n function load() {\n if (busy) return;\n const attempt = refreshes + 1;\n setRefreshes(attempt);\n setBusy(true);\n // Stands in for the request to the server. The second refresh fails, so you can see Try Again.\n timer.current = setTimeout(() => {\n setBusy(false);\n setFailed(attempt === 2);\n }, 1000);\n }\n\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n {/* The header stays while the list loads or fails. */}\n <PageHeader level={1} title=\"Messages\" lede={`${unread} of ${messages.length} unread`} />\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Refresh\" decoIcon=\"RefreshCw\" loading={busy && !failed} onClickButton={load} />\n </Cluster>\n {busy && !failed && (\n <Stack gap=\"small\">\n <Skeleton variant=\"block\" height=\"large\" label=\"Loading messages\" />\n <Skeleton variant=\"block\" height=\"large\" />\n <Skeleton variant=\"block\" height=\"large\" />\n </Stack>\n )}\n {failed && (\n // The list fails as a region, as the case 'Load failure' shows: it stays until the list loads.\n <Surface minHeight=\"tall\" align=\"center\">\n <EmptyBox\n size=\"large\"\n icon=\"CloudOff\"\n text=\"Could not load messages\"\n secondText=\"Check your connection and try again.\"\n action={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Try Again\" loading={busy} onClickButton={load} />}\n />\n </Surface>\n )}\n {!busy && !failed && messages.length === 0 && <EmptyBox size=\"large\" text=\"No messages yet\" secondText=\"Messages from the contact form appear here.\" />}\n {!busy && !failed && (\n <Stack gap=\"small\">\n {messages.map((m) => (\n <Surface key={m.id} padding=\"small\" align=\"start\">\n <Stack gap=\"small\">\n <Cluster justify=\"between\">\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{m.from}</Heading>\n {!m.read && <Tag variant=\"dot\" size=\"small\" color=\"info\" label=\"Unread\" />}\n </Cluster>\n <Cluster gap=\"small\">\n <Paragraph tone=\"secondary\" size=\"caption\">{m.date}</Paragraph>\n {/* The icon shows what the Button does: an open envelope marks the message read, a closed one marks it unread. */}\n <Tooltip title={`Mark message from ${m.from} as ${m.read ? 'unread' : 'read'}`}>\n <IconButton\n iconName={m.read ? 'Mail' : 'MailOpen'}\n ariaLabel={`Mark message from ${m.from} as ${m.read ? 'unread' : 'read'}`}\n color={m.read ? 'iconOnly' : 'primary'}\n state=\"enabled\"\n size=\"medium\"\n onClick={() => toggle(m.id)}\n />\n </Tooltip>\n </Cluster>\n </Cluster>\n <Paragraph size=\"body2\" measure=\"none\">{m.text}</Paragraph>\n </Stack>\n </Surface>\n ))}\n </Stack>\n )}\n </Stack>\n </PageShell>\n );\n}\n",
196
+ "uses": [
197
+ "Button",
198
+ "Cluster",
199
+ "EmptyBox",
200
+ "Heading",
201
+ "IconButton",
202
+ "PageHeader",
203
+ "PageShell",
204
+ "Paragraph",
205
+ "Skeleton",
206
+ "Stack",
207
+ "Surface",
208
+ "Tag",
209
+ "Tooltip"
210
+ ]
211
+ },
212
+ {
213
+ "id": "split",
214
+ "title": "List beside the message",
215
+ "useWhen": "Many messages arrive, and the owner works down them one after another.",
216
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport { SettingsLayout } from 'oneslash-design-system/components/settingsSection';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Message = { id: string; from: string; subject: string; date: string; body: string[]; read: boolean };\n\nconst first: Message[] = [\n { id: 'talk', from: 'Ben Carter', subject: 'A talk in January?', date: 'Nov 16, 2026', body: ['I saw your page about error messages. Do you give talks?', 'We are planning a day for our design team in January.'], read: false },\n { id: 'share', from: 'Omar Reyes', subject: 'Sharing the case study', date: 'Nov 15, 2026', body: ['Is the plan changes case study open to everyone?', 'I would like to share it with my team.'], read: false },\n { id: 'thanks', from: 'Maya Brooks', subject: 'Thank you for the reading list', date: 'Nov 14, 2026', body: ['I read the piece on poor connections twice.'], read: false },\n { id: 'password', from: 'Leo Park', subject: 'The case study password', date: 'Nov 12, 2026', body: ['Could you share the password for the case studies?', 'I would like to show it to my team.'], read: true },\n { id: 'hiring', from: 'Sara Idris', subject: 'We are hiring in the spring', date: 'Nov 10, 2026', body: ['We are hiring a designer in the spring. Would you like to talk?'], read: true },\n { id: 'newsletter', from: 'Noah Quinn', subject: 'Is there a newsletter?', date: 'Nov 9, 2026', body: ['Your design system notes helped our team.'], read: true },\n];\n\nexport default function AdminInboxSplit() {\n const [messages, setMessages] = useState(first);\n // One message is always open, the first at the start.\n const [openId, setOpenId] = useState(first[0].id);\n // On a phone the list is the screen until a message is chosen, and Back returns to it.\n const [showDetail, setShowDetail] = useState(false);\n\n const message = messages.find((m) => m.id === openId) ?? messages[0];\n const unread = messages.filter((m) => !m.read).length;\n\n function toggle(id: string) {\n setMessages((list) => list.map((m) => (m.id === id ? { ...m, read: !m.read } : m)));\n }\n\n const list = (\n <Navigation aria-label=\"Messages\">\n {messages.map((m) => (\n <MenuItem\n key={m.id}\n size=\"medium\"\n label={m.from}\n secondLabel={m.subject}\n tag={m.read ? undefined : { label: 'Unread', color: 'info' }}\n href={`/admin/messages/${m.id}`}\n isSelected={m.id === message.id}\n aria-current={m.id === message.id ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to the message's own address, so it can be shared and reloaded. The example keeps the choice in state.\n event.preventDefault();\n setOpenId(m.id);\n setShowDetail(true);\n }}\n />\n ))}\n </Navigation>\n );\n\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n <PageHeader level={1} title=\"Messages\" lede={`${unread} of ${messages.length} unread`} />\n <SettingsLayout\n navWidth=\"wide\"\n nav={list}\n showContent={showDetail}\n back={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Messages\" onClickButton={() => setShowDetail(false)} />}\n >\n <Stack gap=\"small\">\n <Heading level={2} size=\"h6\">{message.subject}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{message.from}, {message.date}</Paragraph>\n </Stack>\n <Stack gap=\"medium\">\n {message.body.map((paragraph) => (\n <Paragraph key={paragraph} measure=\"none\">{paragraph}</Paragraph>\n ))}\n </Stack>\n <Cluster>\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" decoIcon=\"CircleCheck\" label={message.read ? 'Mark as Unread' : 'Mark as Read'} onClickButton={() => toggle(message.id)} />\n </Cluster>\n </SettingsLayout>\n </Stack>\n </PageShell>\n );\n}\n",
217
+ "uses": [
218
+ "Button",
219
+ "Cluster",
220
+ "Heading",
221
+ "MenuItem",
222
+ "Navigation",
223
+ "PageHeader",
224
+ "PageShell",
225
+ "Paragraph",
226
+ "SettingsLayout",
227
+ "Stack"
228
+ ]
229
+ }
230
+ ]
231
+ },
115
232
  {
116
233
  "id": "agent-asks-before-risky-action",
117
234
  "title": "An agent asks before a risky action",
@@ -604,7 +721,7 @@
604
721
  "Give the Modal one Button, 'Done'. Ignore Escape and a click outside while the key shows, so a stray click cannot lose it.",
605
722
  "Confirm 'Revoke' in the row, as the case 'Delete confirm' does: the row asks 'Revoke CI pipeline?' and shows 'Cancel' and a danger 'Revoke'. Then show a toast: 'CI pipeline key revoked.'",
606
723
  "Give each row's 'Revoke', and the confirm's 'Cancel' and 'Revoke', an `aria-label` that names the key: 'Revoke CI pipeline' and 'Cancel revoking CI pipeline'.",
607
- "Show `EmptyBox` with 'No API keys' when the list is empty, as the rule 'An empty list says what is empty' says.",
724
+ "Show `EmptyBox` with 'No API keys' when the list is empty, as the rule 'An empty list says what will fill it' says.",
608
725
  "Disable the name field while the key is made, and show `loading` on the Button without changing its label."
609
726
  ],
610
727
  "dont": [
@@ -895,6 +1012,63 @@
895
1012
  }
896
1013
  ]
897
1014
  },
1015
+ {
1016
+ "id": "blog-index",
1017
+ "title": "Blog index",
1018
+ "kind": "design",
1019
+ "level": "page",
1020
+ "area": "content",
1021
+ "situation": "A visitor opens the blog to see what was written lately and to pick a post to read.",
1022
+ "do": [
1023
+ "Use `PageHeader` with `level={1}`: the title 'Blog' is the one level 1 heading, with a `lede` of one sentence about what the blog is for.",
1024
+ "Put the newest post first and say so nowhere. The order is the date.",
1025
+ "Make each row of `list` the date as 'Nov 12, 2026' in a secondary caption `Paragraph`, the title as a `Link` and one line of `Paragraph` under it. A row is one link, so the title is the link and the line is not.",
1026
+ "Use `LinkCard` for `cards`, with `image`, `title`, `description` and the date as `caption`, in `Grid columns={2}`. Give the cover `alt=\"\"` when the title says what the post is about, because a cover's alt text joins the link's name.",
1027
+ "Show 12 posts to a page. Past 12, add `Pagination` with `getHref`, such as `(p) => '/blog?page=' + p`, so each page has an address that works without script. Name it 'Blog pages'.",
1028
+ "Show `EmptyBox` with `size=\"large\"` when there are no posts yet: 'No posts yet', with `secondText` 'New posts appear here.' and no action.",
1029
+ "Follow the cases 'Empty search' and 'Load failure' for a search or a filter on the blog."
1030
+ ],
1031
+ "dont": [
1032
+ "Do not use `TimeStamp` for a post date. It writes '11/12/2026 Thu', and the site writes dates as 'Nov 12, 2026'.",
1033
+ "Do not show a post count or a count of readers.",
1034
+ "Do not mix a list and cards on one page. Pick the one that fits the posts.",
1035
+ "Do not put the whole text of a post in the index. One line is enough to choose.",
1036
+ "Do not use a picture of a person as a cover. A cover is a picture of the subject.",
1037
+ "Do not page by infinite scroll. A person cannot reach the footer, or come back to the same place."
1038
+ ],
1039
+ "native": "On Apple use a `List` of `NavigationLink`s for posts, or a `LazyVGrid` of cards for covers. On Android use a `LazyColumn` or `LazyVerticalGrid`.",
1040
+ "options": [
1041
+ {
1042
+ "id": "list",
1043
+ "title": "A list of posts, newest first",
1044
+ "useWhen": "The posts have no pictures, and a person scans the titles and the dates.",
1045
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Link from 'oneslash-design-system/components/link';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Pagination from 'oneslash-design-system/components/pagination';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// Made-up posts, newest first. A real site loads one page of them from its own data.\nconst posts = [\n { id: 'task-threads', date: 'Nov 12, 2026', title: 'How task threads work', line: 'One piece of work and all of its talk, in one thread.' },\n { id: 'pinning', date: 'Nov 5, 2026', title: 'Pin what people need to find again', line: 'Pins stay at the top of a channel until you remove them.' },\n { id: 'agent-sources', date: 'Oct 29, 2026', title: 'Why the agent names its sources', line: 'An answer you can check is an answer you can use.' },\n { id: 'notes-export', date: 'Oct 22, 2026', title: 'Take your notes with you', line: 'Export a note or a whole workspace as PDF.' },\n { id: 'members', date: 'Oct 15, 2026', title: 'Inviting people to a workspace', line: 'Invite by email and choose what each person can do.' },\n { id: 'plans', date: 'Oct 8, 2026', title: 'Choosing a plan', line: 'What each plan includes, and when to move up.' },\n { id: 'search', date: 'Oct 1, 2026', title: 'Finding an old message', line: 'Search reads messages, notes and files together.' },\n { id: 'channels', date: 'Sep 24, 2026', title: 'How channels work', line: 'Make a channel for each team or project.' },\n { id: 'billing', date: 'Sep 17, 2026', title: 'Where your invoices are', line: 'Download any invoice from the billing page.' },\n { id: 'dark-mode', date: 'Sep 10, 2026', title: 'Light, dark or follow the system', line: 'Pick a theme once and every page follows it.' },\n { id: 'shortcuts', date: 'Sep 3, 2026', title: 'Keyboard shortcuts worth learning', line: 'Five keys that save the most time.' },\n { id: 'welcome', date: 'Aug 27, 2026', title: 'Welcome to the Acme blog', line: 'What we will write about here.' },\n { id: 'roadmap', date: 'Aug 20, 2026', title: 'What we are building next', line: 'A short look at the next three months.' },\n { id: 'hello', date: 'Aug 13, 2026', title: 'Hello from the team', line: 'Who we are and why we started.' },\n];\n\nconst PAGE_SIZE = 12;\n\nexport default function BlogIndexList() {\n const [page, setPage] = useState(1);\n const pageCount = Math.ceil(posts.length / PAGE_SIZE);\n const shown = posts.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Blog\" lede=\"Notes from the team on how Acme works and why.\" />\n {shown.length === 0 ? (\n <EmptyBox size=\"large\" text=\"No posts yet\" secondText=\"New posts appear here.\" />\n ) : (\n <Stack gap=\"xlarge\">\n {shown.map((post) => (\n <Stack key={post.id} gap=\"small\">\n <Paragraph tone=\"secondary\" size=\"caption\" measure=\"none\">{post.date}</Paragraph>\n <Link href={`#${post.id}`} size=\"subtitle1\">{post.title}</Link>\n <Paragraph tone=\"secondary\" size=\"body2\">{post.line}</Paragraph>\n </Stack>\n ))}\n </Stack>\n )}\n {/* A real blog passes an address that works without script, such as '/blog?page=2'. The example keeps the page in its hash. */}\n <Pagination page={page} pageCount={pageCount} onPageChange={setPage} getHref={(p) => `#page-${p}`} aria-label=\"Blog pages\" />\n </Stack>\n </PageShell>\n );\n}\n",
1046
+ "uses": [
1047
+ "EmptyBox",
1048
+ "Link",
1049
+ "PageHeader",
1050
+ "PageShell",
1051
+ "Pagination",
1052
+ "Paragraph",
1053
+ "Stack"
1054
+ ]
1055
+ },
1056
+ {
1057
+ "id": "cards",
1058
+ "title": "Cards with a cover",
1059
+ "useWhen": "Every post has a cover picture, and the picture helps a person choose.",
1060
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport Pagination from 'oneslash-design-system/components/pagination';\nimport { Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// Stand-ins for the covers. A real post has its own picture.\nconst cover = (fill: string) =>\n `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='${fill}'/%3E%3Crect x='80' y='80' width='300' height='200' rx='20' fill='%23ffffff'/%3E%3Crect x='420' y='120' width='140' height='140' rx='70' fill='%232f6b4f'/%3E%3C/svg%3E`;\nconst fills = ['%23eef2f6', '%23e6efe9', '%23f1ece4'];\n\n// Made-up posts, newest first. A real site loads one page of them from its own data.\nconst posts = [\n { id: 'task-threads', date: 'Nov 12, 2026', title: 'How task threads work', line: 'One piece of work and all of its talk, in one thread.' },\n { id: 'pinning', date: 'Nov 5, 2026', title: 'Pin what people need to find again', line: 'Pins stay at the top of a channel until you remove them.' },\n { id: 'agent-sources', date: 'Oct 29, 2026', title: 'Why the agent names its sources', line: 'An answer you can check is an answer you can use.' },\n { id: 'notes-export', date: 'Oct 22, 2026', title: 'Take your notes with you', line: 'Export a note or a whole workspace as PDF.' },\n { id: 'members', date: 'Oct 15, 2026', title: 'Inviting people to a workspace', line: 'Invite by email and choose what each person can do.' },\n { id: 'plans', date: 'Oct 8, 2026', title: 'Choosing a plan', line: 'What each plan includes, and when to move up.' },\n { id: 'search', date: 'Oct 1, 2026', title: 'Finding an old message', line: 'Search reads messages, notes and files together.' },\n { id: 'channels', date: 'Sep 24, 2026', title: 'How channels work', line: 'Make a channel for each team or project.' },\n { id: 'billing', date: 'Sep 17, 2026', title: 'Where your invoices are', line: 'Download any invoice from the billing page.' },\n { id: 'dark-mode', date: 'Sep 10, 2026', title: 'Light, dark or follow the system', line: 'Pick a theme once and every page follows it.' },\n { id: 'shortcuts', date: 'Sep 3, 2026', title: 'Keyboard shortcuts worth learning', line: 'Five keys that save the most time.' },\n { id: 'welcome', date: 'Aug 27, 2026', title: 'Welcome to the Acme blog', line: 'What we will write about here.' },\n { id: 'roadmap', date: 'Aug 20, 2026', title: 'What we are building next', line: 'A short look at the next three months.' },\n { id: 'hello', date: 'Aug 13, 2026', title: 'Hello from the team', line: 'Who we are and why we started.' },\n];\n\nconst PAGE_SIZE = 12;\n\nexport default function BlogIndexCards() {\n const [page, setPage] = useState(1);\n const pageCount = Math.ceil(posts.length / PAGE_SIZE);\n const shown = posts.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Blog\" lede=\"Notes from the team on how Acme works and why.\" />\n <Grid columns={2}>\n {shown.map((post, i) => (\n <LinkCard\n key={post.id}\n href={`#${post.id}`}\n title={post.title}\n description={post.line}\n caption={post.date}\n image={{ src: cover(fills[((page - 1) * PAGE_SIZE + i) % fills.length]), alt: '' }}\n />\n ))}\n </Grid>\n {/* A real blog passes an address that works without script, such as '/blog?page=2'. The example keeps the page in its hash. */}\n <Pagination page={page} pageCount={pageCount} onPageChange={setPage} getHref={(p) => `#page-${p}`} aria-label=\"Blog pages\" />\n </Stack>\n </PageShell>\n );\n}\n",
1061
+ "uses": [
1062
+ "Grid",
1063
+ "LinkCard",
1064
+ "PageHeader",
1065
+ "PageShell",
1066
+ "Pagination",
1067
+ "Stack"
1068
+ ]
1069
+ }
1070
+ ]
1071
+ },
898
1072
  {
899
1073
  "id": "breakdown-list",
900
1074
  "title": "Breakdown of a total",
@@ -958,6 +1132,69 @@
958
1132
  }
959
1133
  ]
960
1134
  },
1135
+ {
1136
+ "id": "changelog",
1137
+ "title": "Changelog",
1138
+ "kind": "design",
1139
+ "level": "page",
1140
+ "area": "content",
1141
+ "situation": "A visitor or a customer wants to know what changed in the product lately, and may be sent to one change from a message.",
1142
+ "do": [
1143
+ "Use `PageHeader` with `level={1}`: the title 'Changelog' is the one level 1 heading, with a `lede` that says the order.",
1144
+ "Put the newest entry first.",
1145
+ "Make each entry a level 2 `Heading` with an `id` of its own. A link to `/changelog#pin-a-message` goes straight to it. `PageShell` gives it a scroll margin under a header only when it has an `aside`, as `one-page` does.",
1146
+ "Put the entry's kind and its date under its heading: a `Tag` ('New' in success, 'Improved' in info, 'Fixed' in the default color) and the date as 'Nov 12, 2026'. Both are plain text a screen reader reads.",
1147
+ "List what changed in a `List` with `marker=\"dot\"`, one change to a line, in words a customer uses.",
1148
+ "Put `OnThisPage` in the `aside` of `PageShell` for `one-page`, with the entries' titles, so a long log has a list of entries beside it.",
1149
+ "Show one month in `by-month`, and use `Pagination` with `getHref`, one page for each month, so the month is in the address (`'/changelog?month=2026-10'`). Name it 'Months', and say the month in the `lede`: 'October 2026, newest first.'",
1150
+ "Make Next go to the older month in `by-month`, as it does on the blog, so a person reads back in time."
1151
+ ],
1152
+ "dont": [
1153
+ "Do not leave an entry without a date. A person needs to know how old a change is.",
1154
+ "Do not write an entry as a post. It is a title and a list of changes, and a link to the full post when there is one.",
1155
+ "Do not use an `Accordion` for the entries. A person looks for a change with find in page.",
1156
+ "Do not name a kind that is a feeling, such as 'Exciting'. Use New, Improved or Fixed.",
1157
+ "Do not move the month by script only. The address must change, so a month can be shared and the Back button works.",
1158
+ "Do not add an infinite scroll. It hides the footer and the older months."
1159
+ ],
1160
+ "native": "On Apple show the log in a `List` with a section for each month. On Android use a `LazyColumn` with sticky month headers.",
1161
+ "options": [
1162
+ {
1163
+ "id": "one-page",
1164
+ "title": "All entries on one page",
1165
+ "useWhen": "A few entries a month, so the whole log is a page or two long.",
1166
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Tag from 'oneslash-design-system/components/tag';\nimport List from 'oneslash-design-system/components/list';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Kind = 'New' | 'Improved' | 'Fixed';\n\n// Made-up entries, newest first. Each has an id, so a link can go straight to it.\n// The prefix keeps ids unique where several examples share a page. A real site uses the slug: '/changelog#pin-a-message'.\nconst entries: { id: string; date: string; kind: Kind; title: string; changes: string[] }[] = [\n {\n id: 'changelog-pin-a-message',\n date: 'Nov 12, 2026',\n kind: 'New',\n title: 'Pin a message to a channel',\n changes: ['Pin any message from its menu. Pins show at the top of the channel.', 'A channel holds up to 10 pins. Unpin one to add another.'],\n },\n {\n id: 'changelog-faster-notes',\n date: 'Nov 5, 2026',\n kind: 'Improved',\n title: 'Notes open faster',\n changes: ['A long note shows its first screen at once and loads the rest as you scroll.', 'Search results open on the line that matched.'],\n },\n {\n id: 'changelog-export-fix',\n date: 'Oct 29, 2026',\n kind: 'Fixed',\n title: 'Export keeps the order of a note',\n changes: ['A PDF export no longer puts a list after the text that followed it.', 'An export with a table no longer cuts off the last column.'],\n },\n {\n id: 'changelog-agent-sources',\n date: 'Oct 22, 2026',\n kind: 'New',\n title: 'The agent names its sources',\n changes: ['Every answer lists the notes and messages it used.', 'Open a source from the list to see it in place.'],\n },\n {\n id: 'changelog-invite-fix',\n date: 'Oct 15, 2026',\n kind: 'Fixed',\n title: 'Invitations to a second address',\n changes: ['An invitation sent to an address with a plus sign now arrives.'],\n },\n];\n\nconst kindColor = { New: 'success', Improved: 'info', Fixed: 'default' } as const;\n\nconst items = entries.map(({ id, title }) => ({ id, label: title }));\n\nexport default function ChangelogOnePage() {\n return (\n <PageShell aside={<OnThisPage items={items} aria-label=\"Entries\" />}>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Changelog\" lede=\"What changed in Acme, newest first.\" />\n <Stack gap=\"giant\">\n {entries.map((entry) => (\n <Stack key={entry.id} gap=\"large\">\n <Heading level={2} size=\"h5\" id={entry.id}>{entry.title}</Heading>\n <Cluster>\n <Tag variant=\"contained\" size=\"small\" color={kindColor[entry.kind]} label={entry.kind} />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{entry.date}</Paragraph>\n </Cluster>\n <List marker=\"dot\" size=\"body1\" items={entry.changes} />\n </Stack>\n ))}\n </Stack>\n </Stack>\n </PageShell>\n );\n}\n",
1167
+ "uses": [
1168
+ "Cluster",
1169
+ "Heading",
1170
+ "List",
1171
+ "OnThisPage",
1172
+ "PageHeader",
1173
+ "PageShell",
1174
+ "Paragraph",
1175
+ "Stack",
1176
+ "Tag"
1177
+ ]
1178
+ },
1179
+ {
1180
+ "id": "by-month",
1181
+ "title": "One month at a time",
1182
+ "useWhen": "Many entries, so a page of the whole log would be long and slow.",
1183
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Tag from 'oneslash-design-system/components/tag';\nimport List from 'oneslash-design-system/components/list';\nimport Pagination from 'oneslash-design-system/components/pagination';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Kind = 'New' | 'Improved' | 'Fixed';\n\n// Made-up entries, newest month first. A real site loads the month named in the address.\n// The prefix keeps ids unique where several examples share a page. A real site uses the slug: '/changelog#pin-a-message'.\nconst months: { key: string; label: string; entries: { id: string; date: string; kind: Kind; title: string; changes: string[] }[] }[] = [\n {\n key: '2026-11',\n label: 'November 2026',\n entries: [\n { id: 'changelog-by-month-pin-a-message', date: 'Nov 12, 2026', kind: 'New', title: 'Pin a message to a channel', changes: ['Pin any message from its menu. Pins show at the top of the channel.'] },\n { id: 'changelog-by-month-faster-notes', date: 'Nov 5, 2026', kind: 'Improved', title: 'Notes open faster', changes: ['A long note shows its first screen at once.', 'Search results open on the line that matched.'] },\n ],\n },\n {\n key: '2026-10',\n label: 'October 2026',\n entries: [\n { id: 'changelog-by-month-export-fix', date: 'Oct 29, 2026', kind: 'Fixed', title: 'Export keeps the order of a note', changes: ['A PDF export no longer puts a list after the text that followed it.'] },\n { id: 'changelog-by-month-agent-sources', date: 'Oct 22, 2026', kind: 'New', title: 'The agent names its sources', changes: ['Every answer lists the notes and messages it used.'] },\n { id: 'changelog-by-month-invite-fix', date: 'Oct 15, 2026', kind: 'Fixed', title: 'Invitations to a second address', changes: ['An invitation sent to an address with a plus sign now arrives.'] },\n ],\n },\n {\n key: '2026-09',\n label: 'September 2026',\n entries: [\n { id: 'changelog-by-month-dark-theme', date: 'Sep 17, 2026', kind: 'New', title: 'A dark theme', changes: ['Choose light, dark or the system setting in your profile.'] },\n { id: 'changelog-by-month-channel-order', date: 'Sep 3, 2026', kind: 'Fixed', title: 'Channels keep their order', changes: ['The sidebar no longer re-sorts a channel you moved.'] },\n ],\n },\n {\n key: '2026-08',\n label: 'August 2026',\n entries: [\n { id: 'changelog-by-month-billing-page', date: 'Aug 20, 2026', kind: 'New', title: 'A billing page', changes: ['See your plan, your usage and your invoices in one place.'] },\n ],\n },\n];\n\nconst kindColor = { New: 'success', Improved: 'info', Fixed: 'default' } as const;\n\nexport default function ChangelogByMonth() {\n // Page 1 is the newest month. Next goes back in time.\n const [page, setPage] = useState(1);\n const month = months[page - 1] ?? months[0];\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Changelog\" lede={`${month.label}, newest first.`} />\n <Stack gap=\"giant\">\n {month.entries.map((entry) => (\n <Stack key={entry.id} gap=\"large\">\n <Heading level={2} size=\"h5\" id={entry.id}>{entry.title}</Heading>\n <Cluster>\n <Tag variant=\"contained\" size=\"small\" color={kindColor[entry.kind]} label={entry.kind} />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{entry.date}</Paragraph>\n </Cluster>\n <List marker=\"dot\" size=\"body1\" items={entry.changes} />\n </Stack>\n ))}\n </Stack>\n {/* A real site passes an address that works without script, such as '/changelog?month=2026-10'. The example keeps the month in its hash. */}\n <Pagination page={page} pageCount={months.length} onPageChange={setPage} getHref={(p) => `#month-${months[p - 1].key}`} aria-label=\"Months\" />\n </Stack>\n </PageShell>\n );\n}\n",
1184
+ "uses": [
1185
+ "Cluster",
1186
+ "Heading",
1187
+ "List",
1188
+ "PageHeader",
1189
+ "PageShell",
1190
+ "Pagination",
1191
+ "Paragraph",
1192
+ "Stack",
1193
+ "Tag"
1194
+ ]
1195
+ }
1196
+ ]
1197
+ },
961
1198
  {
962
1199
  "id": "check-your-email",
963
1200
  "title": "Check your email",
@@ -1014,6 +1251,60 @@
1014
1251
  }
1015
1252
  ]
1016
1253
  },
1254
+ {
1255
+ "id": "code-sample",
1256
+ "title": "Code sample",
1257
+ "kind": "design",
1258
+ "level": "organism",
1259
+ "area": "content",
1260
+ "situation": "A page shows code that a person reads, or copies to run.",
1261
+ "do": [
1262
+ "Use `CodeBlock` for `block`, with a `label` that names what the code is, such as 'ask.ts' or 'Set up the client'. The label names the block, its scroll region and its Copy Button.",
1263
+ "Pass `language` as words for the reader ('TypeScript'). It does not color the code.",
1264
+ "Write the `code` as it will be copied, with its line breaks. Keep a block to about twenty lines; split a longer one under headings.",
1265
+ "Let a long line scroll inside the block. The block is a region that a keyboard can focus and scroll with the arrow keys; the page never scrolls sideways.",
1266
+ "Use `wrap` only for a short block of prose, such as a prompt, where every word should stay in view. Code keeps its lines and scrolls.",
1267
+ "Use `CopyField` for `command`, with `mono` and the `label` 'Install command'. A person sees the whole line and copies it with one Button.",
1268
+ "Say 'Copied' only after the clipboard took the text. `CodeBlock` and `CopyField` do this, and show a line to copy by hand when the browser refuses.",
1269
+ "Make each step of a task a `NumberedRow` with its title when the steps have code, and put its `CodeBlock` or `CopyField` under it. The order is clear and every command copies on its own."
1270
+ ],
1271
+ "dont": [
1272
+ "Do not put code in a `Paragraph` or a bare `pre`. It has no name, no Copy Button and no scroll region.",
1273
+ "Do not put a prompt `$` before a command people copy. It is pasted too.",
1274
+ "Do not use `CodeBlock` for one line. Use `CopyField`.",
1275
+ "Do not set the label to a sentence. Name the thing, as a file name or a task does.",
1276
+ "Do not show a screenshot of code. It cannot be copied, searched or read aloud."
1277
+ ],
1278
+ "native": "On Apple show code in a `Text` with a monospaced font in a horizontal `ScrollView`, and a `Button` that sets the pasteboard. On Android use a text block with a monospace font that scrolls sideways, and a button that copies.",
1279
+ "options": [
1280
+ {
1281
+ "id": "block",
1282
+ "title": "A block of code",
1283
+ "useWhen": "Several lines that a person reads or copies.",
1284
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport CodeBlock from 'oneslash-design-system/components/codeBlock';\nimport { PageSection } from 'oneslash-design-system/components/layout';\n\n// Made-up code for a made-up client. A real page shows code that runs.\nconst code = `import { createClient } from '@acme/sdk';\n\nconst acme = createClient({ workspace: 'design' });\n\nconst answer = await acme.agent.ask({\n channel: 'launch-plan',\n question: 'What is left before the launch?',\n});\n\nconsole.log(answer.text, answer.sources);`;\n\nexport default function CodeSampleBlock() {\n return (\n <PageShell>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"code-sample-block-intro\" name=\"Ask the agent\" statement=\"Make a client, then ask a question in a channel.\">\n <Paragraph tone=\"secondary\">The answer comes back with the notes and messages it used.</Paragraph>\n </SectionIntro>\n {/* The label names the block, its scroll region and its Copy Button. A long line scrolls inside the block, never the page. */}\n <CodeBlock id=\"code-sample-block\" label=\"ask.ts\" language=\"TypeScript\" code={code} />\n </PageSection>\n </PageShell>\n );\n}\n",
1285
+ "uses": [
1286
+ "CodeBlock",
1287
+ "PageSection",
1288
+ "PageShell",
1289
+ "Paragraph",
1290
+ "SectionIntro"
1291
+ ]
1292
+ },
1293
+ {
1294
+ "id": "command",
1295
+ "title": "A command to paste",
1296
+ "useWhen": "One line to paste in a terminal.",
1297
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport CopyField from 'oneslash-design-system/components/copyField';\nimport { PageSection } from 'oneslash-design-system/components/layout';\n\nexport default function CodeSampleCommand() {\n return (\n <PageShell>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"code-sample-command-intro\" name=\"Install\" statement=\"Add the client to your project.\">\n <Paragraph tone=\"secondary\">Run this in the folder of your project.</Paragraph>\n </SectionIntro>\n {/* One line to paste. The field shows it whole, the Button copies it, and 'Copied' shows only once the clipboard took it. */}\n <CopyField id=\"code-sample-command\" label=\"Install command\" value=\"npm install @acme/sdk\" mono />\n </PageSection>\n </PageShell>\n );\n}\n",
1298
+ "uses": [
1299
+ "CopyField",
1300
+ "PageSection",
1301
+ "PageShell",
1302
+ "Paragraph",
1303
+ "SectionIntro"
1304
+ ]
1305
+ }
1306
+ ]
1307
+ },
1017
1308
  {
1018
1309
  "id": "collapsible-search",
1019
1310
  "title": "Collapsible search",
@@ -1228,6 +1519,64 @@
1228
1519
  ],
1229
1520
  "native": "On Apple use a system `confirmationDialog` or `.alert`, with the action in the `.destructive` role when it destroys or removes something. Never build a sheet by hand for a confirm."
1230
1521
  },
1522
+ {
1523
+ "id": "contact-page",
1524
+ "title": "Contact page",
1525
+ "kind": "design",
1526
+ "level": "page",
1527
+ "area": "content",
1528
+ "situation": "A visitor wants to reach the person behind a site.",
1529
+ "do": [
1530
+ "Use a `Form` for `form`, with Name, Email and Message, and follow the rules 'A form error shows next to the problem' and 'Success shows where the person is looking'.",
1531
+ "Show a problem with one field under that field. Say what to do: 'Enter an email address, like name@example.com.'",
1532
+ "Keep the label 'Send' while sending, and make the Button `loading`. Disable the fields.",
1533
+ "Show success in an inline success `Alert` with `autoDismiss={false}`: 'Message sent. I reply within two days.' Clear it on the next edit, and clear the fields.",
1534
+ "Say how long a reply takes, in the lede or in the confirmation.",
1535
+ "Add a spam-trap input named `website` in your own code, hidden from sight and from screen readers, with `tabIndex={-1}` and `autoComplete=\"off\"`. The server drops a message that fills it. ODS has no hidden field, so the example leaves it out. Never show it as a visible `TextField`.",
1536
+ "Show a failed send above the fields in `<Alert type=\"error\" variant=\"inline\" showCloseButton>`: 'Could not send your message. Try again.' Keep what the visitor typed.",
1537
+ "Give the address in `links` as a `Link` with `mailto:` and as a `CopyField`, so a visitor with no mail app can copy it.",
1538
+ "Use one address only: 'hello@acme.example'."
1539
+ ],
1540
+ "dont": [
1541
+ "Do not change the Send label to Sending while it runs.",
1542
+ "Do not clear what the visitor typed after a failed send.",
1543
+ "Do not open the mail app from a Button with `window.open`. Use a link with `mailto:`.",
1544
+ "Do not close the confirmation on a timer. It stays until the next edit.",
1545
+ "Do not show both options on one page. Pick one."
1546
+ ],
1547
+ "native": "On Apple a message form is a grouped `Form` with a Send button in the toolbar. For an address only, use a `Link` with a `mailto:` address.",
1548
+ "options": [
1549
+ {
1550
+ "id": "form",
1551
+ "title": "A message form",
1552
+ "useWhen": "A visitor writes a message here, and the person reads and answers it.",
1553
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Form from 'oneslash-design-system/components/form';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nexport default function ContactPageForm() {\n const [name, setName] = useState('');\n const [email, setEmail] = useState('');\n const [message, setMessage] = useState('');\n const [errors, setErrors] = useState({ name: '', email: '', message: '' });\n const [sent, setSent] = useState(false);\n const [sending, setSending] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // Any edit clears the confirmation and the problem with that field.\n function edit(field: 'name' | 'email' | 'message', set: (value: string) => void, value: string) {\n set(value);\n setSent(false);\n setErrors((current) => ({ ...current, [field]: '' }));\n }\n\n function handleSubmit() {\n if (sending) return;\n setSent(false);\n const next = {\n name: name.trim() ? '' : 'Enter your name.',\n email: !email.trim() ? 'Enter your email.' : looksLikeEmail(email.trim()) ? '' : 'Enter an email address, like name@example.com.',\n message: message.trim() ? '' : 'Write a message.',\n };\n setErrors(next);\n if (next.name || next.email || next.message) return;\n setSending(true);\n // A real page also has a hidden spam-trap input named `website`, in its own code. ODS has no hidden field, so the example leaves it out.\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setSending(false);\n setSent(true);\n setName('');\n setEmail('');\n setMessage('');\n }, 1200);\n }\n\n return (\n <PageShell>\n <Stack gap=\"xxlarge\">\n <PageHeader level={1} title=\"Contact\" lede=\"I read every message and reply within two days.\" />\n <Form aria-label=\"Contact\" onSubmit={handleSubmit}>\n {/* The confirmation stays until the next edit, so it has no close button and does not close on its own. */}\n {sent && <Alert type=\"success\" variant=\"inline\" message=\"Message sent. I reply within two days.\" autoDismiss={false} />}\n <TextField id=\"contact-page-name\" label=\"Name\" autoComplete=\"name\" value={name} disabled={sending} error={Boolean(errors.name)} errorText={errors.name} onChange={(e) => edit('name', setName, e.target.value)} />\n <TextField id=\"contact-page-email\" label=\"Email\" type=\"email\" autoComplete=\"email\" value={email} disabled={sending} error={Boolean(errors.email)} errorText={errors.email} onChange={(e) => edit('email', setEmail, e.target.value)} />\n <Textarea id=\"contact-page-message\" label=\"Message\" maxRows={8} value={message} disabled={sending} error={Boolean(errors.message)} errorText={errors.message} onChange={(e) => edit('message', setMessage, e.target.value)} />\n <Stack align=\"start\">\n <Button size=\"large\" type=\"primary\" state=\"enabled\" label=\"Send\" htmlType=\"submit\" loading={sending} />\n </Stack>\n </Form>\n </Stack>\n </PageShell>\n );\n}\n",
1554
+ "uses": [
1555
+ "Alert",
1556
+ "Button",
1557
+ "Form",
1558
+ "PageHeader",
1559
+ "PageShell",
1560
+ "Stack",
1561
+ "TextField",
1562
+ "Textarea"
1563
+ ]
1564
+ },
1565
+ {
1566
+ "id": "links",
1567
+ "title": "An address only",
1568
+ "useWhen": "There is no inbox to read. The page gives an address and nothing else.",
1569
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Link from 'oneslash-design-system/components/link';\nimport CopyField from 'oneslash-design-system/components/copyField';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nexport default function ContactPageLinks() {\n return (\n <PageShell>\n <Stack gap=\"xxlarge\">\n <PageHeader level={1} title=\"Contact\" lede=\"Write to me at this address. I reply within two days.\" />\n <Stack gap=\"large\">\n {/* A mailto link opens the visitor's own mail app. */}\n <Link href=\"mailto:hello@acme.example\">hello@acme.example</Link>\n {/* For a visitor with no mail app: copy the address. */}\n <CopyField id=\"contact-page-address\" label=\"Email address\" value=\"hello@acme.example\" />\n </Stack>\n </Stack>\n </PageShell>\n );\n}\n",
1570
+ "uses": [
1571
+ "CopyField",
1572
+ "Link",
1573
+ "PageHeader",
1574
+ "PageShell",
1575
+ "Stack"
1576
+ ]
1577
+ }
1578
+ ]
1579
+ },
1231
1580
  {
1232
1581
  "id": "conversation-starters",
1233
1582
  "title": "Conversation starters",
@@ -1672,6 +2021,62 @@
1672
2021
  }
1673
2022
  ]
1674
2023
  },
2024
+ {
2025
+ "id": "docs-component-page",
2026
+ "title": "Docs component page",
2027
+ "kind": "design",
2028
+ "level": "page",
2029
+ "area": "content",
2030
+ "situation": "A person opens the page of one part of a design system or a code library to see what it looks like, how to write it and what it takes.",
2031
+ "do": [
2032
+ "Use `PageHeader` with `level={1}`: the part's name is the one level 1 heading, with an `eyebrow` for its group and a `lede` of one sentence that says what it is for.",
2033
+ "Show the part live first, in a `Surface` with `align=\"center\"`, so a person sees it before reading about it.",
2034
+ "Put the code of that same example in a `CodeBlock` with a `label` such as 'Tag example', so the Copy Button and the scroll region have a name.",
2035
+ "Switch between the example and its code with `TabsContainer`, `Tab` and `TabPanel`: give each `Tab` an `id` and `controls`, and keep both panels in the page.",
2036
+ "Show the props in a `TableContainer` with an `aria-label` such as 'Tag props' and a `minWidth`, with the columns Prop, Type, Default and Description. A wide table then scrolls inside its own region.",
2037
+ "Write 'None, required' in Default for a prop that has no default, so an empty cell never means two things.",
2038
+ "Show Do and Don't as two lists side by side in a `Grid columns={2}`, each under a level 3 `Heading`. Start each Don't with \"Do not\".",
2039
+ "Put `OnThisPage` in the `aside` of `PageShell`, as the case 'On this page' says, with an `id` on each `SectionIntro`."
2040
+ ],
2041
+ "dont": [
2042
+ "Do not draw the example from a picture. A person must be able to click and tab it.",
2043
+ "Do not mount only the selected view. Keep both panels in the page with `TabPanel`, so the code is in the server HTML before scripts run.",
2044
+ "Do not let a wide props table scroll the page. Name the table so it scrolls inside its region.",
2045
+ "Do not leave a Default cell empty or write a dash.",
2046
+ "Do not copy the look or the wording of another documentation site. Use the parts and the words of this one."
2047
+ ],
2048
+ "native": "On Apple use a `List` with a `NavigationLink` to a detail view of the part, its preview on top. On Android use a detail screen under a top app bar, with the code in a text block that scrolls.",
2049
+ "options": [
2050
+ {
2051
+ "id": "reference",
2052
+ "title": "A page that documents one part",
2053
+ "useWhen": "Each part of a library has a page with an example, its code and its props.",
2054
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Surface from 'oneslash-design-system/components/surface';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport TabPanel from 'oneslash-design-system/components/tabPanel';\nimport CodeBlock from 'oneslash-design-system/components/codeBlock';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Heading from 'oneslash-design-system/components/heading';\nimport List from 'oneslash-design-system/components/list';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// One part, documented. A real site builds the props and the code from the part's own source.\nconst sections = [\n { id: 'docs-component-page-example', label: 'Example' },\n { id: 'docs-component-page-props', label: 'Props' },\n { id: 'docs-component-page-use', label: 'When to use it' },\n];\n\nconst code = `<Tag\n variant=\"contained\"\n size=\"medium\"\n color=\"success\"\n label=\"Paid\"\n/>`;\n\n// Prop, Type, Default, Description\nconst props = [\n { name: 'variant', type: \"'contained' | 'textOnly' | 'dot'\", initial: 'None, required', text: 'How it is drawn: a filled pill, text only, or a dot before the text.' },\n { name: 'size', type: \"'medium' | 'small' | 'tiny'\", initial: 'None, required', text: 'How large it is set.' },\n { name: 'state', type: \"'enabled' | 'selected'\", initial: \"'enabled'\", text: 'Selected draws the tag as chosen, such as an active filter.' },\n { name: 'label', type: 'ReactNode', initial: 'None, required', text: 'The words in the tag.' },\n];\n\nexport default function DocsComponentPageReference() {\n const [view, setView] = useState<'example' | 'code'>('example');\n return (\n <PageShell aside={<OnThisPage items={sections} />}>\n <Stack gap=\"giant\">\n <PageHeader\n level={1}\n eyebrow=\"Components\"\n title=\"Tag\"\n lede=\"A short label that says what state something is in, such as Paid or Draft.\"\n />\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-example\" name=\"Example\" />\n <Stack gap=\"large\">\n {/* The tabs only switch what is shown. Both panels are in the server HTML. */}\n <TabsContainer aria-label=\"Example views\">\n <Tab id=\"docs-component-page-tab-example\" controls=\"docs-component-page-panel-example\" size=\"small\" label=\"Example\" isSelected={view === 'example'} onClickTab={() => setView('example')} />\n <Tab id=\"docs-component-page-tab-code\" controls=\"docs-component-page-panel-code\" size=\"small\" label=\"Code\" isSelected={view === 'code'} onClickTab={() => setView('code')} />\n </TabsContainer>\n <TabPanel id=\"docs-component-page-panel-example\" labelledBy=\"docs-component-page-tab-example\" selected={view === 'example'}>\n <Surface align=\"center\" minHeight=\"short\">\n <Tag variant=\"contained\" size=\"medium\" color=\"success\" label=\"Paid\" />\n </Surface>\n </TabPanel>\n <TabPanel id=\"docs-component-page-panel-code\" labelledBy=\"docs-component-page-tab-code\" selected={view === 'code'}>\n <CodeBlock id=\"docs-component-page-code\" label=\"Tag example\" language=\"TypeScript\" code={code} />\n </TabPanel>\n </Stack>\n </PageSection>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-props\" name=\"Props\" />\n {/* The name says which part's props these are. A wide table scrolls inside this region, not the page. */}\n <TableContainer aria-label=\"Tag props\" minWidth=\"720px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"120px\">Prop</TableHeaderCell>\n <TableHeaderCell width=\"260px\">Type</TableHeaderCell>\n <TableHeaderCell width=\"140px\">Default</TableHeaderCell>\n <TableHeaderCell>Description</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {props.map((p) => (\n <TableRow key={p.name}>\n <TableCell width=\"120px\">{p.name}</TableCell>\n <TableCell width=\"260px\">{p.type}</TableCell>\n <TableCell width=\"140px\">{p.initial}</TableCell>\n <TableCell>{p.text}</TableCell>\n </TableRow>\n ))}\n </TableContainer>\n </PageSection>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"docs-component-page-use\" name=\"When to use it\" />\n <Grid columns={2} gap=\"xxlarge\">\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h6\">Do</Heading>\n <List marker=\"dot\" items={['Say the state in the words, and use the color to back it up.', 'Keep a tag to one or two words.']} />\n </Stack>\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h6\">Don't</Heading>\n <List marker=\"dot\" items={['Do not use a tag as a button. Use a Button.', 'Do not rely on the color alone to say the state.']} />\n </Stack>\n </Grid>\n </PageSection>\n </Stack>\n </PageShell>\n );\n}\n",
2055
+ "uses": [
2056
+ "CodeBlock",
2057
+ "Grid",
2058
+ "Heading",
2059
+ "List",
2060
+ "OnThisPage",
2061
+ "PageHeader",
2062
+ "PageSection",
2063
+ "PageShell",
2064
+ "SectionIntro",
2065
+ "Stack",
2066
+ "Surface",
2067
+ "Tab",
2068
+ "TabPanel",
2069
+ "TableCell",
2070
+ "TableContainer",
2071
+ "TableHeader",
2072
+ "TableHeaderCell",
2073
+ "TableRow",
2074
+ "TabsContainer",
2075
+ "Tag"
2076
+ ]
2077
+ }
2078
+ ]
2079
+ },
1675
2080
  {
1676
2081
  "id": "email-confirmed",
1677
2082
  "title": "Email confirmed",
@@ -1932,6 +2337,117 @@
1932
2337
  }
1933
2338
  ]
1934
2339
  },
2340
+ {
2341
+ "id": "faq",
2342
+ "title": "FAQ",
2343
+ "kind": "design",
2344
+ "level": "organism",
2345
+ "area": "marketing",
2346
+ "situation": "A marketing page answers the questions a visitor asks before signing up.",
2347
+ "do": [
2348
+ "Put the section's name in `SectionIntro`, so the section has a level 2 heading. Write each question as the visitor would ask it, in sentence case, ending in a question mark.",
2349
+ "Use `Accordion` for `accordion`, with the questions as the titles and `headingLevel={3}`, one level below the section's heading.",
2350
+ "Add `linkable` to the Accordion, so a link such as `#faq-refunds` opens that item and scrolls it under the `SiteHeader`, also on a page that only renders in the browser.",
2351
+ "Keep `multiple` on, its default, so a visitor can keep two answers open to compare. Use `multiple={false}` only when two open answers push the next question off the screen.",
2352
+ "Make each question a level 3 `Heading` for `open-list`, with its answer in a `Paragraph` under it.",
2353
+ "Write each answer as a `Paragraph` of one or two sentences. Name the one next step when there is one, such as the address to write to.",
2354
+ "Put a question that most visitors have first, and one that few have last."
2355
+ ],
2356
+ "dont": [
2357
+ "Do not build the open and close by hand. `Accordion` does the heading, the Button, `aria-expanded` and the keys.",
2358
+ "Do not use `<details>`, which has no heading and no deep link.",
2359
+ "Do not hide up to five short answers behind a click. Show them.",
2360
+ "Do not put a Button or a form inside an answer. An answer is for reading.",
2361
+ "Do not write answers that sound like a sales page."
2362
+ ],
2363
+ "native": "On Apple use a `List` of `DisclosureGroup` rows. On Android use a list with an expandable row. A short list is plain text under a heading.",
2364
+ "options": [
2365
+ {
2366
+ "id": "accordion",
2367
+ "title": "Questions that open",
2368
+ "useWhen": "There are more than about five questions, or the answers are long, and a visitor reads only some of them.",
2369
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Accordion from 'oneslash-design-system/components/accordion';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { PageSection } from 'oneslash-design-system/components/layout';\n\n// Made-up questions about Acme. A real site writes the ones its visitors ask.\nconst questions = [\n { id: 'members', title: 'Who can join a workspace?', content: 'Anyone you invite by email. A workspace on Free holds 3 members. Pro and Business have no limit.' },\n { id: 'yearly', title: 'Is there a yearly price?', content: 'Not yet. Every plan bills monthly, per member on Pro and Business.' },\n { id: 'responses', title: 'When do agent responses start again?', content: \"Each answer the agent posts uses one of the plan's responses. They start again on the 1st of each month.\" },\n { id: 'refunds', title: 'Can I get a refund?', content: 'Yes, within 30 days of a payment. Write to help@acme.example and say which workspace it was for.' },\n { id: 'export', title: 'Can I take my notes with me?', content: 'Yes. Export a note or a whole workspace as PDF on Pro and Business. On Free, copy the text of any note.' },\n { id: 'cancel', title: 'What happens when I cancel?', content: 'The workspace stays on its plan until the end of the period you paid for, then moves to Free. Nothing is deleted.' },\n { id: 'storage', title: 'What happens when storage is full?', content: 'You can still read everything. New files wait until you remove some or move to a plan with more room.' },\n];\n\nexport default function FaqAccordion() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"faq\" name=\"Common questions\" statement=\"What people ask before they sign up.\" />\n {/* The section's heading is an h2, so each question is an h3. `linkable` opens the item named by #faq-refunds and scrolls it under the header. */}\n <Accordion\n id=\"faq\"\n headingLevel={3}\n linkable\n items={questions.map((q) => ({ id: q.id, title: q.title, content: <Paragraph tone=\"secondary\" measure=\"none\">{q.content}</Paragraph> }))}\n />\n </PageSection>\n </PageShell>\n );\n}\n",
2370
+ "uses": [
2371
+ "Accordion",
2372
+ "PageSection",
2373
+ "PageShell",
2374
+ "Paragraph",
2375
+ "SectionIntro"
2376
+ ]
2377
+ },
2378
+ {
2379
+ "id": "open-list",
2380
+ "title": "Questions with their answers showing",
2381
+ "useWhen": "There are up to five short answers that everyone should read.",
2382
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Four short answers that everyone should read, so none is hidden.\nconst questions = [\n { id: 'free', question: 'Is there a free plan?', answer: 'Yes. Free holds 3 members and needs no card.' },\n { id: 'members', question: 'Who can join a workspace?', answer: 'Anyone you invite by email.' },\n { id: 'refunds', question: 'Can I get a refund?', answer: 'Yes, within 30 days of a payment. Write to help@acme.example.' },\n { id: 'cancel', question: 'What happens when I cancel?', answer: 'The workspace moves to Free at the end of the period you paid for. Nothing is deleted.' },\n];\n\nexport default function FaqOpenList() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"faq-open-list\" name=\"Common questions\" statement=\"What people ask before they sign up.\" />\n <Stack gap=\"xlarge\">\n {questions.map((q) => (\n <Stack key={q.id} gap=\"small\">\n {/* The section's heading is an h2, so each question is an h3 and its answer is read in order. */}\n <Heading level={3} size=\"h6\">{q.question}</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">{q.answer}</Paragraph>\n </Stack>\n ))}\n </Stack>\n </PageSection>\n </PageShell>\n );\n}\n",
2383
+ "uses": [
2384
+ "Heading",
2385
+ "PageSection",
2386
+ "PageShell",
2387
+ "Paragraph",
2388
+ "SectionIntro",
2389
+ "Stack"
2390
+ ]
2391
+ }
2392
+ ]
2393
+ },
2394
+ {
2395
+ "id": "feature-grid",
2396
+ "title": "Feature grid",
2397
+ "kind": "design",
2398
+ "level": "organism",
2399
+ "area": "marketing",
2400
+ "situation": "A marketing page lists what the product does, so a visitor can see if it fits.",
2401
+ "do": [
2402
+ "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A feature section does not add its own action. The page's one Button stays in the header, the hero and the end.",
2403
+ "Open the section with `SectionIntro`: a name and one statement. Its name is the h2.",
2404
+ "Use `Grid columns={3}` of `Surface` for `cards`, each with an `Icon`, a level 3 `Heading` and one line in a `Paragraph`.",
2405
+ "Use `NumberedRow` with `visual` for `rows`. The picture is beside the words from the 2xl breakpoint, swaps sides each row, and sits under the words below it. Give the picture alt text that says what is in it.",
2406
+ "Keep to six cards or fewer, and four rows or fewer. A longer list is a page of its own.",
2407
+ "Make a card a link only when it goes somewhere. Then use `LinkCard`, and the card itself is one link."
2408
+ ],
2409
+ "dont": [
2410
+ "Do not put a Button in every card.",
2411
+ "Do not make a card look like a link when it is not one.",
2412
+ "Do not fill the grid with logos of other products.",
2413
+ "Do not mix cards and rows in one section."
2414
+ ],
2415
+ "native": "On Apple use a `List` of `Label`s, or a `TabView` of pages for a first-run tour. On Android use a list with leading icons.",
2416
+ "options": [
2417
+ {
2418
+ "id": "cards",
2419
+ "title": "Cards of equal weight",
2420
+ "useWhen": "Three to six features count the same, and each one fits an icon, a name and one line.",
2421
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\nconst features = [\n { icon: 'MessagesSquare', title: 'Channels', line: 'A channel for each subject, open to the whole team.' },\n { icon: 'ListChecks', title: 'Task threads', line: 'Every task keeps its own replies.' },\n { icon: 'BookOpen', title: 'Notes', line: 'Notes and decisions the whole team can search.' },\n { icon: 'Bot', title: 'Agent answers', line: 'Ask a question and see where the answer came from.' },\n { icon: 'Paperclip', title: 'Files', line: 'Keep a file next to the talk about it.' },\n { icon: 'Search', title: 'Search', line: 'Find any message, task or file from one box.' },\n] as const;\n\nexport default function FeatureGridCards() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"features\" name=\"Features\" statement=\"Everything your team needs to stay on the same page.\" />\n {/* Three across from md, one on a phone. Nothing here is a link, so nothing looks like one. */}\n <Grid columns={3}>\n {features.map((f) => (\n <Surface key={f.title} padding=\"medium\">\n <Stack gap=\"medium\">\n <Icon name={f.icon} size=\"medium\" color=\"secondary\" />\n <Heading level={3} size=\"h6\">{f.title}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{f.line}</Paragraph>\n </Stack>\n </Surface>\n ))}\n </Grid>\n </PageSection>\n </PageShell>\n );\n}\n",
2422
+ "uses": [
2423
+ "Grid",
2424
+ "Heading",
2425
+ "Icon",
2426
+ "PageSection",
2427
+ "PageShell",
2428
+ "Paragraph",
2429
+ "SectionIntro",
2430
+ "Stack",
2431
+ "Surface"
2432
+ ]
2433
+ },
2434
+ {
2435
+ "id": "rows",
2436
+ "title": "Rows with a picture",
2437
+ "useWhen": "Two to four features each need a picture to be understood.",
2438
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport NumberedRow from 'oneslash-design-system/components/numberedRow';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Image from 'oneslash-design-system/components/image';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Stand-ins for pictures of the product. A real page passes screenshots.\nconst channels =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 320'%3E%3Crect width='480' height='320' fill='%23eef2f6'/%3E%3Crect x='30' y='30' width='120' height='260' rx='10' fill='%23dfe7ef'/%3E%3Crect x='170' y='40' width='200' height='36' rx='10' fill='%23ffffff'/%3E%3Crect x='230' y='96' width='220' height='36' rx='10' fill='%232f6b4f'/%3E%3Crect x='170' y='152' width='180' height='36' rx='10' fill='%23ffffff'/%3E%3Crect x='170' y='250' width='280' height='36' rx='10' fill='%23ffffff'/%3E%3C/svg%3E\";\nconst knowledge =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 320'%3E%3Crect width='480' height='320' fill='%23efe9df'/%3E%3Crect x='40' y='40' width='400' height='40' rx='10' fill='%23ffffff'/%3E%3Crect x='40' y='100' width='190' height='170' rx='10' fill='%23ffffff'/%3E%3Crect x='250' y='100' width='190' height='80' rx='10' fill='%23dfe7ef'/%3E%3Crect x='250' y='190' width='190' height='80' rx='10' fill='%23dfe7ef'/%3E%3C/svg%3E\";\nconst agent =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 320'%3E%3Crect width='480' height='320' fill='%23e6efe9'/%3E%3Crect x='40' y='40' width='260' height='40' rx='10' fill='%23ffffff'/%3E%3Crect x='180' y='100' width='260' height='60' rx='10' fill='%232f6b4f'/%3E%3Crect x='40' y='180' width='300' height='60' rx='10' fill='%23ffffff'/%3E%3Crect x='40' y='256' width='200' height='30' rx='10' fill='%23dfe7ef'/%3E%3C/svg%3E\";\n\nexport default function FeatureGridRows() {\n return (\n <PageShell wide>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"features\" name=\"Features\" statement=\"Three things Acme does for your team.\" />\n {/* Each row is a number, a title, a few words and a picture. The picture is beside the words from 2xl and swaps sides each row, and under them below that. */}\n <Stack gap=\"giant\">\n <NumberedRow\n index={0}\n title=\"Channels and threads\"\n proof=\"One place for talk and for tasks.\"\n visual={<Image src={channels} alt=\"A channel with three messages and a list of channels beside it\" width={480} height={320} />}\n >\n <Paragraph tone=\"secondary\" measure=\"none\">Talk in channels. Turn any message into a task with its own thread.</Paragraph>\n </NumberedRow>\n <NumberedRow\n index={1}\n title=\"Notes the whole team can search\"\n proof=\"Search finds a decision, not only a message.\"\n visual={<Image src={knowledge} alt=\"A search box over a page of notes and two smaller notes\" width={480} height={320} />}\n >\n <Paragraph tone=\"secondary\" measure=\"none\">Write a note once. Everyone on the team finds it in the same place.</Paragraph>\n </NumberedRow>\n <NumberedRow\n index={2}\n title=\"Answers that show their source\"\n proof=\"Its answers say where they came from.\"\n visual={<Image src={agent} alt=\"The agent's reply to a question, with the message it used linked under it\" width={480} height={320} />}\n >\n <Paragraph tone=\"secondary\" measure=\"none\">Ask a question. The agent answers and links to the message it used.</Paragraph>\n </NumberedRow>\n </Stack>\n </PageSection>\n </PageShell>\n );\n}\n",
2439
+ "uses": [
2440
+ "Image",
2441
+ "NumberedRow",
2442
+ "PageSection",
2443
+ "PageShell",
2444
+ "Paragraph",
2445
+ "SectionIntro",
2446
+ "Stack"
2447
+ ]
2448
+ }
2449
+ ]
2450
+ },
1935
2451
  {
1936
2452
  "id": "feedback-form",
1937
2453
  "title": "Feedback form",
@@ -2138,6 +2654,65 @@
2138
2654
  "Do not change the submit Button's label while it is loading, such as to 'Saving…'."
2139
2655
  ]
2140
2656
  },
2657
+ {
2658
+ "id": "image-viewer",
2659
+ "title": "Image viewer",
2660
+ "kind": "design",
2661
+ "level": "organism",
2662
+ "area": "content",
2663
+ "situation": "A page shows images small, and a person wants to see one larger without leaving the page.",
2664
+ "do": [
2665
+ "Show each image as a `LightboxThumbnail` and keep the open state and the index of the shown image in your page. For `gallery`, put the thumbnails in a `Grid compact`, two across on a phone.",
2666
+ "Render one `Lightbox` for the page with the list of images, the `index`, `onIndexChange`, `isOpen` and `onClose`. Give it an `aria-label` that names the set, such as \"Pictures\".",
2667
+ "Write alt text that says what the image shows, such as \"A laptop on a wooden desk, its screen blue\". It names the thumbnail and stands in for an image that fails to load.",
2668
+ "Add a `caption` when the image needs words. The viewer shows it under the image and uses it as its title.",
2669
+ "Pass two or more images to get the arrows: the viewer shows 'Previous image', 'Next image' and '2 of 3' after the title. ArrowLeft, ArrowRight and a swipe step; the first and the last image stop there.",
2670
+ "Pass a single image in a list too, so the page keeps one way to open an image. The viewer then shows no arrows and no count.",
2671
+ "Let Escape, the backdrop and 'Close' close the viewer. Focus goes back to the thumbnail that opened it.",
2672
+ "Count on the viewer when an image fails to load: it shows 'This image could not be loaded.' with its alt text, and the arrows still work.",
2673
+ "Follow the case 'Attachments' for images that sit in a message."
2674
+ ],
2675
+ "dont": [
2676
+ "Do not open an image from a click on an `Image`. Use `LightboxThumbnail`, a button that a keyboard reaches.",
2677
+ "Do not leave the alt text empty on a thumbnail, or write \"image\" or a file name.",
2678
+ "Do not build a full-screen layer with a portal of your own. `Lightbox` is a dialog with a focus trap and the focus return.",
2679
+ "Do not handle Escape or the arrow keys with a listener of your own. The viewer does.",
2680
+ "Do not use the viewer for video, or for a page that has one image and nothing to see larger.",
2681
+ "Do not hide the arrows on a phone. A swipe is a second way to step, not the only one."
2682
+ ],
2683
+ "native": "On Apple use a `fullScreenCover` with a `TabView` in `page` style, and `accessibilityLabel` on each image. On Android use a full-screen dialog with a `HorizontalPager` and a content description on each image.",
2684
+ "options": [
2685
+ {
2686
+ "id": "gallery",
2687
+ "title": "Several images opened from thumbnails",
2688
+ "useWhen": "Two or more images that a person may want to step through.",
2689
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Lightbox, { LightboxThumbnail } from 'oneslash-design-system/components/lightbox';\nimport { Grid, PageSection } from 'oneslash-design-system/components/layout';\n\n// Three drawings stand in for the photos. A real page passes its own files.\nconst hillside =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E\";\nconst desk =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E\";\nconst board =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3Crect x='160' y='170' width='240' height='20' rx='10' fill='%23aab8c6'/%3E%3Crect x='160' y='220' width='360' height='16' rx='8' fill='%23c2cfdb'/%3E%3Crect x='160' y='260' width='320' height='16' rx='8' fill='%23c2cfdb'/%3E%3C/svg%3E\";\n\nconst images = [\n { src: hillside, alt: 'A green hillside under a pale sky with the sun on the right', caption: 'The hill behind the new office.' },\n { src: desk, alt: 'A laptop on a wooden desk, its screen blue', caption: 'A desk set up for the first day.' },\n { src: board, alt: 'A thread beside a note, with the decision marked in green', caption: 'A decision, with the notes that led to it.' },\n];\n\nexport default function ImageViewerGallery() {\n const [open, setOpen] = useState(false);\n const [index, setIndex] = useState(0);\n return (\n <PageShell>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"image-viewer-gallery-intro\" name=\"Pictures\" statement=\"The office and a decision.\" />\n {/* Each thumbnail is a button named 'Open image: <alt>'. Closing the viewer gives focus back to the one that opened it. */}\n <Grid compact columns={3}>\n {images.map((image, i) => (\n <LightboxThumbnail\n key={image.alt}\n image={image}\n onOpen={() => {\n setIndex(i);\n setOpen(true);\n }}\n />\n ))}\n </Grid>\n </PageSection>\n <Lightbox images={images} index={index} onIndexChange={setIndex} isOpen={open} onClose={() => setOpen(false)} aria-label=\"Pictures\" />\n </PageShell>\n );\n}\n",
2690
+ "uses": [
2691
+ "Grid",
2692
+ "Lightbox",
2693
+ "LightboxThumbnail",
2694
+ "PageSection",
2695
+ "PageShell",
2696
+ "SectionIntro"
2697
+ ]
2698
+ },
2699
+ {
2700
+ "id": "single",
2701
+ "title": "One image opened larger",
2702
+ "useWhen": "One image whose detail is too small to read in the page.",
2703
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Lightbox, { LightboxThumbnail } from 'oneslash-design-system/components/lightbox';\nimport { Grid, PageSection } from 'oneslash-design-system/components/layout';\n\n// One drawing stands in for the photo. A real page passes its own file.\nconst board =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3Crect x='160' y='170' width='240' height='20' rx='10' fill='%23aab8c6'/%3E%3Crect x='160' y='220' width='360' height='16' rx='8' fill='%23c2cfdb'/%3E%3Crect x='160' y='260' width='320' height='16' rx='8' fill='%23c2cfdb'/%3E%3C/svg%3E\";\n\nconst image = { src: board, alt: 'A thread beside a note, with the decision marked in green', caption: 'A decision, with the notes that led to it.' };\n\nexport default function ImageViewerSingle() {\n const [open, setOpen] = useState(false);\n return (\n <PageShell>\n <PageSection gap=\"xlarge\">\n <SectionIntro id=\"image-viewer-single-intro\" name=\"A decision\" statement=\"The thread and the note, side by side.\">\n <Paragraph tone=\"secondary\">Open the picture to read it at full size.</Paragraph>\n </SectionIntro>\n {/* One image: the viewer shows no arrows and no count. */}\n <Grid columns={2}>\n <LightboxThumbnail image={image} onOpen={() => setOpen(true)} />\n </Grid>\n </PageSection>\n <Lightbox images={[image]} index={0} onIndexChange={() => {}} isOpen={open} onClose={() => setOpen(false)} aria-label=\"Decision picture\" />\n </PageShell>\n );\n}\n",
2704
+ "uses": [
2705
+ "Grid",
2706
+ "Lightbox",
2707
+ "LightboxThumbnail",
2708
+ "PageSection",
2709
+ "PageShell",
2710
+ "Paragraph",
2711
+ "SectionIntro"
2712
+ ]
2713
+ }
2714
+ ]
2715
+ },
2141
2716
  {
2142
2717
  "id": "import-checklist",
2143
2718
  "title": "Import checklist",
@@ -2465,23 +3040,126 @@
2465
3040
  ]
2466
3041
  },
2467
3042
  {
2468
- "id": "with-upcoming",
2469
- "title": "The next charge first",
2470
- "useWhen": "The next charge is not the plan price, for example after a member joined mid-month, so it comes first and says why.",
2471
- "source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads these from the server. The plan is $8.00 a member each month; a fourth member\n// joined on Nov 16, so the next charge also covers the 15 days left in November ($8.00 x 15/30).\nconst perMember = 8;\nconst members = 4;\nconst regular = perMember * members;\nconst added = 4;\nconst upcoming = { date: 'Dec 1, 2026', description: 'Pro plan, Dec 2026', amount: regular + added };\n\nconst paid = [\n { id: 'inv-0', date: 'Nov 1, 2026', description: 'Pro plan, Nov 2026', amount: 24, status: 'Paid' },\n { id: 'inv-1', date: 'Oct 1, 2026', description: 'Pro plan, Oct 2026', amount: 24, status: 'Paid' },\n { id: 'inv-2', date: 'Sep 1, 2026', description: 'Pro plan, Sep 2026', amount: 24, status: 'Paid' },\n];\n\nexport default function InvoiceListWithUpcoming() {\n const [explaining, setExplaining] = useState(false);\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\">Invoices</Heading>\n <TableContainer aria-label=\"Invoices\" minWidth=\"640px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"130px\">Date</TableHeaderCell>\n <TableHeaderCell>Description</TableHeaderCell>\n <TableHeaderCell width=\"100px\" align=\"right\">Amount</TableHeaderCell>\n <TableHeaderCell width=\"110px\">Status</TableHeaderCell>\n <TableHeaderCell width=\"130px\">Download</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {/* The next charge is the first row. It has no invoice yet, so it has no Download link. */}\n <TableRow>\n <TableCell width=\"130px\">{upcoming.date}</TableCell>\n <TableCell>\n <Stack gap=\"small\" align=\"start\">\n {upcoming.description}\n {/* The label never changes. The state is in aria-expanded. */}\n <Button\n size=\"small\"\n type=\"tertiary\"\n state=\"enabled\"\n label=\"Why Is This Higher?\"\n aria-expanded={explaining}\n aria-controls=\"invoice-list-upcoming-why\"\n onClickButton={() => setExplaining((open) => !open)}\n />\n {explaining && (\n <Paragraph id=\"invoice-list-upcoming-why\" tone=\"secondary\" size=\"body2\" measure=\"none\">\n {`Your regular charge is ${formatMoney(regular)}: ${members} members at ${formatMoney(perMember)}. This one is ${formatMoney(upcoming.amount)} because it also adds ${formatMoney(added)} for Omar Reyes, who joined on Nov 16, for the 15 days left in November. It happens once. The charge after this is ${formatMoney(regular)}.`}\n </Paragraph>\n )}\n </Stack>\n </TableCell>\n <TableCell width=\"100px\" align=\"right\">{formatMoney(upcoming.amount)}</TableCell>\n <TableCell width=\"110px\">\n <Tag variant=\"dot\" size=\"small\" color=\"info\" label=\"Upcoming\" />\n </TableCell>\n <TableCell width=\"130px\">{''}</TableCell>\n </TableRow>\n {paid.map((inv) => (\n <TableRow key={inv.id}>\n <TableCell width=\"130px\">{inv.date}</TableCell>\n <TableCell>{inv.description}</TableCell>\n <TableCell width=\"100px\" align=\"right\">{formatMoney(inv.amount)}</TableCell>\n <TableCell width=\"110px\">\n <Tag variant=\"textOnly\" size=\"small\" label={inv.status} />\n </TableCell>\n <TableCell width=\"130px\">\n {/* A real app links to the file on its own server. */}\n <Button\n size=\"small\"\n type=\"tertiary\"\n state=\"enabled\"\n label=\"Download\"\n aria-label={`Download invoice for ${inv.date}, opens in a new tab`}\n actionIcon=\"ExternalLink\"\n href={`https://acme.example/invoices/${inv.id}.pdf`}\n openInNewTab\n />\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n </Stack>\n </Center>\n );\n}\n",
3043
+ "id": "with-upcoming",
3044
+ "title": "The next charge first",
3045
+ "useWhen": "The next charge is not the plan price, for example after a member joined mid-month, so it comes first and says why.",
3046
+ "source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads these from the server. The plan is $8.00 a member each month; a fourth member\n// joined on Nov 16, so the next charge also covers the 15 days left in November ($8.00 x 15/30).\nconst perMember = 8;\nconst members = 4;\nconst regular = perMember * members;\nconst added = 4;\nconst upcoming = { date: 'Dec 1, 2026', description: 'Pro plan, Dec 2026', amount: regular + added };\n\nconst paid = [\n { id: 'inv-0', date: 'Nov 1, 2026', description: 'Pro plan, Nov 2026', amount: 24, status: 'Paid' },\n { id: 'inv-1', date: 'Oct 1, 2026', description: 'Pro plan, Oct 2026', amount: 24, status: 'Paid' },\n { id: 'inv-2', date: 'Sep 1, 2026', description: 'Pro plan, Sep 2026', amount: 24, status: 'Paid' },\n];\n\nexport default function InvoiceListWithUpcoming() {\n const [explaining, setExplaining] = useState(false);\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\">Invoices</Heading>\n <TableContainer aria-label=\"Invoices\" minWidth=\"640px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"130px\">Date</TableHeaderCell>\n <TableHeaderCell>Description</TableHeaderCell>\n <TableHeaderCell width=\"100px\" align=\"right\">Amount</TableHeaderCell>\n <TableHeaderCell width=\"110px\">Status</TableHeaderCell>\n <TableHeaderCell width=\"130px\">Download</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {/* The next charge is the first row. It has no invoice yet, so it has no Download link. */}\n <TableRow>\n <TableCell width=\"130px\">{upcoming.date}</TableCell>\n <TableCell>\n <Stack gap=\"small\" align=\"start\">\n {upcoming.description}\n {/* The label never changes. The state is in aria-expanded. */}\n <Button\n size=\"small\"\n type=\"tertiary\"\n state=\"enabled\"\n label=\"Why Is This Higher?\"\n aria-expanded={explaining}\n aria-controls=\"invoice-list-upcoming-why\"\n onClickButton={() => setExplaining((open) => !open)}\n />\n {explaining && (\n <Paragraph id=\"invoice-list-upcoming-why\" tone=\"secondary\" size=\"body2\" measure=\"none\">\n {`Your regular charge is ${formatMoney(regular)}: ${members} members at ${formatMoney(perMember)}. This one is ${formatMoney(upcoming.amount)} because it also adds ${formatMoney(added)} for Omar Reyes, who joined on Nov 16, for the 15 days left in November. It happens once. The charge after this is ${formatMoney(regular)}.`}\n </Paragraph>\n )}\n </Stack>\n </TableCell>\n <TableCell width=\"100px\" align=\"right\">{formatMoney(upcoming.amount)}</TableCell>\n <TableCell width=\"110px\">\n <Tag variant=\"dot\" size=\"small\" color=\"info\" label=\"Upcoming\" />\n </TableCell>\n <TableCell width=\"130px\">{''}</TableCell>\n </TableRow>\n {paid.map((inv) => (\n <TableRow key={inv.id}>\n <TableCell width=\"130px\">{inv.date}</TableCell>\n <TableCell>{inv.description}</TableCell>\n <TableCell width=\"100px\" align=\"right\">{formatMoney(inv.amount)}</TableCell>\n <TableCell width=\"110px\">\n <Tag variant=\"textOnly\" size=\"small\" label={inv.status} />\n </TableCell>\n <TableCell width=\"130px\">\n {/* A real app links to the file on its own server. */}\n <Button\n size=\"small\"\n type=\"tertiary\"\n state=\"enabled\"\n label=\"Download\"\n aria-label={`Download invoice for ${inv.date}, opens in a new tab`}\n actionIcon=\"ExternalLink\"\n href={`https://acme.example/invoices/${inv.id}.pdf`}\n openInNewTab\n />\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n </Stack>\n </Center>\n );\n}\n",
3047
+ "uses": [
3048
+ "Button",
3049
+ "Center",
3050
+ "Heading",
3051
+ "Paragraph",
3052
+ "Stack",
3053
+ "TableCell",
3054
+ "TableContainer",
3055
+ "TableHeader",
3056
+ "TableHeaderCell",
3057
+ "TableRow",
3058
+ "Tag",
3059
+ "formatMoney"
3060
+ ]
3061
+ }
3062
+ ]
3063
+ },
3064
+ {
3065
+ "id": "landing-hero",
3066
+ "title": "Hero",
3067
+ "kind": "design",
3068
+ "level": "organism",
3069
+ "area": "marketing",
3070
+ "situation": "A marketing page opens by saying what the product is and asking for one thing.",
3071
+ "do": [
3072
+ "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
3073
+ "Use `PageHeader` with `level={1}`, an `eyebrow` that says what kind of product it is, a title and a lede. The page has one h1.",
3074
+ "Put the main action first, a primary `Button` labeled 'Sign Up', then one secondary action such as 'See How It Works'. Use `size=\"large\"`.",
3075
+ "Put a short line under the actions that removes a doubt: 'Start on Free with 3 members. No card needed.'",
3076
+ "Put the two actions in a `Cluster`. On a phone they sit side by side, and the second moves to its own line when they do not fit.",
3077
+ "Keep the words left aligned, also in `centered`. A centered block of text is hard to read past two lines.",
3078
+ "Let the title wrap. A long word breaks inside the column and nothing scrolls sideways.",
3079
+ "Name the picture for a screen reader: say what is in it. Use `Figure` with `crop`, so the picture keeps its shape at every width.",
3080
+ "Show the words first and the picture under them on a phone. `Grid columns={2}` stacks the two parts in the order you write them."
3081
+ ],
3082
+ "dont": [
3083
+ "Do not add a second primary Button to the hero, or a third action.",
3084
+ "Do not put a second h1 on the page.",
3085
+ "Do not move the title or swap its words with a timer.",
3086
+ "Do not hide the main action under the picture on a phone."
3087
+ ],
3088
+ "native": "On Apple and Android an app has no hero. The first screen is the product, or a short sign-in.",
3089
+ "options": [
3090
+ {
3091
+ "id": "centered",
3092
+ "title": "Words in one column",
3093
+ "useWhen": "The words carry the page: the product is easy to say and a picture would add little.",
3094
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Button from 'oneslash-design-system/components/button';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nexport default function LandingHeroCentered() {\n return (\n <PageShell>\n <Stack gap=\"xxlarge\">\n {/* The only h1 on the page: level 1 is the default. */}\n <PageHeader\n level={1}\n eyebrow=\"Team workspace with an AI agent\"\n title=\"A shared workspace for your team and its agent\"\n lede=\"Plan the work in threads, keep notes the whole team can search, and ask the agent when you need an answer.\"\n />\n {/* The rule's one main action first, then one secondary. They wrap on a phone. */}\n <Stack gap=\"medium\">\n <Cluster>\n <Button size=\"large\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />\n <Button size=\"large\" type=\"secondary\" state=\"enabled\" label=\"See How It Works\" href=\"#how-it-works\" />\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Start on Free with 3 members. No card needed.</Paragraph>\n </Stack>\n </Stack>\n </PageShell>\n );\n}\n",
3095
+ "uses": [
3096
+ "Button",
3097
+ "Cluster",
3098
+ "PageHeader",
3099
+ "PageShell",
3100
+ "Paragraph",
3101
+ "Stack"
3102
+ ]
3103
+ },
3104
+ {
3105
+ "id": "split",
3106
+ "title": "Words beside a picture",
3107
+ "useWhen": "A picture of the product explains it faster than words.",
3108
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Button from 'oneslash-design-system/components/button';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// A stand-in for a picture of the product. A real page passes a screenshot.\nconst appPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 480'%3E%3Crect width='640' height='480' fill='%23eef2f6'/%3E%3Crect width='170' height='480' fill='%23dfe7ef'/%3E%3Crect x='20' y='28' width='90' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='20' y='72' width='120' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='20' y='100' width='100' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='20' y='128' width='110' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='200' y='28' width='180' height='14' rx='7' fill='%23aab8c6'/%3E%3Crect x='200' y='80' width='300' height='44' rx='10' fill='%23ffffff'/%3E%3Crect x='260' y='148' width='340' height='44' rx='10' fill='%232f6b4f'/%3E%3Crect x='200' y='216' width='260' height='44' rx='10' fill='%23ffffff'/%3E%3Crect x='200' y='400' width='400' height='40' rx='10' fill='%23ffffff'/%3E%3C/svg%3E\";\n\nexport default function LandingHeroSplit() {\n return (\n <PageShell wide>\n {/* Two columns from md. On a phone the words come first and the picture sits under them. */}\n <Grid columns={2} gap=\"giant\">\n <Stack gap=\"xxlarge\">\n <PageHeader\n level={1}\n eyebrow=\"Team workspace with an AI agent\"\n title=\"A shared workspace for your team and its agent\"\n lede=\"Plan the work in threads, keep notes the whole team can search, and ask the agent when you need an answer.\"\n />\n <Stack gap=\"medium\">\n <Cluster>\n <Button size=\"large\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />\n <Button size=\"large\" type=\"secondary\" state=\"enabled\" label=\"See How It Works\" href=\"#how-it-works\" />\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Start on Free with 3 members. No card needed.</Paragraph>\n </Stack>\n </Stack>\n <Figure crop={4 / 3}>\n <Image src={appPicture} alt=\"The Acme workspace: a list of channels beside a conversation with the agent\" width={640} height={480} />\n </Figure>\n </Grid>\n </PageShell>\n );\n}\n",
3109
+ "uses": [
3110
+ "Button",
3111
+ "Cluster",
3112
+ "Figure",
3113
+ "Grid",
3114
+ "Image",
3115
+ "PageHeader",
3116
+ "PageShell",
3117
+ "Paragraph",
3118
+ "Stack"
3119
+ ]
3120
+ }
3121
+ ]
3122
+ },
3123
+ {
3124
+ "id": "legal-page",
3125
+ "title": "Legal page",
3126
+ "kind": "design",
3127
+ "level": "page",
3128
+ "area": "content",
3129
+ "situation": "A person reads the terms or the privacy policy to find one answer in it, or reads all of it before they agree.",
3130
+ "do": [
3131
+ "Put an info `Alert` first with the words 'Sample text. This is not a real agreement.' on any page whose text is an example. Set `autoDismiss={false}`, so it stays. A real page has no such line and uses text written for the company.",
3132
+ "Use `PageHeader` with `level={1}`: one level 1 title, 'Terms of service', and `facts` with 'Last updated' 'Nov 16, 2026'. The date is the date of the text, not of the last deploy.",
3133
+ "Number the sections as level 2 headings: '1. Using Acme'. Give each an `id`, in the same order as the list beside the page.",
3134
+ "Put `OnThisPage` in the `aside` of `PageShell`, as the case 'On this page' says, with the same labels as the headings.",
3135
+ "Write paragraphs and `List`s at reading width, one idea to a paragraph. Use `marker=\"dot\"` for what a term covers and `marker=\"number\"` for steps in order.",
3136
+ "Name who the text is between, once, in the first section: 'Acme' and 'you'.",
3137
+ "End with a Contact section that names `help@acme.example` as the only address.",
3138
+ "Leave every section open. A person finds a word with find in page, and a closed panel hides what they look for."
3139
+ ],
3140
+ "dont": [
3141
+ "Do not put the sections in an accordion. Find in page does not search closed panels.",
3142
+ "Do not set each section in a card. A long text reads best in one column, with the headings doing the work.",
3143
+ "Do not copy the text of another company. A real page uses text a lawyer wrote for the company.",
3144
+ "Do not write a date without a year, or only \"recently updated\".",
3145
+ "Do not rely on the list of sections to make the page readable. It sits beside the page from the `xl` breakpoint, and a phone reads in order."
3146
+ ],
3147
+ "native": "On Apple open the text in an `SFSafariViewController`, so the address is the real one. On Android open it in a Custom Tab.",
3148
+ "options": [
3149
+ {
3150
+ "id": "sections",
3151
+ "title": "Numbered sections with a list beside them",
3152
+ "useWhen": "Terms or a privacy policy, which a person searches for one answer.",
3153
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// Generic sample text for a made-up service. A real page uses text written for the company.\nconst sections = [\n { id: 'legal-page-using', title: '1. Using Acme' },\n { id: 'legal-page-accounts', title: '2. Your account' },\n { id: 'legal-page-content', title: '3. Your content' },\n { id: 'legal-page-rules', title: '4. Rules of use' },\n { id: 'legal-page-ending', title: '5. Deleting your account' },\n { id: 'legal-page-contact', title: '6. Contact' },\n];\n\nconst items = sections.map(({ id, title }) => ({ id, label: title }));\n\nexport default function LegalPageSections() {\n return (\n <PageShell aside={<OnThisPage items={items} />}>\n <Stack gap=\"giant\">\n <Alert type=\"info\" variant=\"inline\" message=\"Sample text. This is not a real agreement.\" autoDismiss={false} />\n <PageHeader level={1} title=\"Terms of service\" facts={[{ label: 'Last updated', value: 'Nov 16, 2026' }]} />\n <Stack gap=\"xxlarge\">\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-using\">1. Using Acme</Heading>\n <Paragraph>These terms are between Acme and you. When you use the service, you agree to them. If you use it for a team, you say you may agree for that team.</Paragraph>\n <Paragraph>We may change the service and these terms. We tell you before a change that matters to you.</Paragraph>\n </Stack>\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-accounts\">2. Your account</Heading>\n <Paragraph>You keep your login details to yourself and tell us when you think someone else knows them. You answer for what happens under your account.</Paragraph>\n <List marker=\"dot\" size=\"body1\" items={['Give true details when you sign up.', 'Use one account for yourself.', 'Tell us if you lose access.']} />\n </Stack>\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-content\">3. Your content</Heading>\n <Paragraph>What you write and upload stays yours. You let us store it and show it to the people you choose, so the service can work.</Paragraph>\n <Paragraph>You can export your content or delete it at any time. Deleted content leaves our systems within 30 days.</Paragraph>\n </Stack>\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-rules\">4. Rules of use</Heading>\n <Paragraph>Use Acme only for lawful work, and treat other people with respect. Do not:</Paragraph>\n <List marker=\"dot\" size=\"body1\" items={['Break the law or ask others to.', 'Try to get into accounts that are not yours.', 'Send what harms the service or the people on it.']} />\n </Stack>\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-ending\">5. Deleting your account</Heading>\n <Paragraph>You can delete your account at any time from your settings. We may close it if you break these terms, and we tell you why when we do.</Paragraph>\n <List marker=\"number\" size=\"body1\" items={['Open Settings and choose Delete Account.', 'Confirm, and the account is deleted.', 'Export your content first if you want to keep it.']} />\n </Stack>\n <Stack gap=\"large\">\n <Heading level={2} size=\"h5\" id=\"legal-page-contact\">6. Contact</Heading>\n <Paragraph>Write to help@acme.example with any question about these terms.</Paragraph>\n </Stack>\n </Stack>\n </Stack>\n </PageShell>\n );\n}\n",
2472
3154
  "uses": [
2473
- "Button",
2474
- "Center",
3155
+ "Alert",
2475
3156
  "Heading",
3157
+ "List",
3158
+ "OnThisPage",
3159
+ "PageHeader",
3160
+ "PageShell",
2476
3161
  "Paragraph",
2477
- "Stack",
2478
- "TableCell",
2479
- "TableContainer",
2480
- "TableHeader",
2481
- "TableHeaderCell",
2482
- "TableRow",
2483
- "Tag",
2484
- "formatMoney"
3162
+ "Stack"
2485
3163
  ]
2486
3164
  }
2487
3165
  ]
@@ -2678,6 +3356,73 @@
2678
3356
  }
2679
3357
  ]
2680
3358
  },
3359
+ {
3360
+ "id": "long-form-page",
3361
+ "title": "Long-form page",
3362
+ "kind": "design",
3363
+ "level": "page",
3364
+ "area": "content",
3365
+ "situation": "A person reads one long piece, such as a post, a case study or a method, from the top down, and may come back to part of it.",
3366
+ "do": [
3367
+ "Use `PageHeader` with `level={1}`, a `title`, a `lede` of one or two sentences and `facts` for the date, the reading time and the author. The title is the one level 1 heading.",
3368
+ "Write the facts as 'Published' 'Nov 12, 2026', 'Reading time' '6 minutes' and 'Author' 'Dana Lee'. A number shows its unit, as the rule 'A number shows its unit and never shows 0 for unknown' says.",
3369
+ "Put one hero `Figure` after the header, with an `Image` that has alt text and a caption when it needs one.",
3370
+ "Make each section a `SectionIntro`, whose name is the level 2 heading and gets an id for a link. Put the body under it as `Paragraph`s at reading width.",
3371
+ "Show the decisions or steps of a case study as `NumberedRow`s, each with a short title and the reason beneath it.",
3372
+ "Put further reading in a `List` of `Link`s, each named for the page it goes to.",
3373
+ "End the page as the case 'Page end' says: one `LinkCard` that names the next page to read, with the caption 'Next: Task threads'.",
3374
+ "Put `OnThisPage` in the `aside` of `PageShell` for `with-contents`, as the case 'On this page' says. Give every `SectionIntro` an `id` and pass the same ids and names as the items.",
3375
+ "Make the page read in order without the list. Below the `xl` breakpoint the list is not shown, and a phone scrolls."
3376
+ ],
3377
+ "dont": [
3378
+ "Do not pick `with-contents` for a post of two to four sections that people read through. Pick `article`, and they find the sections by scrolling.",
3379
+ "Do not put the list of sections in the page as well as beside it.",
3380
+ "Do not set the text wider than reading width. Let the figure and the numbered rows use the column.",
3381
+ "Do not end the page on a sign-up banner. A reader who finished the page wants the next thing to read.",
3382
+ "Do not hide a section behind an accordion. A reader who is in the middle of the page needs to find a word with find in page.",
3383
+ "Do not use a second level 1 heading in a section."
3384
+ ],
3385
+ "native": "On Apple use a `ScrollView` with a large title, and a `Menu` of sections that scrolls to one. On Android use a `LazyColumn` under a collapsing top app bar.",
3386
+ "options": [
3387
+ {
3388
+ "id": "article",
3389
+ "title": "An article read top to bottom",
3390
+ "useWhen": "A post or a case study that most people read from the first line to the last.",
3391
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport NumberedRow from 'oneslash-design-system/components/numberedRow';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Link from 'oneslash-design-system/components/link';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// A stand-in for the hero picture. A real page passes its own.\nconst hero =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3Crect x='160' y='170' width='240' height='20' rx='10' fill='%23aab8c6'/%3E%3Crect x='160' y='220' width='360' height='16' rx='8' fill='%23c2cfdb'/%3E%3Crect x='160' y='260' width='320' height='16' rx='8' fill='%23c2cfdb'/%3E%3C/svg%3E\";\n\nexport default function LongFormPageArticle() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader\n level={1}\n title=\"Why we keep decisions in threads\"\n lede=\"A decision made in a meeting is gone by Friday. We moved ours into the thread where the work happens, and this is what changed.\"\n facts={[\n { label: 'Published', value: 'Nov 12, 2026' },\n { label: 'Reading time', value: '6 minutes' },\n { label: 'Author', value: 'Dana Lee' },\n ]}\n />\n <Figure crop={16 / 9} caption=\"The thread for one decision, with the notes that led to it.\">\n <Image src={hero} alt=\"A thread beside a note, with the decision marked in green\" width={1280} height={720} />\n </Figure>\n <PageSection>\n <SectionIntro id=\"long-form-page-problem\" name=\"The problem\" statement=\"People remembered the decision. They did not remember why.\">\n <Paragraph>Every month someone asked why a screen worked the way it did. The answer was in a call that nobody wrote down.</Paragraph>\n <Paragraph>So the team spent the first ten minutes of each review arguing about a choice that was already made.</Paragraph>\n </SectionIntro>\n </PageSection>\n <PageSection>\n <SectionIntro id=\"long-form-page-decisions\" name=\"What we decided\" />\n <Stack gap=\"xlarge\">\n <NumberedRow index={0} title=\"A decision stays with the work it decides.\">\n <Paragraph>Anyone who opens the work sees the choice and the messages around it, so nobody has to ask.</Paragraph>\n </NumberedRow>\n <NumberedRow index={1} title=\"Each decision has one owner.\">\n <Paragraph>The owner writes it in a sentence and says what would change it. Ben Carter reviews it the same day.</Paragraph>\n </NumberedRow>\n <NumberedRow index={2} title=\"A decision can be reopened, with a reason.\" proof=\"The thread keeps both versions and the reason for the change.\">\n <Paragraph>Nothing is final for good. A new fact is a reason to look again, and the thread keeps both versions.</Paragraph>\n </NumberedRow>\n </Stack>\n </PageSection>\n <PageSection>\n <SectionIntro id=\"long-form-page-reading\" name=\"Further reading\" />\n <List\n size=\"body1\"\n items={[\n <Link key=\"a\" href=\"#how-channels-work\">How channels work</Link>,\n <Link key=\"b\" href=\"#writing-a-decision\">Writing a decision in one sentence</Link>,\n <Link key=\"c\" href=\"#reopening-a-decision\">Reopening a decision</Link>,\n ]}\n />\n </PageSection>\n {/* A reading page ends by pointing to the next page to read. */}\n <LinkCard href=\"#task-threads\" title=\"Task threads\" caption=\"Next: Task threads\" />\n </Stack>\n </PageShell>\n );\n}\n",
3392
+ "uses": [
3393
+ "Figure",
3394
+ "Image",
3395
+ "Link",
3396
+ "LinkCard",
3397
+ "List",
3398
+ "NumberedRow",
3399
+ "PageHeader",
3400
+ "PageSection",
3401
+ "PageShell",
3402
+ "Paragraph",
3403
+ "SectionIntro",
3404
+ "Stack"
3405
+ ]
3406
+ },
3407
+ {
3408
+ "id": "with-contents",
3409
+ "title": "With a list of sections beside it",
3410
+ "useWhen": "The page has five sections or more, and people jump between them or come back to one.",
3411
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport OnThisPage from 'oneslash-design-system/components/onThisPage';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// The same ids and names go to the sections and to the list. A real site builds both from one list.\nconst sections = [\n { id: 'long-form-page-start', name: 'Before you start', text: 'Pick one workspace for the trial. Invite two people who will use it every day, and keep the rest for later.' },\n { id: 'long-form-page-channels', name: 'Set up channels', text: 'Make a channel for each team or project. Name it for the subject, so a new member can tell where to write.' },\n { id: 'long-form-page-notes', name: 'Move your notes', text: 'Paste the notes you still use into a note. Leave old ones where they are until someone asks for them.' },\n { id: 'long-form-page-agent', name: 'Ask the agent', text: 'Ask a question in a channel. The agent answers from that workspace and names the notes it used.' },\n { id: 'long-form-page-review', name: 'Review after a week', text: 'Look at what the team used and what it left alone. Remove a channel that has had no message.' },\n];\n\nconst items = sections.map(({ id, name }) => ({ id, label: name }));\n\nconst filler = 'Write what you decide in the thread, in one sentence. Someone who opens the page next month should not need to ask you what happened.';\n\nexport default function LongFormPageWithContents() {\n return (\n <PageShell aside={<OnThisPage items={items} />}>\n <Stack gap=\"giant\">\n <PageHeader\n level={1}\n title=\"A first week with Acme\"\n lede=\"What to set up on day one, and what to leave until you need it.\"\n facts={[\n { label: 'Published', value: 'Nov 12, 2026' },\n { label: 'Reading time', value: '8 minutes' },\n { label: 'Author', value: 'Dana Lee' },\n ]}\n />\n {sections.map((s) => (\n <PageSection key={s.id}>\n <SectionIntro id={s.id} name={s.name}>\n <Paragraph>{s.text}</Paragraph>\n <Paragraph tone=\"secondary\">{filler}</Paragraph>\n {s.id === 'long-form-page-agent' && (\n <List marker=\"dot\" size=\"body1\" items={['Ask one question at a time.', 'Say which channel or note it is about.', 'Check the sources it names.']} />\n )}\n </SectionIntro>\n </PageSection>\n ))}\n <LinkCard href=\"#task-threads\" title=\"Task threads\" caption=\"Next: Task threads\" />\n </Stack>\n </PageShell>\n );\n}\n",
3412
+ "uses": [
3413
+ "LinkCard",
3414
+ "List",
3415
+ "OnThisPage",
3416
+ "PageHeader",
3417
+ "PageSection",
3418
+ "PageShell",
3419
+ "Paragraph",
3420
+ "SectionIntro",
3421
+ "Stack"
3422
+ ]
3423
+ }
3424
+ ]
3425
+ },
2681
3426
  {
2682
3427
  "id": "master-detail",
2683
3428
  "title": "List and detail",
@@ -2928,7 +3673,7 @@
2928
3673
  "id": "hover-toolbar",
2929
3674
  "title": "Toolbar on the row",
2930
3675
  "useWhen": "A product used with a pointer, with three or four frequent actions.",
2931
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },\n { id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },\n];\n\nexport default function MessageActionsHoverToolbar() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n const [copiedId, setCopiedId] = useState<string | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [draft, setDraft] = useState('');\n const [saving, setSaving] = useState(false);\n // The row whose footer asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n // One timer per request, so a save and a delete never clear each other's.\n const saveTimer = useRef<ReturnType<typeof setTimeout>>();\n const deleteTimer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Each row's buttons by row id, so focus can move to one when the thing that had it is gone.\n const reactButtons = useRef<Record<string, Focusable>>({});\n const editButtons = useRef<Record<string, Focusable>>({});\n const deleteButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the timers and closes every toast it opened.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(copyTimer.current);\n clearTimeout(saveTimer.current);\n clearTimeout(deleteTimer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const editingRow = thread.find((m) => m.id === editingId);\n const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;\n\n // A real app opens its reaction picker here; this one adds or removes a thumbs-up.\n function react(id: string) {\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, reacted: !m.reacted } : m)));\n }\n\n function copy(m: Row) {\n navigator.clipboard?.writeText(m.text).then(() => {\n if (!mounted.current) return;\n setCopiedId(m.id);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopiedId(null), 2000);\n }, () => {});\n }\n\n // The field takes focus, with the caret after the text.\n function startEditing(m: Row) {\n setDraft(m.text);\n setEditingId(m.id);\n focusNext.current = () => {\n const end = field.current?.value.length ?? 0;\n field.current?.focus();\n field.current?.setSelectionRange(end, end);\n };\n }\n\n // The field that had focus is gone, so focus goes to the row's Edit button.\n function stopEditing(id: string) {\n setEditingId(null);\n focusNext.current = () => editButtons.current[id]?.focus();\n }\n\n function cancelEditing() {\n if (saving || !editingId) return;\n stopEditing(editingId);\n }\n\n function save() {\n if (saving || !canSave || !editingId) return;\n const id = editingId;\n const value = draft.trim();\n setSaving(true);\n // Stands in for the request to the server.\n saveTimer.current = setTimeout(() => {\n setSaving(false);\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));\n stopEditing(id);\n }, 1200);\n }\n\n // The confirm opens in the row's footer, with focus on 'Cancel'.\n function askToDelete(id: string) {\n setConfirmingId(id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's Delete button.\n function keepMessage() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => deleteButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const next = thread[thread.findIndex((m) => m.id === id) + 1];\n setDeleting(true);\n // Stands in for the request to the server.\n deleteTimer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setThread((rows) => rows.filter((m) => m.id !== id));\n toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));\n // The row is gone: focus goes to the next row's first action, or to the message box when none follows.\n // If the next row's button is not on screen, focus goes to the message box.\n focusNext.current = () => ((next ? reactButtons.current[next.id] : null) ?? box.current)?.focus();\n }, 1200);\n }\n\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);\n setText('');\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const own = m.from === me;\n const editing = m.id === editingId;\n const confirming = m.id === confirmingId;\n return (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={\n <>\n {m.agent && <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />}\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n {m.agent && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>}\n {m.edited && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">(edited)</Paragraph>}\n </>\n }\n footer={\n m.reacted || confirming ? (\n <Stack gap=\"small\">\n {m.reacted && <Tag variant=\"contained\" size=\"small\" state=\"selected\" label=\"👍 1\" aria-label=\"Thumbs up, 1 reaction\" />}\n {confirming && (\n // The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" measure=\"none\">Delete this message?</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel deleting your message\" onClickButton={keepMessage} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label=\"Delete this message\" loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n </Stack>\n )}\n </Stack>\n ) : undefined\n }\n // Shown while the pointer is on the row or focus is in it, and always on a touch screen.\n actions={\n editing || confirming ? undefined : (\n <>\n <Tooltip title=\"Add reaction\">\n <IconButton\n ref={(el) => { reactButtons.current[m.id] = el; }}\n color=\"iconOnly\"\n state=\"enabled\"\n size=\"small\"\n iconName=\"SmilePlus\"\n ariaLabel={`Add reaction to message from ${m.from}`}\n onClick={() => react(m.id)}\n />\n </Tooltip>\n <Tooltip title={copiedId === m.id ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copiedId === m.id ? 'Check' : 'Copy'} ariaLabel={copiedId === m.id ? 'Copied' : `Copy message from ${m.from}`} onClick={() => copy(m)} />\n </Tooltip>\n {own && (\n <Tooltip title=\"Edit\">\n <IconButton ref={(el) => { editButtons.current[m.id] = el; }} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Pencil\" ariaLabel=\"Edit your message\" onClick={() => startEditing(m)} />\n </Tooltip>\n )}\n {own && (\n <Tooltip title=\"Delete\">\n <IconButton ref={(el) => { deleteButtons.current[m.id] = el; }} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Trash2\" ariaLabel=\"Delete your message\" onClick={() => askToDelete(m.id)} />\n </Tooltip>\n )}\n </>\n )\n }\n >\n {editing ? (\n // Edit works as the case 'Message edit' says.\n <Composer\n ref={field}\n id=\"message-actions-hover-edit\"\n aria-label=\"Edit message\"\n value={draft}\n onChange={setDraft}\n onSubmit={save}\n canSubmit={canSave}\n disabled={saving}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n cancelEditing();\n }\n }}\n actions={\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={saving ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelEditing} />\n <Button size=\"small\" type=\"primary\" state={canSave ? 'enabled' : 'disabled'} label=\"Save\" loading={saving} onClickButton={save} />\n </Cluster>\n }\n />\n ) : (\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n )}\n </Message>\n );\n })}\n </Stack>\n <Composer\n ref={box}\n id=\"message-actions-hover-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Center>\n );\n}\n",
3676
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },\n { id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },\n];\n\nexport default function MessageActionsHoverToolbar() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n const [copiedId, setCopiedId] = useState<string | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [draft, setDraft] = useState('');\n const [saving, setSaving] = useState(false);\n // The row whose footer asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n // One timer per request, so a save and a delete never clear each other's.\n const saveTimer = useRef<ReturnType<typeof setTimeout>>();\n const deleteTimer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Each row's buttons by row id, so focus can move to one when the thing that had it is gone.\n const reactButtons = useRef<Record<string, Focusable>>({});\n const editButtons = useRef<Record<string, Focusable>>({});\n const deleteButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the timers and closes every toast it opened.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(copyTimer.current);\n clearTimeout(saveTimer.current);\n clearTimeout(deleteTimer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const editingRow = thread.find((m) => m.id === editingId);\n const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;\n\n // A real app opens its reaction picker here; this one adds or removes a thumbs-up.\n function react(id: string) {\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, reacted: !m.reacted } : m)));\n }\n\n function copy(m: Row) {\n navigator.clipboard?.writeText(m.text).then(() => {\n if (!mounted.current) return;\n setCopiedId(m.id);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopiedId(null), 2000);\n }, () => {});\n }\n\n // The field takes focus, with the caret after the text.\n function startEditing(m: Row) {\n setDraft(m.text);\n setEditingId(m.id);\n focusNext.current = () => {\n const end = field.current?.value.length ?? 0;\n field.current?.focus();\n field.current?.setSelectionRange(end, end);\n };\n }\n\n // The field that had focus is gone, so focus goes to the row's Edit button.\n function stopEditing(id: string) {\n setEditingId(null);\n focusNext.current = () => editButtons.current[id]?.focus();\n }\n\n function cancelEditing() {\n if (saving || !editingId) return;\n stopEditing(editingId);\n }\n\n function save() {\n if (saving || !canSave || !editingId) return;\n const id = editingId;\n const value = draft.trim();\n setSaving(true);\n // Stands in for the request to the server.\n saveTimer.current = setTimeout(() => {\n setSaving(false);\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));\n stopEditing(id);\n }, 1200);\n }\n\n // The confirm opens in the row's footer, with focus on 'Cancel'.\n function askToDelete(id: string) {\n setConfirmingId(id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's Delete button.\n function keepMessage() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => deleteButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const next = thread[thread.findIndex((m) => m.id === id) + 1];\n setDeleting(true);\n // Stands in for the request to the server.\n deleteTimer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setThread((rows) => rows.filter((m) => m.id !== id));\n toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));\n // The row is gone: focus goes to the next row's first action, or to the message box when none follows.\n // If the next row's button is not on screen, focus goes to the message box.\n focusNext.current = () => ((next ? reactButtons.current[next.id] : null) ?? box.current)?.focus();\n }, 1200);\n }\n\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);\n setText('');\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const own = m.from === me;\n const editing = m.id === editingId;\n const confirming = m.id === confirmingId;\n return (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={\n <>\n {m.agent && <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />}\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n {m.agent && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>}\n {m.edited && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">(edited)</Paragraph>}\n </>\n }\n footer={\n m.reacted || confirming ? (\n <Stack gap=\"small\">\n {m.reacted && <Tag variant=\"contained\" size=\"small\" state=\"selected\" label=\"👍 1\" aria-label=\"Thumbs up, 1 reaction\" />}\n {confirming && (\n // The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" measure=\"none\">Delete this message?</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel deleting your message\" onClickButton={keepMessage} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label=\"Delete this message\" loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n </Stack>\n )}\n </Stack>\n ) : undefined\n }\n // Shown while the pointer is on the row or focus is in it, and always on a touch screen.\n actions={\n editing || confirming ? undefined : (\n <>\n <Tooltip title=\"Add reaction\">\n <IconButton\n ref={(el) => { reactButtons.current[m.id] = el; }}\n color=\"iconOnly\"\n state=\"enabled\"\n size=\"small\"\n iconName=\"SmilePlus\"\n ariaLabel={`Add reaction to message from ${m.from}`}\n onClick={() => react(m.id)}\n />\n </Tooltip>\n <Tooltip title={copiedId === m.id ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copiedId === m.id ? 'Check' : 'Copy'} ariaLabel={copiedId === m.id ? 'Copied' : `Copy message from ${m.from}`} onClick={() => copy(m)} />\n </Tooltip>\n {own && (\n <Tooltip title=\"Edit\">\n <IconButton ref={(el) => { editButtons.current[m.id] = el; }} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Pencil\" ariaLabel=\"Edit your message\" onClick={() => startEditing(m)} />\n </Tooltip>\n )}\n {own && (\n <Tooltip title=\"Delete\">\n <IconButton ref={(el) => { deleteButtons.current[m.id] = el; }} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Trash2\" ariaLabel=\"Delete your message\" onClick={() => askToDelete(m.id)} />\n </Tooltip>\n )}\n </>\n )\n }\n >\n {editing ? (\n // Edit works as the case 'Message edit' says.\n <Composer\n ref={field}\n id=\"message-actions-hover-edit\"\n aria-label=\"Edit message\"\n value={draft}\n onChange={setDraft}\n onSubmit={save}\n canSubmit={canSave}\n disabled={saving}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n cancelEditing();\n }\n }}\n actions={\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={saving ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelEditing} />\n <Button size=\"small\" type=\"primary\" state={canSave ? 'enabled' : 'disabled'} label=\"Save\" loading={saving} onClickButton={save} />\n </Cluster>\n }\n />\n ) : (\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n )}\n </Message>\n );\n })}\n </Stack>\n <Composer\n ref={box}\n id=\"message-actions-hover-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Center>\n );\n}\n",
2932
3677
  "uses": [
2933
3678
  "Button",
2934
3679
  "Center",
@@ -2952,7 +3697,7 @@
2952
3697
  "id": "menu",
2953
3698
  "title": "More menu",
2954
3699
  "useWhen": "There are more than four actions, or the product is used on a touch screen.",
2955
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },\n { id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },\n];\n\nexport default function MessageActionsMenu() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuRow, setMenuRow] = useState<Row | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [draft, setDraft] = useState('');\n const [saving, setSaving] = useState(false);\n // The row whose footer asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n // One timer per request, so a save and a delete never clear each other's.\n const saveTimer = useRef<ReturnType<typeof setTimeout>>();\n const deleteTimer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Each row's More button by row id, so focus can move to one when the thing that had it is gone.\n const moreButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the timers and closes every toast it opened.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(saveTimer.current);\n clearTimeout(deleteTimer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const editingRow = thread.find((m) => m.id === editingId);\n const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;\n\n // A real app opens its reaction picker here; this one adds or removes a thumbs-up.\n function react(m: Row) {\n setThread((rows) => rows.map((r) => (r.id === m.id ? { ...r, reacted: !r.reacted } : r)));\n }\n\n // The menu closes when an item is chosen, so a copy shows a toast rather than a check.\n function copy(m: Row) {\n navigator.clipboard?.writeText(m.text).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Message copied.' }));\n }, () => {});\n }\n\n // A real app sends the task to the server here.\n function createTask(m: Row) {\n toastIds.current.push(toast({ type: 'success', message: `Task created from ${m.from}'s message.` }));\n }\n\n // A real app asks for a reason in a Modal, then sends the report.\n function report(m: Row) {\n toastIds.current.push(toast({ type: 'success', message: `${m.from}'s message reported to the workspace admins.` }));\n }\n\n function openMenu(m: Row, anchor: HTMLElement) {\n if (menuOpen && menuRow?.id === m.id) {\n closeMenu();\n return;\n }\n setMenuRow(m);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Escape, a click outside and every item close the menu. Popover's returnFocus gives focus back to More.\n function closeMenu() {\n setMenuOpen(false);\n }\n\n function choose(action: (m: Row) => void) {\n if (!menuRow) return;\n const m = menuRow;\n closeMenu();\n action(m);\n }\n\n // The field takes focus, with the caret after the text.\n function startEditing(m: Row) {\n setDraft(m.text);\n setEditingId(m.id);\n focusNext.current = () => {\n const end = field.current?.value.length ?? 0;\n field.current?.focus();\n field.current?.setSelectionRange(end, end);\n };\n }\n\n // The field that had focus is gone, so focus goes to the row's More button.\n function stopEditing(id: string) {\n setEditingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function cancelEditing() {\n if (saving || !editingId) return;\n stopEditing(editingId);\n }\n\n function save() {\n if (saving || !canSave || !editingId) return;\n const id = editingId;\n const value = draft.trim();\n setSaving(true);\n // Stands in for the request to the server.\n saveTimer.current = setTimeout(() => {\n setSaving(false);\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));\n stopEditing(id);\n }, 1200);\n }\n\n // The confirm opens in the row's footer, with focus on 'Cancel'.\n function askToDelete(m: Row) {\n setConfirmingId(m.id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.\n function keepMessage() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const next = thread[thread.findIndex((m) => m.id === id) + 1];\n setDeleting(true);\n // Stands in for the request to the server.\n deleteTimer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setThread((rows) => rows.filter((m) => m.id !== id));\n toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));\n // The row is gone: focus goes to the next row's More button, or to the message box when none follows.\n // If the next row's button is not on screen, focus goes to the message box.\n focusNext.current = () => ((next ? moreButtons.current[next.id] : null) ?? box.current)?.focus();\n }, 1200);\n }\n\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);\n setText('');\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const editing = m.id === editingId;\n const confirming = m.id === confirmingId;\n return (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={\n <>\n {m.agent && <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />}\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n {m.agent && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>}\n {m.edited && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">(edited)</Paragraph>}\n </>\n }\n footer={\n m.reacted || confirming ? (\n <Stack gap=\"small\">\n {m.reacted && <Tag variant=\"contained\" size=\"small\" state=\"selected\" label=\"👍 1\" aria-label=\"Thumbs up, 1 reaction\" />}\n {confirming && (\n // The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" measure=\"none\">Delete this message?</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel deleting your message\" onClickButton={keepMessage} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label=\"Delete this message\" loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n </Stack>\n )}\n </Stack>\n ) : undefined\n }\n // One More button. Shown while the pointer is on the row or focus is in it, and always on a touch screen.\n // It stays on screen while its menu is open, though the pointer and focus are in the menu.\n actionsVisible={menuOpen && menuRow?.id === m.id}\n actions={\n editing || confirming ? undefined : (\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[m.id] = el; }}\n color=\"iconOnly\"\n state={menuOpen && menuRow?.id === m.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for message from ${m.from}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuRow?.id === m.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(m, e.currentTarget)}\n />\n </Tooltip>\n )\n }\n >\n {editing ? (\n // Edit works as the case 'Message edit' says.\n <Composer\n ref={field}\n id=\"message-actions-menu-edit\"\n aria-label=\"Edit message\"\n value={draft}\n onChange={setDraft}\n onSubmit={save}\n canSubmit={canSave}\n disabled={saving}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n cancelEditing();\n }\n }}\n actions={\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={saving ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelEditing} />\n <Button size=\"small\" type=\"primary\" state={canSave ? 'enabled' : 'disabled'} label=\"Save\" loading={saving} onClickButton={save} />\n </Cluster>\n }\n />\n ) : (\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n )}\n </Message>\n );\n })}\n </Stack>\n <Composer\n ref={box}\n id=\"message-actions-menu-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n {/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={closeMenu} returnFocus>\n <Menu navigable aria-label=\"Message actions\" width={200}>\n <MenuItem size=\"small\" iconName=\"SmilePlus\" label=\"Add Reaction\" onClick={() => choose(react)} />\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Copy\" onClick={() => choose(copy)} />\n {menuRow?.from === me && <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Edit\" onClick={() => choose(startEditing)} />}\n <MenuItem size=\"small\" iconName=\"ClipboardPlus\" label=\"Create Task\" onClick={() => choose(createTask)} />\n {menuRow?.from !== me && <MenuItem size=\"small\" iconName=\"Flag\" label=\"Report\" onClick={() => choose(report)} />}\n {menuRow?.from === me && <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={() => choose(askToDelete)} />}\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
3700
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },\n { id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },\n];\n\nexport default function MessageActionsMenu() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuRow, setMenuRow] = useState<Row | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [draft, setDraft] = useState('');\n const [saving, setSaving] = useState(false);\n // The row whose footer asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n // One timer per request, so a save and a delete never clear each other's.\n const saveTimer = useRef<ReturnType<typeof setTimeout>>();\n const deleteTimer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Each row's More button by row id, so focus can move to one when the thing that had it is gone.\n const moreButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the timers and closes every toast it opened.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(saveTimer.current);\n clearTimeout(deleteTimer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const editingRow = thread.find((m) => m.id === editingId);\n const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;\n\n // A real app opens its reaction picker here; this one adds or removes a thumbs-up.\n function react(m: Row) {\n setThread((rows) => rows.map((r) => (r.id === m.id ? { ...r, reacted: !r.reacted } : r)));\n }\n\n // The menu closes when an item is chosen, so a copy shows a toast rather than a check.\n function copy(m: Row) {\n navigator.clipboard?.writeText(m.text).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Message copied.' }));\n }, () => {});\n }\n\n // A real app sends the task to the server here.\n function createTask(m: Row) {\n toastIds.current.push(toast({ type: 'success', message: `Task created from ${m.from}'s message.` }));\n }\n\n // A real app asks for a reason in a Modal, then sends the report.\n function report(m: Row) {\n toastIds.current.push(toast({ type: 'success', message: `${m.from}'s message reported to the workspace admins.` }));\n }\n\n function openMenu(m: Row, anchor: HTMLElement) {\n if (menuOpen && menuRow?.id === m.id) {\n closeMenu();\n return;\n }\n setMenuRow(m);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Escape, a click outside and every item close the menu. Popover's returnFocus gives focus back to More.\n function closeMenu() {\n setMenuOpen(false);\n }\n\n function choose(action: (m: Row) => void) {\n if (!menuRow) return;\n const m = menuRow;\n closeMenu();\n action(m);\n }\n\n // The field takes focus, with the caret after the text.\n function startEditing(m: Row) {\n setDraft(m.text);\n setEditingId(m.id);\n focusNext.current = () => {\n const end = field.current?.value.length ?? 0;\n field.current?.focus();\n field.current?.setSelectionRange(end, end);\n };\n }\n\n // The field that had focus is gone, so focus goes to the row's More button.\n function stopEditing(id: string) {\n setEditingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function cancelEditing() {\n if (saving || !editingId) return;\n stopEditing(editingId);\n }\n\n function save() {\n if (saving || !canSave || !editingId) return;\n const id = editingId;\n const value = draft.trim();\n setSaving(true);\n // Stands in for the request to the server.\n saveTimer.current = setTimeout(() => {\n setSaving(false);\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));\n stopEditing(id);\n }, 1200);\n }\n\n // The confirm opens in the row's footer, with focus on 'Cancel'.\n function askToDelete(m: Row) {\n setConfirmingId(m.id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.\n function keepMessage() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const next = thread[thread.findIndex((m) => m.id === id) + 1];\n setDeleting(true);\n // Stands in for the request to the server.\n deleteTimer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setThread((rows) => rows.filter((m) => m.id !== id));\n toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));\n // The row is gone: focus goes to the next row's More button, or to the message box when none follows.\n // If the next row's button is not on screen, focus goes to the message box.\n focusNext.current = () => ((next ? moreButtons.current[next.id] : null) ?? box.current)?.focus();\n }, 1200);\n }\n\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);\n setText('');\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const editing = m.id === editingId;\n const confirming = m.id === confirmingId;\n return (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={\n <>\n {m.agent && <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />}\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n {m.agent && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>}\n {m.edited && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">(edited)</Paragraph>}\n </>\n }\n footer={\n m.reacted || confirming ? (\n <Stack gap=\"small\">\n {m.reacted && <Tag variant=\"contained\" size=\"small\" state=\"selected\" label=\"👍 1\" aria-label=\"Thumbs up, 1 reaction\" />}\n {confirming && (\n // The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" measure=\"none\">Delete this message?</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel deleting your message\" onClickButton={keepMessage} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label=\"Delete this message\" loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n </Stack>\n )}\n </Stack>\n ) : undefined\n }\n // One More button. Shown while the pointer is on the row or focus is in it, and always on a touch screen.\n // It stays on screen while its menu is open, though the pointer and focus are in the menu.\n actionsVisible={menuOpen && menuRow?.id === m.id}\n actions={\n editing || confirming ? undefined : (\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[m.id] = el; }}\n color=\"iconOnly\"\n state={menuOpen && menuRow?.id === m.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for message from ${m.from}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuRow?.id === m.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(m, e.currentTarget)}\n />\n </Tooltip>\n )\n }\n >\n {editing ? (\n // Edit works as the case 'Message edit' says.\n <Composer\n ref={field}\n id=\"message-actions-menu-edit\"\n aria-label=\"Edit message\"\n value={draft}\n onChange={setDraft}\n onSubmit={save}\n canSubmit={canSave}\n disabled={saving}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n cancelEditing();\n }\n }}\n actions={\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={saving ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={cancelEditing} />\n <Button size=\"small\" type=\"primary\" state={canSave ? 'enabled' : 'disabled'} label=\"Save\" loading={saving} onClickButton={save} />\n </Cluster>\n }\n />\n ) : (\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n )}\n </Message>\n );\n })}\n </Stack>\n <Composer\n ref={box}\n id=\"message-actions-menu-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n {/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={closeMenu} returnFocus>\n <Menu navigable aria-label=\"Message actions\" width={200}>\n <MenuItem size=\"small\" iconName=\"SmilePlus\" label=\"Add Reaction\" onClick={() => choose(react)} />\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Copy\" onClick={() => choose(copy)} />\n {menuRow?.from === me && <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Edit\" onClick={() => choose(startEditing)} />}\n <MenuItem size=\"small\" iconName=\"ClipboardPlus\" label=\"Create Task\" onClick={() => choose(createTask)} />\n {menuRow?.from !== me && <MenuItem size=\"small\" iconName=\"Flag\" label=\"Report\" onClick={() => choose(report)} />}\n {menuRow?.from === me && <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={() => choose(askToDelete)} />}\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
2956
3701
  "uses": [
2957
3702
  "Button",
2958
3703
  "Center",
@@ -2996,10 +3741,10 @@
2996
3741
  "Pass `canSubmit` so a message with files and no text can be sent.",
2997
3742
  "Keep the files and the text when a send fails. Show an inline error Alert above the message box, as the rule 'A form error shows next to the problem' says.",
2998
3743
  "Move focus to the next chip after a chip is removed, or to the message box when none is left, since the chip that had it is gone.",
2999
- "Show images in a sent message as thumbnails: a `Grid` of `<Figure crop>` with an `Image` each. Write `alt` text that says what the image shows.",
3744
+ "Show images in a sent message as thumbnails: a `Grid` of `LightboxThumbnail`s. Write `alt` text that says what the image shows.",
3000
3745
  "Show other files as `FileChip`s that open the file, with the kind ('PDF'), the name and the size.",
3001
- "Show a `FileChip` with the file's name in place of an image that fails to load, so the file can still be opened.",
3002
- "Let the person open an image at full size. The example shows the thumbnails only."
3746
+ "Keep each image's file reachable: when an image fails to load, the `Lightbox` shows 'This image could not be loaded.' with its alt text.",
3747
+ "Open an image at full size in a `Lightbox`: render one with the list of images, the `index`, `onIndexChange`, `isOpen` and `onClose`, as the case 'Image viewer' says. Closing it gives focus back to the thumbnail."
3003
3748
  ],
3004
3749
  "dont": [
3005
3750
  "Do not show a failed upload only in an Alert away from the file.",
@@ -3013,7 +3758,7 @@
3013
3758
  "id": "in-composer",
3014
3759
  "title": "In the composer",
3015
3760
  "useWhen": "Files are waiting to be sent with the next message.",
3016
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\nconst MAX_FILES = 5;\n\ntype Upload = { id: string; name: string; kind: string; size: string; state: 'ready' | 'uploading' | 'failed'; error?: string };\ntype Row = { id: string; from: string; at: Date; text: string; files?: Upload[] };\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Dana has the final versions.' },\n];\n\n// Opens with one file ready, one still uploading and one the server refused.\nconst firstFiles: Upload[] = [\n { id: 'f1', name: 'Launch brief.pdf', kind: 'PDF', size: '1.2 MB', state: 'ready' },\n { id: 'f2', name: 'Hero image.png', kind: 'PNG', size: '3.4 MB', state: 'uploading' },\n { id: 'f3', name: 'Product video.mov', kind: 'MOV', size: '48 MB', state: 'failed', error: 'Too large. The limit is 25 MB.' },\n];\n\n// What the attach button adds, in turn. A real app opens the file picker.\nconst sampleFiles = [\n { name: 'Press list.xlsx', kind: 'XLSX', size: '48 KB' },\n { name: 'Pricing sheet.pdf', kind: 'PDF', size: '320 KB' },\n { name: 'Logo.svg', kind: 'SVG', size: '12 KB' },\n];\n\n// Where a sent file opens. A real app links to the stored file.\nconst fileHref = (name: string) => `/files/${name.toLowerCase().replace(/\\s+/g, '-')}`;\n\n// The line that says why sending is blocked. The message box points at it with aria-describedby.\nconst blockedId = 'message-attachments-send-blocked';\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nexport default function MessageAttachmentsInComposer() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n const [files, setFiles] = useState(firstFiles);\n const added = useRef(0);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n\n // On unmount it stops every upload still running.\n useEffect(() => () => {\n timers.current.forEach((t) => clearTimeout(t));\n timers.current = [];\n }, []);\n\n const atLimit = files.length >= MAX_FILES;\n const uploading = files.some((f) => f.state === 'uploading');\n const failed = files.find((f) => f.state === 'failed');\n const blockedReason = failed ? `Remove ${failed.name} to send.` : uploading ? 'Wait for the upload to finish, then send.' : null;\n\n function attach() {\n if (atLimit) return;\n const sample = sampleFiles[added.current % sampleFiles.length];\n const id = `a${added.current + 1}`;\n added.current += 1;\n setFiles((list) => [...list, { ...sample, id, state: 'uploading' }]);\n // Stands in for the request to the server.\n timers.current.push(\n setTimeout(() => {\n setFiles((list) => list.map((f) => (f.id === id ? { ...f, state: 'ready' } : f)));\n }, 1200),\n );\n }\n\n // The chip that had focus is gone. A real app moves focus to the next chip, or to the message box when\n // none is left. FileChip does not pass a ref to its remove button, so this example always uses the message box.\n function remove(id: string) {\n setFiles((list) => list.filter((f) => f.id !== id));\n field.current?.focus();\n }\n\n // The Composer calls this only when canSubmit is true: no upload running, none failed.\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim(), files }]);\n setText('');\n setFiles([]);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m, i) => (\n <Message\n key={m.id}\n aria-label={m.from}\n compact={followsOn(thread, i)}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n m.files && m.files.length > 0 ? (\n <Cluster gap=\"small\">\n {m.files.map((f) => (\n // A sent file opens when its chip is pressed.\n <FileChip key={f.id} name={f.name} kind={f.kind} meta={f.size} href={fileHref(f.name)} openInNewTab />\n ))}\n </Cluster>\n ) : undefined\n }\n >\n {m.text && <Paragraph measure=\"none\">{m.text}</Paragraph>}\n </Message>\n ))}\n </Stack>\n <Composer\n ref={field}\n id=\"message-attachments-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n aria-describedby={blockedReason ? blockedId : undefined}\n // Files alone can be sent, but not while one uploads or has failed.\n canSubmit={(text.trim() !== '' || files.length > 0) && !uploading && !failed}\n above={\n files.length > 0 ? (\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n {files.map((f) => (\n <FileChip\n key={f.id}\n name={f.name}\n kind={f.kind}\n state={f.state}\n meta={f.state === 'uploading' ? 'Uploading' : f.state === 'failed' ? f.error : f.size}\n onRemove={() => remove(f.id)}\n />\n ))}\n </Cluster>\n {/* A real app also says these in a polite live region when they change. */}\n {blockedReason && (\n <Paragraph id={blockedId} size=\"caption\" tone=\"secondary\" measure=\"none\">{blockedReason}</Paragraph>\n )}\n {atLimit && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{`You can attach up to ${MAX_FILES} files.`}</Paragraph>\n )}\n </Stack>\n ) : undefined\n }\n tools={\n <Tooltip title=\"Attach files\">\n <IconButton\n color=\"iconOnly\"\n state={atLimit ? 'disabled' : 'enabled'}\n size=\"small\"\n iconName=\"Paperclip\"\n ariaLabel=\"Attach files\"\n onClick={attach}\n />\n </Tooltip>\n }\n />\n </Stack>\n </Center>\n );\n}\n",
3761
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\nconst MAX_FILES = 5;\n\ntype Upload = { id: string; name: string; kind: string; size: string; state: 'ready' | 'uploading' | 'failed'; error?: string };\ntype Row = { id: string; from: string; at: Date; text: string; files?: Upload[] };\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2026-11-16T11:40:00Z'), text: 'Can someone send the launch assets?' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2026-11-16T11:42:00Z'), text: 'Dana has the final versions.' },\n];\n\n// Opens with one file ready, one still uploading and one the server refused.\nconst firstFiles: Upload[] = [\n { id: 'f1', name: 'Launch brief.pdf', kind: 'PDF', size: '1.2 MB', state: 'ready' },\n { id: 'f2', name: 'Hero image.png', kind: 'PNG', size: '3.4 MB', state: 'uploading' },\n { id: 'f3', name: 'Product video.mov', kind: 'MOV', size: '48 MB', state: 'failed', error: 'Too large. The limit is 25 MB.' },\n];\n\n// What the attach button adds, in turn. A real app opens the file picker.\nconst sampleFiles = [\n { name: 'Press list.xlsx', kind: 'XLSX', size: '48 KB' },\n { name: 'Pricing sheet.pdf', kind: 'PDF', size: '320 KB' },\n { name: 'Logo.svg', kind: 'SVG', size: '12 KB' },\n];\n\n// Where a sent file opens. A real app links to the stored file.\nconst fileHref = (name: string) => `/files/${name.toLowerCase().replace(/\\s+/g, '-')}`;\n\n// The line that says why sending is blocked. The message box points at it with aria-describedby.\nconst blockedId = 'message-attachments-send-blocked';\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nexport default function MessageAttachmentsInComposer() {\n const [thread, setThread] = useState(firstThread);\n const [text, setText] = useState('');\n const [files, setFiles] = useState(firstFiles);\n const added = useRef(0);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const field = useRef<HTMLTextAreaElement>(null);\n\n // On unmount it stops every upload still running.\n useEffect(() => () => {\n timers.current.forEach((t) => clearTimeout(t));\n timers.current = [];\n }, []);\n\n const atLimit = files.length >= MAX_FILES;\n const uploading = files.some((f) => f.state === 'uploading');\n const failed = files.find((f) => f.state === 'failed');\n const blockedReason = failed ? `Remove ${failed.name} to send.` : uploading ? 'Wait for the upload to finish, then send.' : null;\n\n function attach() {\n if (atLimit) return;\n const sample = sampleFiles[added.current % sampleFiles.length];\n const id = `a${added.current + 1}`;\n added.current += 1;\n setFiles((list) => [...list, { ...sample, id, state: 'uploading' }]);\n // Stands in for the request to the server.\n timers.current.push(\n setTimeout(() => {\n setFiles((list) => list.map((f) => (f.id === id ? { ...f, state: 'ready' } : f)));\n }, 1200),\n );\n }\n\n // The chip that had focus is gone. A real app moves focus to the next chip, or to the message box when\n // none is left. FileChip does not pass a ref to its remove button, so this example always uses the message box.\n function remove(id: string) {\n setFiles((list) => list.filter((f) => f.id !== id));\n field.current?.focus();\n }\n\n // The Composer calls this only when canSubmit is true: no upload running, none failed.\n function send() {\n // A real app sends the message to the server here and shows it at once.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim(), files }]);\n setText('');\n setFiles([]);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m, i) => (\n <Message\n key={m.id}\n aria-label={m.from}\n compact={followsOn(thread, i)}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n m.files && m.files.length > 0 ? (\n <Cluster gap=\"small\">\n {m.files.map((f) => (\n // A sent file opens when its chip is pressed.\n <FileChip key={f.id} name={f.name} kind={f.kind} meta={f.size} href={fileHref(f.name)} openInNewTab />\n ))}\n </Cluster>\n ) : undefined\n }\n >\n {m.text && <Paragraph measure=\"none\">{m.text}</Paragraph>}\n </Message>\n ))}\n </Stack>\n <Composer\n ref={field}\n id=\"message-attachments-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n aria-describedby={blockedReason ? blockedId : undefined}\n // Files alone can be sent, but not while one uploads or has failed.\n canSubmit={(text.trim() !== '' || files.length > 0) && !uploading && !failed}\n above={\n files.length > 0 ? (\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n {files.map((f) => (\n <FileChip\n key={f.id}\n name={f.name}\n kind={f.kind}\n state={f.state}\n meta={f.state === 'uploading' ? 'Uploading' : f.state === 'failed' ? f.error : f.size}\n onRemove={() => remove(f.id)}\n />\n ))}\n </Cluster>\n {/* A real app also says these in a polite live region when they change. */}\n {blockedReason && (\n <Paragraph id={blockedId} size=\"caption\" tone=\"secondary\" measure=\"none\">{blockedReason}</Paragraph>\n )}\n {atLimit && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{`You can attach up to ${MAX_FILES} files.`}</Paragraph>\n )}\n </Stack>\n ) : undefined\n }\n tools={\n <Tooltip title=\"Attach files\">\n <IconButton\n color=\"iconOnly\"\n state={atLimit ? 'disabled' : 'enabled'}\n size=\"small\"\n iconName=\"Paperclip\"\n ariaLabel=\"Attach files\"\n onClick={attach}\n />\n </Tooltip>\n }\n />\n </Stack>\n </Center>\n );\n}\n",
3017
3762
  "uses": [
3018
3763
  "Center",
3019
3764
  "Cluster",
@@ -3033,15 +3778,15 @@
3033
3778
  "id": "in-message",
3034
3779
  "title": "In a sent message",
3035
3780
  "useWhen": "Files are part of a message in the thread.",
3036
- "source": "'use client';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// Two small drawings stand in for the uploaded photos.\nconst hillside =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E\";\nconst desk =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E\";\n\ntype Row = { id: string; from: string; at: Date; text: string };\n\nconst before: Row = { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' };\nconst withFiles: Row = { id: 'm2', from: 'Dana Lee', at: new Date('2025-01-15T11:44:00Z'), text: 'Here are the two hero options and the brief.' };\n\nexport default function MessageAttachmentsInMessage() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={before.from}\n avatar={<UserImage userHandle={before.from} decorative />}\n name={before.from}\n meta={<TimeStamp createdAt={before.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{before.text}</Paragraph>\n </Message>\n <Message\n aria-label={withFiles.from}\n avatar={<UserImage userHandle={withFiles.from} decorative />}\n name={withFiles.from}\n meta={<TimeStamp createdAt={withFiles.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n <Stack gap=\"small\">\n {/* Small thumbnails: four columns, two of them used. A real app opens the full image on click. */}\n <Grid columns={4} compact gap=\"small\">\n <Figure crop={4 / 3} radius=\"control\">\n <Image src={hillside} alt=\"Hero option A: a green hillside under a pale sky with the sun on the right\" width={160} height={120} />\n </Figure>\n <Figure crop={4 / 3} radius=\"control\">\n <Image src={desk} alt=\"Hero option B: a laptop on a wooden desk, its screen blue\" width={160} height={120} />\n </Figure>\n </Grid>\n <Cluster gap=\"small\">\n {/* Each chip opens the file. */}\n <FileChip name=\"Launch brief.pdf\" kind=\"PDF\" meta=\"1.2 MB\" href=\"/files/launch-brief.pdf\" openInNewTab />\n <FileChip name=\"Press list.xlsx\" kind=\"XLSX\" meta=\"48 KB\" href=\"/files/press-list.xlsx\" openInNewTab />\n </Cluster>\n </Stack>\n }\n >\n <Paragraph measure=\"none\">{withFiles.text}</Paragraph>\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
3781
+ "source": "'use client';\nimport { useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport Lightbox, { LightboxThumbnail } from 'oneslash-design-system/components/lightbox';\nimport { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// Two small drawings stand in for the uploaded photos.\nconst hillside =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E\";\nconst desk =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E\";\n\nconst photos = [\n { src: hillside, alt: 'Hero option A, a green hillside under a pale sky with the sun on the right' },\n { src: desk, alt: 'Hero option B, a laptop on a wooden desk, its screen blue' },\n];\n\ntype Row = { id: string; from: string; at: Date; text: string };\n\nconst before: Row = { id: 'm1', from: 'Ben Carter', at: new Date('2026-11-16T11:40:00Z'), text: 'Can someone send the launch assets?' };\nconst withFiles: Row = { id: 'm2', from: 'Dana Lee', at: new Date('2026-11-16T11:44:00Z'), text: 'Here are the two hero options and the brief.' };\n\nexport default function MessageAttachmentsInMessage() {\n const [open, setOpen] = useState(false);\n const [index, setIndex] = useState(0);\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={before.from}\n avatar={<UserImage userHandle={before.from} decorative />}\n name={before.from}\n meta={<TimeStamp createdAt={before.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{before.text}</Paragraph>\n </Message>\n <Message\n aria-label={withFiles.from}\n avatar={<UserImage userHandle={withFiles.from} decorative />}\n name={withFiles.from}\n meta={<TimeStamp createdAt={withFiles.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n <Stack gap=\"small\">\n {/* Small thumbnails: four columns, two of them used. Each opens the Lightbox; closing it gives focus back to that thumbnail. */}\n <Grid columns={4} compact gap=\"small\">\n {photos.map((photo, i) => (\n <LightboxThumbnail\n key={photo.alt}\n image={photo}\n onOpen={() => {\n setIndex(i);\n setOpen(true);\n }}\n />\n ))}\n </Grid>\n <Cluster gap=\"small\">\n {/* Each chip opens the file. */}\n <FileChip name=\"Launch brief.pdf\" kind=\"PDF\" meta=\"1.2 MB\" href=\"/files/launch-brief.pdf\" openInNewTab />\n <FileChip name=\"Press list.xlsx\" kind=\"XLSX\" meta=\"48 KB\" href=\"/files/press-list.xlsx\" openInNewTab />\n </Cluster>\n </Stack>\n }\n >\n <Paragraph measure=\"none\">{withFiles.text}</Paragraph>\n </Message>\n </Stack>\n </Stack>\n <Lightbox images={photos} index={index} onIndexChange={setIndex} isOpen={open} onClose={() => setOpen(false)} aria-label=\"Launch images\" />\n </Center>\n );\n}\n",
3037
3782
  "uses": [
3038
3783
  "Center",
3039
3784
  "Cluster",
3040
- "Figure",
3041
3785
  "FileChip",
3042
3786
  "Grid",
3043
3787
  "Heading",
3044
- "Image",
3788
+ "Lightbox",
3789
+ "LightboxThumbnail",
3045
3790
  "Message",
3046
3791
  "Paragraph",
3047
3792
  "Stack",
@@ -3653,6 +4398,33 @@
3653
4398
  }
3654
4399
  ]
3655
4400
  },
4401
+ {
4402
+ "id": "one-main-action",
4403
+ "title": "A marketing page asks for one main action, in the same words everywhere",
4404
+ "kind": "rule",
4405
+ "level": "rule",
4406
+ "area": "marketing",
4407
+ "situation": "A marketing page asks the visitor to do something: sign up, open the app, buy a plan.",
4408
+ "answer": "A page has one main action. It is a primary `Button` with the same label in the header, the hero, the pricing section and the end of the page: 'Sign Up', or 'Sign Up for Pro' on a plan. A second action is a secondary `Button`, or a `Link` that teaches, such as 'See How It Works'. It is never a second primary. Write the label as the move, in Title Case, with short prepositions lowercase. Do not write 'Get Started Free' in one place and 'Try It' in another. The main action and the second action open in the same tab, unless one goes to a store or starts a download. A link to another site, in a list or a footer, uses `external`, as the case 'Site footer' says.",
4409
+ "why": "A visitor who sees three names for one move wonders if they are three moves. One label everywhere tells them where every button goes, and one primary Button tells them which one matters.",
4410
+ "do": [
4411
+ "Give the page one primary `Button`: 'Sign Up'. Use the same label in the header, the hero, the pricing section and the end of the page.",
4412
+ "Name the action for a plan with the plan: 'Sign Up for Pro'. Keep short prepositions lowercase.",
4413
+ "Make a second action a secondary `Button` or a `Link` that teaches: 'See How It Works'.",
4414
+ "Write each label as the move, in Title Case, and use the same words for the same move on every page.",
4415
+ "Name where an action goes when it leaves the site: 'Download the Desktop App'. Keep the main and second action in the same tab, unless one goes to a store or starts a download. Then use `openInNewTab`.",
4416
+ "Put the header's main action in `SiteHeader` as `phoneAction`, as the case 'Site header' says, so it stays in the bar on a phone.",
4417
+ "Use a `Button` with `href` for an action that goes to a page. Use `onClickButton` only for an action that stays on the page."
4418
+ ],
4419
+ "dont": [
4420
+ "Do not call one move 'Get Started Free' in one place and 'Try It' in another.",
4421
+ "Do not give a second, different move a primary Button. The header and the hero may both show 'Sign Up'.",
4422
+ "Do not open the main action or the second action in a new tab, unless it goes to a store or starts a download.",
4423
+ "Do not build your own call-to-action button for one section. Use `Button`.",
4424
+ "Do not leave a Button with no action. If it has nowhere to go, it is not on the page yet."
4425
+ ],
4426
+ "native": "On Apple an app has no marketing page. A product page in the App Store is the store. On Android the same holds for Google Play."
4427
+ },
3656
4428
  {
3657
4429
  "id": "overflow-menu",
3658
4430
  "title": "More menu",
@@ -3688,7 +4460,7 @@
3688
4460
  "id": "on-a-row",
3689
4461
  "title": "More button on a row",
3690
4462
  "useWhen": "The actions are for one item in a list, and each row has its own button.",
3691
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Report = { id: string; name: string; updated: string };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\n// A real app reads these from the server.\nconst firstReports: Report[] = [\n { id: 'q3', name: 'Q3 report', updated: 'Updated 2 days ago' },\n { id: 'budget', name: 'Budget review', updated: 'Updated last week' },\n { id: 'hiring', name: 'Hiring plan', updated: 'Updated 3 weeks ago' },\n { id: 'roadmap', name: 'Roadmap', updated: 'Updated last month' },\n];\n\nexport default function OverflowMenuOnARow() {\n const [reports, setReports] = useState(firstReports);\n // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuRow, setMenuRow] = useState<Report | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // The row that asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const cancelDelete = useRef<Focusable>(null);\n // Each row's More button by row id, so focus can move to one when the thing that had it is gone.\n const moreButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n // Gives each copy its own id, so no two rows share a key.\n const copies = useRef(0);\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function openMenu(r: Report, anchor: HTMLElement) {\n if (menuOpen && menuRow?.id === r.id) {\n setMenuOpen(false);\n return;\n }\n setMenuRow(r);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.\n function choose(action: (r: Report) => void) {\n if (!menuRow) return;\n const r = menuRow;\n setMenuOpen(false);\n action(r);\n }\n\n // The copy shows under the row, so it needs no toast. Focus goes to the copy's More button.\n function duplicate(r: Report) {\n copies.current += 1;\n const copy = { id: `${r.id}-copy-${copies.current}`, name: `${r.name} copy`, updated: 'Updated just now' };\n setReports((list) => {\n const at = list.findIndex((x) => x.id === r.id);\n return [...list.slice(0, at + 1), copy, ...list.slice(at + 1)];\n });\n focusNext.current = () => moreButtons.current[copy.id]?.focus();\n }\n\n // The menu is gone, so the result shows in a toast. A clipboard that is missing or refuses says to copy by hand,\n // in an error toast that stays until the person closes it.\n function copyLink(r: Report) {\n const link = `https://example.com/reports/${r.id}`;\n const failed = () => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'error', message: `Copying is blocked here. Select the link and copy it: ${link}` }));\n };\n if (!navigator.clipboard) return failed();\n navigator.clipboard.writeText(link).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Link copied.' }));\n }, failed);\n }\n\n // The confirm opens in the row, with focus on 'Cancel'.\n function askToDelete(r: Report) {\n setConfirmingId(r.id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.\n function keepReport() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const at = reports.findIndex((r) => r.id === id);\n const gone = reports[at];\n const neighbor = reports[at + 1] ?? reports[at - 1];\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setReports((list) => list.filter((r) => r.id !== id));\n toastIds.current.push(toast({ type: 'success', message: `${gone.name} deleted.` }));\n // The row is gone: focus goes to the next row's More button, or the one before it when it was the last.\n focusNext.current = () => (neighbor ? moreButtons.current[neighbor.id] : null)?.focus();\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Reports</Heading>\n {reports.length > 0 ? (\n <TableContainer>\n {reports.map((r) => {\n const confirming = r.id === confirmingId;\n return (\n <TableRow key={r.id}>\n <TableCell>\n <Stack gap=\"small\">\n {r.name}\n {confirming && <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Delete this report?</Paragraph>}\n </Stack>\n </TableCell>\n <TableCell width=\"160px\">{r.updated}</TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"168px\" align=\"right\">\n {confirming ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label={`Cancel deleting ${r.name}`} onClickButton={keepReport} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label={`Delete ${r.name}`} loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n ) : (\n <Cluster justify=\"end\">\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[r.id] = el; }}\n color=\"iconOnly\"\n state={menuOpen && menuRow?.id === r.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${r.name}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuRow?.id === r.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(r, e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n )}\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n ) : (\n <EmptyBox size=\"small\" text=\"No reports yet\" secondText=\"Reports you create appear here.\" />\n )}\n </Stack>\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label={menuRow ? `Actions for ${menuRow.name}` : 'Report actions'} width={200}>\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Duplicate\" onClick={() => choose(duplicate)} />\n <MenuItem size=\"small\" iconName=\"Link\" label=\"Copy Link\" onClick={() => choose(copyLink)} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={() => choose(askToDelete)} />\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
4463
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Report = { id: string; name: string; updated: string };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\n// A real app reads these from the server.\nconst firstReports: Report[] = [\n { id: 'q3', name: 'Q3 report', updated: 'Updated 2 days ago' },\n { id: 'budget', name: 'Budget review', updated: 'Updated last week' },\n { id: 'hiring', name: 'Hiring plan', updated: 'Updated 3 weeks ago' },\n { id: 'roadmap', name: 'Roadmap', updated: 'Updated last month' },\n];\n\nexport default function OverflowMenuOnARow() {\n const [reports, setReports] = useState(firstReports);\n // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuRow, setMenuRow] = useState<Report | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // The row that asks to confirm the delete. One row at a time.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const cancelDelete = useRef<Focusable>(null);\n // Each row's More button by row id, so focus can move to one when the thing that had it is gone.\n const moreButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n // Gives each copy its own id, so no two rows share a key.\n const copies = useRef(0);\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function openMenu(r: Report, anchor: HTMLElement) {\n if (menuOpen && menuRow?.id === r.id) {\n setMenuOpen(false);\n return;\n }\n setMenuRow(r);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.\n function choose(action: (r: Report) => void) {\n if (!menuRow) return;\n const r = menuRow;\n setMenuOpen(false);\n action(r);\n }\n\n // The copy shows under the row, so it needs no toast. Focus goes to the copy's More button.\n function duplicate(r: Report) {\n copies.current += 1;\n const copy = { id: `${r.id}-copy-${copies.current}`, name: `${r.name} copy`, updated: 'Updated just now' };\n setReports((list) => {\n const at = list.findIndex((x) => x.id === r.id);\n return [...list.slice(0, at + 1), copy, ...list.slice(at + 1)];\n });\n focusNext.current = () => moreButtons.current[copy.id]?.focus();\n }\n\n // The menu is gone, so the result shows in a toast. A clipboard that is missing or refuses says to copy by hand,\n // in an error toast that stays until the person closes it.\n function copyLink(r: Report) {\n const link = `https://example.com/reports/${r.id}`;\n const failed = () => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'error', message: `Copying is blocked here. Select the link and copy it: ${link}` }));\n };\n if (!navigator.clipboard) return failed();\n navigator.clipboard.writeText(link).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Link copied.' }));\n }, failed);\n }\n\n // The confirm opens in the row, with focus on 'Cancel'.\n function askToDelete(r: Report) {\n setConfirmingId(r.id);\n focusNext.current = () => cancelDelete.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.\n function keepReport() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function confirmDelete() {\n if (deleting || !confirmingId) return;\n const id = confirmingId;\n const at = reports.findIndex((r) => r.id === id);\n const gone = reports[at];\n const neighbor = reports[at + 1] ?? reports[at - 1];\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirmingId(null);\n setReports((list) => list.filter((r) => r.id !== id));\n toastIds.current.push(toast({ type: 'success', message: `${gone.name} deleted.` }));\n // The row is gone: focus goes to the next row's More button, or the one before it when it was the last.\n focusNext.current = () => (neighbor ? moreButtons.current[neighbor.id] : null)?.focus();\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Reports</Heading>\n {reports.length > 0 ? (\n <TableContainer>\n {reports.map((r) => {\n const confirming = r.id === confirmingId;\n return (\n <TableRow key={r.id}>\n <TableCell>\n <Stack gap=\"small\">\n {r.name}\n {confirming && <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Delete this report?</Paragraph>}\n </Stack>\n </TableCell>\n <TableCell width=\"160px\">{r.updated}</TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"168px\" align=\"right\">\n {confirming ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Button ref={cancelDelete} size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label={`Cancel deleting ${r.name}`} onClickButton={keepReport} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" aria-label={`Delete ${r.name}`} loading={deleting} onClickButton={confirmDelete} />\n </Cluster>\n ) : (\n <Cluster justify=\"end\">\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[r.id] = el; }}\n color=\"iconOnly\"\n state={menuOpen && menuRow?.id === r.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${r.name}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuRow?.id === r.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(r, e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n )}\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n ) : (\n <EmptyBox size=\"small\" text=\"No reports yet\" secondText=\"Reports you create appear here.\" />\n )}\n </Stack>\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label={menuRow ? `Actions for ${menuRow.name}` : 'Report actions'} width={200}>\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Duplicate\" onClick={() => choose(duplicate)} />\n <MenuItem size=\"small\" iconName=\"Link\" label=\"Copy Link\" onClick={() => choose(copyLink)} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={() => choose(askToDelete)} />\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
3692
4464
  "uses": [
3693
4465
  "Button",
3694
4466
  "Center",
@@ -3715,7 +4487,7 @@
3715
4487
  "id": "in-a-header",
3716
4488
  "title": "More button in a header",
3717
4489
  "useWhen": "The actions are for the whole page, and the header has one button.",
3718
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst otherReports = ['Budget review', 'Hiring plan', 'Roadmap'];\n\nexport default function OverflowMenuInAHeader() {\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const [deleted, setDeleted] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const moreButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function toggle(anchorEl: HTMLElement) {\n setAnchor(anchorEl);\n setOpen((o) => !o);\n }\n\n // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.\n function duplicate() {\n setOpen(false);\n toastIds.current.push(toast({ type: 'success', message: 'Q3 report duplicated.' }));\n }\n\n // The menu is gone, so the result shows in a toast. A clipboard that is missing or refuses says to copy by hand.\n function copyLink() {\n setOpen(false);\n const link = 'https://example.com/reports/q3';\n const failed = () => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'error', message: `Copying is blocked here. Select the link and copy it: ${link}` }));\n };\n if (!navigator.clipboard) return failed();\n navigator.clipboard.writeText(link).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Link copied.' }));\n }, failed);\n }\n\n function askToDelete() {\n setOpen(false);\n setConfirming(true);\n }\n\n // The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.\n function keepReport() {\n if (deleting) return;\n setConfirming(false);\n focusNext.current = () => moreButton.current?.focus();\n }\n\n function confirmDelete() {\n if (deleting) return;\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirming(false);\n setDeleted(true);\n toastIds.current.push(toast({ type: 'success', message: 'Q3 report deleted.' }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n {deleted ? (\n // A real app goes back to the list of reports here.\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Reports</Heading>\n <Surface padding=\"large\">\n <List items={otherReports} size=\"body1\" />\n </Surface>\n </Stack>\n ) : (\n <Stack gap=\"medium\">\n <Cluster justify=\"between\">\n <Heading level={1} size=\"h5\">Q3 report</Heading>\n <Tooltip title=\"More\">\n <IconButton\n ref={moreButton}\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel=\"More actions for Q3 report\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={(e: { currentTarget: HTMLElement }) => toggle(e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>\n </Stack>\n )}\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Actions for Q3 report\" width={200}>\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Duplicate\" onClick={duplicate} />\n <MenuItem size=\"small\" iconName=\"Link\" label=\"Copy Link\" onClick={copyLink} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={askToDelete} />\n </Menu>\n </Popover>\n {/* The page is not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}\n <Modal\n isOpen={confirming}\n size=\"small\"\n title=\"Delete Report\"\n onClose={keepReport}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={keepReport} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" loading={deleting} onClickButton={confirmDelete} />\n </>\n }\n >\n <Paragraph measure=\"none\">This deletes &apos;Q3 report&apos; and its 12 tasks.</Paragraph>\n </Modal>\n </Center>\n );\n}\n",
4490
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst otherReports = ['Budget review', 'Hiring plan', 'Roadmap'];\n\nexport default function OverflowMenuInAHeader() {\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const [deleted, setDeleted] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const moreButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function toggle(anchorEl: HTMLElement) {\n setAnchor(anchorEl);\n setOpen((o) => !o);\n }\n\n // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.\n function duplicate() {\n setOpen(false);\n toastIds.current.push(toast({ type: 'success', message: 'Q3 report duplicated.' }));\n }\n\n // The menu is gone, so the result shows in a toast. A clipboard that is missing or refuses says to copy by hand.\n function copyLink() {\n setOpen(false);\n const link = 'https://example.com/reports/q3';\n const failed = () => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'error', message: `Copying is blocked here. Select the link and copy it: ${link}` }));\n };\n if (!navigator.clipboard) return failed();\n navigator.clipboard.writeText(link).then(() => {\n if (!mounted.current) return;\n toastIds.current.push(toast({ type: 'success', message: 'Link copied.' }));\n }, failed);\n }\n\n function askToDelete() {\n setOpen(false);\n setConfirming(true);\n }\n\n // The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.\n function keepReport() {\n if (deleting) return;\n setConfirming(false);\n focusNext.current = () => moreButton.current?.focus();\n }\n\n function confirmDelete() {\n if (deleting) return;\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirming(false);\n setDeleted(true);\n toastIds.current.push(toast({ type: 'success', message: 'Q3 report deleted.' }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n {deleted ? (\n // A real app goes back to the list of reports here.\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Reports</Heading>\n <Surface padding=\"large\">\n <List items={otherReports} size=\"body1\" />\n </Surface>\n </Stack>\n ) : (\n <Stack gap=\"medium\">\n <Cluster justify=\"between\">\n <Heading level={1} size=\"h5\">Q3 report</Heading>\n <Tooltip title=\"More\">\n <IconButton\n ref={moreButton}\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel=\"More actions for Q3 report\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={(e: { currentTarget: HTMLElement }) => toggle(e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>\n </Stack>\n )}\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Actions for Q3 report\" width={200}>\n <MenuItem size=\"small\" iconName=\"Copy\" label=\"Duplicate\" onClick={duplicate} />\n <MenuItem size=\"small\" iconName=\"Link\" label=\"Copy Link\" onClick={copyLink} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete\" onClick={askToDelete} />\n </Menu>\n </Popover>\n {/* The page is not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}\n <Modal\n isOpen={confirming}\n size=\"small\"\n title=\"Delete Report\"\n onClose={keepReport}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={keepReport} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" loading={deleting} onClickButton={confirmDelete} />\n </>\n }\n >\n <Paragraph measure=\"none\">This deletes &apos;Q3 report&apos; and its 12 tasks.</Paragraph>\n </Modal>\n </Center>\n );\n}\n",
3719
4491
  "uses": [
3720
4492
  "Button",
3721
4493
  "Center",
@@ -3739,6 +4511,58 @@
3739
4511
  }
3740
4512
  ]
3741
4513
  },
4514
+ {
4515
+ "id": "page-end",
4516
+ "title": "Page end",
4517
+ "kind": "design",
4518
+ "level": "organism",
4519
+ "area": "marketing",
4520
+ "situation": "A page has said what it had to say, and its last block decides what the visitor does next.",
4521
+ "do": [
4522
+ "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. The closing block uses the same labels as the header and the hero.",
4523
+ "Use a `Surface` for `cta-band`, with a level 2 `Heading`, one line of lede and the page's actions: a primary 'Sign Up' and one secondary.",
4524
+ "Write the heading as a statement the visitor can say yes to, and the lede as the one doubt it removes.",
4525
+ "Use one `LinkCard` for `next-link`, with the next page's title and a caption that says it is next: 'Next: Task threads'.",
4526
+ "Put the block after the last section and before the `SiteFooter`."
4527
+ ],
4528
+ "dont": [
4529
+ "Do not use both blocks on one page. A page ends one way.",
4530
+ "Do not add a new action that the header and the hero do not have.",
4531
+ "Do not close a reading page on a sign-up banner.",
4532
+ "Do not name the link 'Next'. Name the page."
4533
+ ],
4534
+ "native": "On Apple a screen ends with its content. A flow moves on with a `NavigationLink` or a toolbar button. On Android use the same with a navigation bar.",
4535
+ "options": [
4536
+ {
4537
+ "id": "cta-band",
4538
+ "title": "Closing call to action",
4539
+ "useWhen": "A marketing page closes on its main action.",
4540
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nexport default function PageEndCtaBand() {\n return (\n <PageShell>\n {/* The last block of the page: one statement, one line, and the same actions as the header and the hero. */}\n <Surface padding=\"xlarge\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"medium\">\n <Heading level={2} size=\"h4\">Bring your team and its agent together</Heading>\n <Paragraph tone=\"secondary\" measure=\"lede\">Start on Free with 3 members, and add people when you need them.</Paragraph>\n </Stack>\n <Cluster>\n <Button size=\"large\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />\n <Button size=\"large\" type=\"secondary\" state=\"enabled\" label=\"See How It Works\" href=\"#how-it-works\" />\n </Cluster>\n </Stack>\n </Surface>\n </PageShell>\n );\n}\n",
4541
+ "uses": [
4542
+ "Button",
4543
+ "Cluster",
4544
+ "Heading",
4545
+ "PageShell",
4546
+ "Paragraph",
4547
+ "Stack",
4548
+ "Surface"
4549
+ ]
4550
+ },
4551
+ {
4552
+ "id": "next-link",
4553
+ "title": "Link to the next page",
4554
+ "useWhen": "A reading page leads to the next thing to read.",
4555
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nexport default function PageEndNextLink() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <Stack gap=\"xxlarge\">\n <PageHeader level={1} title=\"How channels work\" lede=\"A channel is a place for one subject. Everyone in it sees every message.\" />\n <Paragraph tone=\"secondary\">Make a channel for each team or project. Pin the messages people need to find again. Turn a message into a task when it needs an owner.</Paragraph>\n </Stack>\n {/* A reading page ends by pointing to the next page to read, and not to a sign-up. */}\n <LinkCard href=\"#task-threads\" title=\"Task threads\" caption=\"Next: Task threads\" />\n </Stack>\n </PageShell>\n );\n}\n",
4556
+ "uses": [
4557
+ "LinkCard",
4558
+ "PageHeader",
4559
+ "PageShell",
4560
+ "Paragraph",
4561
+ "Stack"
4562
+ ]
4563
+ }
4564
+ ]
4565
+ },
3742
4566
  {
3743
4567
  "id": "page-header",
3744
4568
  "title": "Page header with actions",
@@ -3863,6 +4687,91 @@
3863
4687
  }
3864
4688
  ]
3865
4689
  },
4690
+ {
4691
+ "id": "password-gate",
4692
+ "title": "Password gate",
4693
+ "kind": "design",
4694
+ "level": "organism",
4695
+ "area": "content",
4696
+ "situation": "Some work is private. A visitor needs the password to read it, and someone who does not have it needs to know how to ask.",
4697
+ "do": [
4698
+ "Put the gate in a `Surface` with a heading that says what is behind it: 'This case study needs a password'. It is the h1 on a whole page and an h2 inside a page.",
4699
+ "Say in one line how to get access, with a `Link` to the contact page.",
4700
+ "Use a password `TextField` and a Button named 'View Work'. Put them in a `Form`, so Enter submits.",
4701
+ "Show a wrong password under the field: 'That password is not right.' Keep focus in the field and keep what was typed.",
4702
+ "Keep the Button's label while it checks, and make it `loading`.",
4703
+ "Keep the field enabled while it checks. A disabled field loses focus, and after a wrong password the cursor must still be in the field.",
4704
+ "Show the work when the password is right, and move focus to the first control in it.",
4705
+ "Follow the rule 'A confirm says exactly what will happen' for `modal`. Put 'Cancel' first and make the Modal title and its action the same words: 'View Work'.",
4706
+ "Let the server check the password and set the cookie. The server sends the private content only to a visitor with the cookie. The page never holds the password.",
4707
+ "Keep the summary and the facts in the page for `inline`, and leave the private part out of the HTML sent to a visitor without the cookie."
4708
+ ],
4709
+ "dont": [
4710
+ "Do not send private content to the browser and hide it there, with a style or a check in the page. A visitor can still read it.",
4711
+ "Do not put the password in the page, in a script or in the address.",
4712
+ "Do not say which part of a password was wrong.",
4713
+ "Do not show a bare field with no word on what is behind it or how to ask.",
4714
+ "Do not change the Button's label while it checks."
4715
+ ],
4716
+ "native": "On Apple use a `SecureField` in a grouped form, and let the server check it. A locked item opens a sheet with the field and Cancel first.",
4717
+ "options": [
4718
+ {
4719
+ "id": "page",
4720
+ "title": "The whole page is private",
4721
+ "useWhen": "The whole page is private, and nothing on it is public.",
4722
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Form from 'oneslash-design-system/components/form';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.\n// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.\nconst PASSPHRASE = 'acme-demo';\n\nexport default function PasswordGatePage() {\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [checking, setChecking] = useState(false);\n const [unlocked, setUnlocked] = useState(false);\n // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.\n const [attempt, setAttempt] = useState(0);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const lockAgain = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // The field is gone once the work shows, so focus moves to the first control in it.\n useEffect(() => {\n if (unlocked) lockAgain.current?.focus();\n }, [unlocked]);\n\n function handleSubmit() {\n if (checking) return;\n if (!password.trim()) {\n setError('Enter the password.');\n setAttempt((n) => n + 1);\n return;\n }\n setError('');\n setChecking(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setChecking(false);\n if (password === PASSPHRASE) {\n setUnlocked(true);\n } else {\n setError('That password is not right.');\n setAttempt((n) => n + 1);\n }\n }, 600);\n }\n\n if (unlocked) {\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n <PageHeader level={1} title=\"Plan changes, a case study\" lede=\"How we made a plan change clear before anyone pays.\" />\n <Paragraph tone=\"secondary\">The screens, the notes and the decisions for this case study are here.</Paragraph>\n <Stack align=\"start\">\n <Button ref={lockAgain} size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Lock Again\" onClickButton={() => { setUnlocked(false); setPassword(''); }} />\n </Stack>\n </Stack>\n </PageShell>\n );\n }\n\n return (\n <PageShell>\n <Surface padding=\"xlarge\" minHeight=\"tall\" align=\"center\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">This case study needs a password</Heading>\n <Paragraph>\n The password comes by email. <Link href=\"#contact\">Ask for the password</Link>.\n </Paragraph>\n <Form aria-label=\"Private work\" onSubmit={handleSubmit}>\n <TextField key={attempt} id=\"password-gate-password\" label=\"Password\" type=\"password\" autoComplete=\"current-password\" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />\n <Stack align=\"start\">\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"View Work\" htmlType=\"submit\" loading={checking} />\n </Stack>\n </Form>\n </Stack>\n </Surface>\n </PageShell>\n );\n}\n",
4723
+ "uses": [
4724
+ "Button",
4725
+ "Form",
4726
+ "Heading",
4727
+ "Link",
4728
+ "PageHeader",
4729
+ "PageShell",
4730
+ "Paragraph",
4731
+ "Stack",
4732
+ "Surface",
4733
+ "TextField"
4734
+ ]
4735
+ },
4736
+ {
4737
+ "id": "inline",
4738
+ "title": "Part of the page is private",
4739
+ "useWhen": "The summary and the facts stay readable, and the rest is behind the gate.",
4740
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Form from 'oneslash-design-system/components/form';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.\n// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.\n\n// A stand-in for a screen. A real page passes its own picture.\nconst screen =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3C/svg%3E\";\n\nconst PASSPHRASE = 'acme-demo';\n\nexport default function PasswordGateInline() {\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [checking, setChecking] = useState(false);\n const [unlocked, setUnlocked] = useState(false);\n // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.\n const [attempt, setAttempt] = useState(0);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const lockAgain = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // The field is gone once the work shows, so focus moves to the first control in it.\n useEffect(() => {\n if (unlocked) lockAgain.current?.focus();\n }, [unlocked]);\n\n function handleSubmit() {\n if (checking) return;\n if (!password.trim()) {\n setError('Enter the password.');\n setAttempt((n) => n + 1);\n return;\n }\n setError('');\n setChecking(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setChecking(false);\n if (password === PASSPHRASE) {\n setUnlocked(true);\n } else {\n setError('That password is not right.');\n setAttempt((n) => n + 1);\n }\n }, 600);\n }\n\n const header = (\n <PageHeader\n level={1}\n title=\"Plan changes, a case study\"\n lede=\"How we made a plan change clear before anyone pays.\"\n facts={[\n { label: 'Role', value: 'Lead designer' },\n { label: 'Team', value: '4 people' },\n { label: 'Year', value: '2026' },\n ]}\n />\n );\n\n return (\n <PageShell>\n <Stack gap=\"giant\">\n {/* The summary and the facts stay readable. Only the screens are behind the gate. */}\n <Stack gap=\"xlarge\">\n {header}\n <Paragraph tone=\"secondary\">People could not tell what a new plan would cost them. We showed the new price and the day it starts before the last step, and fewer people wrote to ask.</Paragraph>\n </Stack>\n {unlocked ? (\n <Stack gap=\"xlarge\">\n <Figure crop={16 / 9} caption=\"The plan change, before the person pays.\">\n <Image src={screen} alt=\"A plan change screen: the current plan beside the new plan, with the new price in green\" width={1280} height={720} />\n </Figure>\n <Stack align=\"start\">\n <Button ref={lockAgain} size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Lock Again\" onClickButton={() => { setUnlocked(false); setPassword(''); }} />\n </Stack>\n </Stack>\n ) : (\n <Surface padding=\"large\">\n <Stack gap=\"large\">\n <Heading level={2} size=\"h6\">This case study needs a password</Heading>\n <Paragraph>\n The password comes by email. <Link href=\"#contact\">Ask for the password</Link>.\n </Paragraph>\n <Form aria-label=\"Private work\" onSubmit={handleSubmit}>\n <TextField key={attempt} id=\"password-gate-inline-password\" label=\"Password\" type=\"password\" autoComplete=\"current-password\" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />\n <Stack align=\"start\">\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"View Work\" htmlType=\"submit\" loading={checking} />\n </Stack>\n </Form>\n </Stack>\n </Surface>\n )}\n </Stack>\n </PageShell>\n );\n}\n",
4741
+ "uses": [
4742
+ "Button",
4743
+ "Figure",
4744
+ "Form",
4745
+ "Heading",
4746
+ "Image",
4747
+ "Link",
4748
+ "PageHeader",
4749
+ "PageShell",
4750
+ "Paragraph",
4751
+ "Stack",
4752
+ "Surface",
4753
+ "TextField"
4754
+ ]
4755
+ },
4756
+ {
4757
+ "id": "modal",
4758
+ "title": "A link to private work asks first",
4759
+ "useWhen": "A list links to private work, and the gate should not leave the list.",
4760
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Form from 'oneslash-design-system/components/form';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Button from 'oneslash-design-system/components/button';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.\n// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.\nconst PASSPHRASE = 'acme-demo';\n\nexport default function PasswordGateModal() {\n const [open, setOpen] = useState(false);\n const [unlocked, setUnlocked] = useState(false);\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [checking, setChecking] = useState(false);\n // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.\n const [attempt, setAttempt] = useState(0);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function handleClose() {\n if (checking) return;\n setOpen(false);\n setPassword('');\n setError('');\n }\n\n function handleSubmit() {\n if (checking) return;\n if (!password.trim()) {\n setError('Enter the password.');\n setAttempt((n) => n + 1);\n return;\n }\n setError('');\n setChecking(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setChecking(false);\n if (password === PASSPHRASE) {\n setUnlocked(true);\n setOpen(false);\n setPassword('');\n } else {\n setError('That password is not right.');\n setAttempt((n) => n + 1);\n }\n }, 600);\n }\n\n return (\n <PageShell>\n <Stack gap=\"xlarge\">\n <PageHeader level={1} title=\"Selected work\" lede=\"Three case studies. The first is open. The others need a password.\" />\n <Stack gap=\"large\" align=\"start\">\n <Link href=\"#how-we-write-errors\">How we write error messages</Link>\n {/* A link to private work asks for the password first. A real page keeps the link's address, so the work opens there after the check. The trigger stays, so focus has somewhere to go back to. */}\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Read the Plan Changes Case Study\" onClickButton={() => { if (!unlocked) setOpen(true); }} />\n {unlocked && <Paragraph>It is open for you now.</Paragraph>}\n </Stack>\n </Stack>\n <Modal\n isOpen={open}\n size=\"small\"\n initialFocus=\"body\"\n title=\"View Work\"\n onClose={handleClose}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={checking ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={handleClose} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"View Work\" loading={checking} onClickButton={handleSubmit} />\n </>\n }\n >\n <Form aria-label=\"Private work\" onSubmit={handleSubmit}>\n <TextField key={attempt} id=\"password-gate-modal-password\" label=\"Password\" type=\"password\" autoComplete=\"current-password\" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">\n This case study needs a password, and it comes by email. <Link href=\"#contact\">Ask for the password</Link>.\n </Paragraph>\n </Form>\n </Modal>\n </PageShell>\n );\n}\n",
4761
+ "uses": [
4762
+ "Button",
4763
+ "Form",
4764
+ "Link",
4765
+ "Modal",
4766
+ "PageHeader",
4767
+ "PageShell",
4768
+ "Paragraph",
4769
+ "Stack",
4770
+ "TextField"
4771
+ ]
4772
+ }
4773
+ ]
4774
+ },
3866
4775
  {
3867
4776
  "id": "payment-method",
3868
4777
  "title": "Payment method",
@@ -4106,6 +5015,92 @@
4106
5015
  }
4107
5016
  ]
4108
5017
  },
5018
+ {
5019
+ "id": "pricing-section",
5020
+ "title": "Pricing section",
5021
+ "kind": "design",
5022
+ "level": "organism",
5023
+ "area": "marketing",
5024
+ "situation": "A visitor to the public site compares the plans and signs up for one.",
5025
+ "do": [
5026
+ "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
5027
+ "Show the same plans as the case 'Plan picker', word for word: the names, the prices and what each includes. A price comes from `formatMoney`, as the rule 'A number shows its unit and never shows 0 for unknown' says.",
5028
+ "Make each plan a `Surface` with its name as a level 3 heading, its price, a `List` of what it includes and one `Button`. Put them in `Grid columns={3}`, which stacks them on a phone.",
5029
+ "Name each Button for the plan: 'Sign Up for Free', 'Sign Up for Pro', 'Sign Up for Business'. Give it an `href` to the sign-up page with the plan in the address, so it works as a link.",
5030
+ "Make the Button of the plan most visitors start on primary, and the others secondary. A visitor has no current plan, so no card carries 'Current plan'.",
5031
+ "Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.",
5032
+ "Put one line under the cards that says what the prices are in and who pays: 'Prices in USD. Pro and Business bill each member monthly.'",
5033
+ "Add a `SegmentedControl` for monthly and yearly as the case 'Range switch' says once a plan bills by the year. Leave it out while every plan bills monthly."
5034
+ ],
5035
+ "dont": [
5036
+ "Do not name a Button 'Get Started', 'Choose' or 'Select'. Name the plan it signs up for.",
5037
+ "Do not open the sign-up page in a new tab.",
5038
+ "Do not give two plans a primary Button.",
5039
+ "Do not change a price or a limit here without changing it in the case 'Plan picker' too. A visitor sees one set of plans.",
5040
+ "Do not make a card clickable as a whole. Its Button is the one control."
5041
+ ],
5042
+ "native": "On Apple an app has no pricing section. The plans are in the app as a `List` with the system purchase sheet, as the case 'Plan picker' says.",
5043
+ "options": [
5044
+ {
5045
+ "id": "cards",
5046
+ "title": "Plan cards side by side",
5047
+ "useWhen": "The plans a visitor can sign up for are shown on the public site, two or three at once.",
5048
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.\nconst plans = [\n { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },\n { id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },\n { id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },\n];\n\nexport default function PricingSectionCards() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"pricing\" name=\"Pricing\" statement=\"Pick the plan that fits your team.\" />\n <Stack gap=\"medium\">\n {/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}\n <Grid columns={3}>\n {plans.map((p) => (\n <Surface key={p.id} padding=\"medium\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={3} size=\"h6\">{p.name}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{p.price}</Paragraph>\n </Stack>\n <List items={p.includes} size=\"body2\" marker=\"dot\" />\n {/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}\n <Button\n size=\"medium\"\n type={p.id === 'pro' ? 'primary' : 'secondary'}\n state=\"enabled\"\n label={`Sign Up for ${p.name}`}\n href={`https://acme.example/sign-up?plan=${p.id}`}\n />\n </Stack>\n </Surface>\n ))}\n </Grid>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Prices in USD. Pro and Business bill each member monthly.</Paragraph>\n </Stack>\n </PageSection>\n </PageShell>\n );\n}\n",
5049
+ "uses": [
5050
+ "Button",
5051
+ "Grid",
5052
+ "Heading",
5053
+ "List",
5054
+ "PageSection",
5055
+ "PageShell",
5056
+ "Paragraph",
5057
+ "SectionIntro",
5058
+ "Stack",
5059
+ "Surface",
5060
+ "formatMoney"
5061
+ ]
5062
+ }
5063
+ ]
5064
+ },
5065
+ {
5066
+ "id": "product-cards",
5067
+ "title": "Product cards",
5068
+ "kind": "design",
5069
+ "level": "organism",
5070
+ "area": "marketing",
5071
+ "situation": "A maker lists its products on one page, and each product has its own site.",
5072
+ "do": [
5073
+ "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A list of products has no main action of its own: each card is a link, not a Button.",
5074
+ "Use `LinkCard` with `image`, `title`, `description` and `caption`, in `Grid columns={2}`.",
5075
+ "Pass `external`. The list stays open in its tab while the product opens in another, and a screen reader hears that the link opens in a new tab. This follows the case 'Site footer': a link to another site opens in a new tab and says so.",
5076
+ "Give each product a title that is its name, a description of one short line, and a caption that says what kind of product it is.",
5077
+ "Pass `alt: ''` for the picture when the title names the product, so a screen reader does not say it twice. Otherwise say what the picture shows.",
5078
+ "Open the section with `SectionIntro`, such as 'Products'.",
5079
+ "Keep to six cards or fewer."
5080
+ ],
5081
+ "dont": [
5082
+ "Do not put a Button inside a card. The card is the link.",
5083
+ "Do not link only the title or only the picture.",
5084
+ "Do not name the link 'Learn more'. The title is the name.",
5085
+ "Do not open a link to a page of your own site in a new tab."
5086
+ ],
5087
+ "native": "On Apple use a `Link` in a `List` row with an `Image`, which opens Safari. On Android use a card that opens a custom tab.",
5088
+ "options": [
5089
+ {
5090
+ "id": "grid",
5091
+ "title": "Cards in a grid",
5092
+ "useWhen": "A maker lists two to six products, and each one leads to its own site.",
5093
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { Grid, PageSection } from 'oneslash-design-system/components/layout';\n\n// Stand-ins for a picture of each product. A real page passes a screenshot or the product's mark.\nconst notesPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23efe9df'/%3E%3Crect x='200' y='50' width='240' height='260' rx='14' fill='%23ffffff'/%3E%3Crect x='224' y='84' width='120' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='224' y='116' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='142' width='170' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='168' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='194' width='110' height='10' rx='5' fill='%23dfe7ef'/%3E%3C/svg%3E\";\nconst tasksPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23e6efe9'/%3E%3Crect x='180' y='60' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='134' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='208' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='198' y='78' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='152' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='226' width='16' height='16' rx='4' fill='%23aab8c6'/%3E%3Crect x='230' y='82' width='160' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='156' width='120' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='230' width='140' height='8' rx='4' fill='%23dfe7ef'/%3E%3C/svg%3E\";\n\nexport default function ProductCardsGrid() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"products\" name=\"Products\" statement=\"Apps from Acme, each with its own site.\" />\n {/* Two across from md, one on a phone. Each card is one link to the product's own site, in a new tab, and says so to a screen reader. */}\n <Grid columns={2}>\n <LinkCard\n href=\"https://notes.acme.example\"\n title=\"Acme Notes\"\n description=\"Write a thing down once and find it again.\"\n caption=\"Notes app\"\n image={{ src: notesPicture, alt: '' }}\n external\n />\n <LinkCard\n href=\"https://tasks.acme.example\"\n title=\"Acme Tasks\"\n description=\"A short list for today, and a long one for later.\"\n caption=\"Task app\"\n image={{ src: tasksPicture, alt: '' }}\n external\n />\n </Grid>\n </PageSection>\n </PageShell>\n );\n}\n",
5094
+ "uses": [
5095
+ "Grid",
5096
+ "LinkCard",
5097
+ "PageSection",
5098
+ "PageShell",
5099
+ "SectionIntro"
5100
+ ]
5101
+ }
5102
+ ]
5103
+ },
4109
5104
  {
4110
5105
  "id": "profile-form",
4111
5106
  "title": "Profile",
@@ -4346,7 +5341,7 @@
4346
5341
  "id": "thumbs",
4347
5342
  "title": "Thumbs",
4348
5343
  "useWhen": "The team wants a signal and will not read reasons.",
4349
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'What changed in the new plans?' };\nconst firstRepliedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each Regenerate writes the next version of the reply.\nconst replies = [\n 'Pro goes from $12 to $15 a month. There is a new Team plan at $25 per seat, and the Free plan stays the same.',\n 'Two things changed. Pro now costs $15 a month instead of $12, and the new Team plan costs $25 per seat.',\n];\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Writing a new reply', done: 'Wrote a new reply' },\n];\n\ntype Thumb = 'up' | 'down' | null;\ntype Phase = 'reply' | 'running' | 'stopping';\n\nfunction stepsUpTo(current: number): StepListStep[] {\n return plan.slice(0, current + 1).map((s, i) => (i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says. While a new reply is written there is\n// no time to show: the old reply's time would be wrong for it.\nfunction agentMeta(at?: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n {at && <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function ReplyFeedbackThumbs() {\n const [thumb, setThumb] = useState<Thumb>(null);\n const [thanks, setThanks] = useState(false);\n const [copied, setCopied] = useState(false);\n const [version, setVersion] = useState(0);\n // Each version of the reply has its own time: a regenerated reply shows when it was written.\n const [repliedAt, setRepliedAt] = useState(firstRepliedAt);\n const [phase, setPhase] = useState<Phase>('reply');\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [stopped, setStopped] = useState(false);\n const thanksTimer = useRef<ReturnType<typeof setTimeout>>();\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const regenerateButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops every timer and the run.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(thanksTimer.current);\n clearTimeout(copyTimer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const reply = replies[version];\n\n // Pressing a thumb marks it, pressing it again clears it, and the other thumb moves the mark.\n // A real app sends the mark to the server; the thanks is the only confirmation.\n function mark(next: 'up' | 'down') {\n const value = thumb === next ? null : next;\n setThumb(value);\n clearTimeout(thanksTimer.current);\n setThanks(value !== null);\n if (value !== null) thanksTimer.current = setTimeout(() => setThanks(false), 2000);\n }\n\n function copy() {\n navigator.clipboard?.writeText(reply).then(() => {\n if (!mounted.current) return;\n setCopied(true);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n }, () => {});\n }\n\n function endRun() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n setPhase('reply');\n // 'Stop' is gone and the buttons are back, so focus returns to Regenerate.\n focusNext.current = () => regenerateButton.current?.focus();\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === plan.length - 1) {\n setVersion((v) => (v + 1) % replies.length);\n setRepliedAt(new Date());\n setThumb(null);\n endRun();\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The reply's row turns into the agent's progress row, as the case 'Agent at work' shows.\n function regenerate() {\n clearTimeout(thanksTimer.current);\n setThanks(false);\n setStopped(false);\n setCurrent(0);\n setSeconds(0);\n setPhase('running');\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n // Regenerate had focus and is gone; 'Stop' takes its place.\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Stop asks the server to end the run. The reply stays as it was.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n setStopped(true);\n endRun();\n }, 1200);\n }\n\n const working = phase !== 'reply';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(working ? undefined : repliedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : (\n // One reply is on screen, so 'reply' is enough in the names. With several, each name says which reply.\n <Cluster gap=\"small\">\n <Tooltip title=\"Mark as helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'up' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsUp\" ariaLabel=\"Mark reply as helpful\" aria-pressed={thumb === 'up'} onClick={() => mark('up')} />\n </Tooltip>\n <Tooltip title=\"Mark as not helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'down' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsDown\" ariaLabel=\"Mark reply as not helpful\" aria-pressed={thumb === 'down'} onClick={() => mark('down')} />\n </Tooltip>\n <Tooltip title={copied ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copied ? 'Check' : 'Copy'} ariaLabel={copied ? 'Copied' : 'Copy reply'} onClick={copy} />\n </Tooltip>\n {/* Only on the latest reply. */}\n <Tooltip title=\"Regenerate\">\n <IconButton ref={regenerateButton} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"RefreshCw\" ariaLabel=\"Regenerate reply\" onClick={regenerate} />\n </Tooltip>\n {/* A real app wraps the thanks in a polite live region. */}\n {thanks && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Thanks. This helps the agent improve.</Paragraph>}\n </Cluster>\n )\n }\n >\n {working ? (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n ) : (\n <Stack gap=\"small\">\n <Paragraph measure=\"none\">{reply}</Paragraph>\n {stopped && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Stopped. Nothing was changed.</Paragraph>}\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5344
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'What changed in the new plans?' };\nconst firstRepliedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each Regenerate writes the next version of the reply.\nconst replies = [\n 'Pro goes from $12 to $15 a month. There is a new Team plan at $25 per seat, and the Free plan stays the same.',\n 'Two things changed. Pro now costs $15 a month instead of $12, and the new Team plan costs $25 per seat.',\n];\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Writing a new reply', done: 'Wrote a new reply' },\n];\n\ntype Thumb = 'up' | 'down' | null;\ntype Phase = 'reply' | 'running' | 'stopping';\n\nfunction stepsUpTo(current: number): StepListStep[] {\n return plan.slice(0, current + 1).map((s, i) => (i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says. While a new reply is written there is\n// no time to show: the old reply's time would be wrong for it.\nfunction agentMeta(at?: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n {at && <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function ReplyFeedbackThumbs() {\n const [thumb, setThumb] = useState<Thumb>(null);\n const [thanks, setThanks] = useState(false);\n const [copied, setCopied] = useState(false);\n const [version, setVersion] = useState(0);\n // Each version of the reply has its own time: a regenerated reply shows when it was written.\n const [repliedAt, setRepliedAt] = useState(firstRepliedAt);\n const [phase, setPhase] = useState<Phase>('reply');\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [stopped, setStopped] = useState(false);\n const thanksTimer = useRef<ReturnType<typeof setTimeout>>();\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const regenerateButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops every timer and the run.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(thanksTimer.current);\n clearTimeout(copyTimer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const reply = replies[version];\n\n // Pressing a thumb marks it, pressing it again clears it, and the other thumb moves the mark.\n // A real app sends the mark to the server; the thanks is the only confirmation.\n function mark(next: 'up' | 'down') {\n const value = thumb === next ? null : next;\n setThumb(value);\n clearTimeout(thanksTimer.current);\n setThanks(value !== null);\n if (value !== null) thanksTimer.current = setTimeout(() => setThanks(false), 2000);\n }\n\n function copy() {\n navigator.clipboard?.writeText(reply).then(() => {\n if (!mounted.current) return;\n setCopied(true);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n }, () => {});\n }\n\n function endRun() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n setPhase('reply');\n // 'Stop' is gone and the buttons are back, so focus returns to Regenerate.\n focusNext.current = () => regenerateButton.current?.focus();\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === plan.length - 1) {\n setVersion((v) => (v + 1) % replies.length);\n setRepliedAt(new Date());\n setThumb(null);\n endRun();\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The reply's row turns into the agent's progress row, as the case 'Agent at work' shows.\n function regenerate() {\n clearTimeout(thanksTimer.current);\n setThanks(false);\n setStopped(false);\n setCurrent(0);\n setSeconds(0);\n setPhase('running');\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n // Regenerate had focus and is gone; 'Stop' takes its place.\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Stop asks the server to end the run. The reply stays as it was.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n setStopped(true);\n endRun();\n }, 1200);\n }\n\n const working = phase !== 'reply';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(working ? undefined : repliedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : (\n // One reply is on screen, so 'reply' is enough in the names. With several, each name says which reply.\n <Cluster gap=\"small\">\n <Tooltip title=\"Mark as helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'up' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsUp\" ariaLabel=\"Mark reply as helpful\" aria-pressed={thumb === 'up'} onClick={() => mark('up')} />\n </Tooltip>\n <Tooltip title=\"Mark as not helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'down' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsDown\" ariaLabel=\"Mark reply as not helpful\" aria-pressed={thumb === 'down'} onClick={() => mark('down')} />\n </Tooltip>\n <Tooltip title={copied ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copied ? 'Check' : 'Copy'} ariaLabel={copied ? 'Copied' : 'Copy reply'} onClick={copy} />\n </Tooltip>\n {/* Only on the latest reply. */}\n <Tooltip title=\"Regenerate\">\n <IconButton ref={regenerateButton} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"RefreshCw\" ariaLabel=\"Regenerate reply\" onClick={regenerate} />\n </Tooltip>\n {/* A real app wraps the thanks in a polite live region. */}\n {thanks && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Thanks. This helps the agent improve.</Paragraph>}\n </Cluster>\n )\n }\n >\n {working ? (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n ) : (\n <Stack gap=\"small\">\n <Paragraph measure=\"none\">{reply}</Paragraph>\n {stopped && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Stopped. Nothing was changed.</Paragraph>}\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
4350
5345
  "uses": [
4351
5346
  "Button",
4352
5347
  "Center",
@@ -4367,7 +5362,7 @@
4367
5362
  "id": "with-reason",
4368
5363
  "title": "With reason",
4369
5364
  "useWhen": "Someone reads the reasons and acts on them.",
4370
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'What changed in the new plans?' };\nconst firstRepliedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each Regenerate writes the next version of the reply.\nconst replies = [\n 'Pro goes from $12 to $15 a month. There is a new Team plan at $25 per seat, and the Free plan stays the same.',\n 'Two things changed. Pro now costs $15 a month instead of $12, and the new Team plan costs $25 per seat.',\n];\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Writing a new reply', done: 'Wrote a new reply' },\n];\n\ntype Thumb = 'up' | 'down' | null;\n\n// A real app sends the reason with the mark, for the team to read.\nconst reasons = ['Inaccurate', 'Off topic', 'Too long', 'Other'];\ntype Phase = 'reply' | 'running' | 'stopping';\n\nfunction stepsUpTo(current: number): StepListStep[] {\n return plan.slice(0, current + 1).map((s, i) => (i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says. While a new reply is written there is\n// no time to show: the old reply's time would be wrong for it.\nfunction agentMeta(at?: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n {at && <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function ReplyFeedbackWithReason() {\n // Opens just after the person pressed thumbs down, so the picture in the docs shows the reasons.\n const [thumb, setThumb] = useState<Thumb>('down');\n const [thanks, setThanks] = useState(false);\n // The reason row, open after thumbs down until a reason or Skip is picked.\n const [asking, setAsking] = useState(true);\n const [copied, setCopied] = useState(false);\n const [version, setVersion] = useState(0);\n // Each version of the reply has its own time: a regenerated reply shows when it was written.\n const [repliedAt, setRepliedAt] = useState(firstRepliedAt);\n const [phase, setPhase] = useState<Phase>('reply');\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [stopped, setStopped] = useState(false);\n const thanksTimer = useRef<ReturnType<typeof setTimeout>>();\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const regenerateButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const thumbsDownButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops every timer and the run.\n useEffect(() => () => {\n mounted.current = false;\n clearTimeout(thanksTimer.current);\n clearTimeout(copyTimer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const reply = replies[version];\n\n function showThanks() {\n clearTimeout(thanksTimer.current);\n setThanks(true);\n thanksTimer.current = setTimeout(() => setThanks(false), 2000);\n }\n\n // Pressing a thumb marks it, pressing it again clears it, and the other thumb moves the mark.\n // Thumbs down asks what was wrong; the thanks waits for the answer.\n // A real app sends the mark to the server; the thanks is the only confirmation.\n function mark(next: 'up' | 'down') {\n const value = thumb === next ? null : next;\n setThumb(value);\n setAsking(value === 'down');\n clearTimeout(thanksTimer.current);\n setThanks(false);\n if (value === 'up') showThanks();\n }\n\n // A reason or Skip closes the row. Focus was on a reason or Skip, so it goes back to thumbs down.\n function finish() {\n setAsking(false);\n showThanks();\n thumbsDownButton.current?.focus();\n }\n\n function copy() {\n navigator.clipboard?.writeText(reply).then(() => {\n if (!mounted.current) return;\n setCopied(true);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n }, () => {});\n }\n\n function endRun() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n setPhase('reply');\n // 'Stop' is gone and the buttons are back, so focus returns to Regenerate.\n focusNext.current = () => regenerateButton.current?.focus();\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === plan.length - 1) {\n setVersion((v) => (v + 1) % replies.length);\n setRepliedAt(new Date());\n setThumb(null);\n endRun();\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The reply's row turns into the agent's progress row, as the case 'Agent at work' shows.\n function regenerate() {\n clearTimeout(thanksTimer.current);\n setThanks(false);\n setAsking(false);\n setStopped(false);\n setCurrent(0);\n setSeconds(0);\n setPhase('running');\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n // Regenerate had focus and is gone; 'Stop' takes its place.\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Stop asks the server to end the run. The reply stays as it was.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n setStopped(true);\n endRun();\n }, 1200);\n }\n\n const working = phase !== 'reply';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(working ? undefined : repliedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : (\n // One reply is on screen, so 'reply' is enough in the names. With several, each name says which reply.\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Tooltip title=\"Mark as helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'up' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsUp\" ariaLabel=\"Mark reply as helpful\" aria-pressed={thumb === 'up'} onClick={() => mark('up')} />\n </Tooltip>\n <Tooltip title=\"Mark as not helpful\">\n <IconButton ref={thumbsDownButton} color=\"iconOnly\" state={thumb === 'down' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsDown\" ariaLabel=\"Mark reply as not helpful\" aria-pressed={thumb === 'down'} onClick={() => mark('down')} />\n </Tooltip>\n <Tooltip title={copied ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copied ? 'Check' : 'Copy'} ariaLabel={copied ? 'Copied' : 'Copy reply'} onClick={copy} />\n </Tooltip>\n {/* Only on the latest reply. */}\n <Tooltip title=\"Regenerate\">\n <IconButton ref={regenerateButton} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"RefreshCw\" ariaLabel=\"Regenerate reply\" onClick={regenerate} />\n </Tooltip>\n {/* A real app wraps the thanks in a polite live region. */}\n {thanks && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Thanks. This helps the agent improve.</Paragraph>}\n </Cluster>\n {asking && (\n <Cluster gap=\"small\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">What was wrong?</Paragraph>\n {/* Each reason is an answer, not a filter, so it is not a toggle. A Cluster cannot be named:\n a real app groups the reasons under the question, named 'What was wrong?'. */}\n {reasons.map((r) => (\n <Tag key={r} variant=\"contained\" size=\"small\" toggle={false} label={r} onClick={finish} />\n ))}\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Skip\" onClickButton={finish} />\n </Cluster>\n )}\n </Stack>\n )\n }\n >\n {working ? (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n ) : (\n <Stack gap=\"small\">\n <Paragraph measure=\"none\">{reply}</Paragraph>\n {stopped && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Stopped. Nothing was changed.</Paragraph>}\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5365
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'What changed in the new plans?' };\nconst firstRepliedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each Regenerate writes the next version of the reply.\nconst replies = [\n 'Pro goes from $12 to $15 a month. There is a new Team plan at $25 per seat, and the Free plan stays the same.',\n 'Two things changed. Pro now costs $15 a month instead of $12, and the new Team plan costs $25 per seat.',\n];\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Writing a new reply', done: 'Wrote a new reply' },\n];\n\ntype Thumb = 'up' | 'down' | null;\n\n// A real app sends the reason with the mark, for the team to read.\nconst reasons = ['Inaccurate', 'Off topic', 'Too long', 'Other'];\ntype Phase = 'reply' | 'running' | 'stopping';\n\nfunction stepsUpTo(current: number): StepListStep[] {\n return plan.slice(0, current + 1).map((s, i) => (i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says. While a new reply is written there is\n// no time to show: the old reply's time would be wrong for it.\nfunction agentMeta(at?: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n {at && <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function ReplyFeedbackWithReason() {\n // Opens just after the person pressed thumbs down, so the picture in the docs shows the reasons.\n const [thumb, setThumb] = useState<Thumb>('down');\n const [thanks, setThanks] = useState(false);\n // The reason row, open after thumbs down until a reason or Skip is picked.\n const [asking, setAsking] = useState(true);\n const [copied, setCopied] = useState(false);\n const [version, setVersion] = useState(0);\n // Each version of the reply has its own time: a regenerated reply shows when it was written.\n const [repliedAt, setRepliedAt] = useState(firstRepliedAt);\n const [phase, setPhase] = useState<Phase>('reply');\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [stopped, setStopped] = useState(false);\n const thanksTimer = useRef<ReturnType<typeof setTimeout>>();\n const copyTimer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const regenerateButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const thumbsDownButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The clipboard answers later; by then the example may be gone.\n const mounted = useRef(true);\n\n // On unmount it stops every timer and the run.\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n clearTimeout(thanksTimer.current);\n clearTimeout(copyTimer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n };\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const reply = replies[version];\n\n function showThanks() {\n clearTimeout(thanksTimer.current);\n setThanks(true);\n thanksTimer.current = setTimeout(() => setThanks(false), 2000);\n }\n\n // Pressing a thumb marks it, pressing it again clears it, and the other thumb moves the mark.\n // Thumbs down asks what was wrong; the thanks waits for the answer.\n // A real app sends the mark to the server; the thanks is the only confirmation.\n function mark(next: 'up' | 'down') {\n const value = thumb === next ? null : next;\n setThumb(value);\n setAsking(value === 'down');\n clearTimeout(thanksTimer.current);\n setThanks(false);\n if (value === 'up') showThanks();\n }\n\n // A reason or Skip closes the row. Focus was on a reason or Skip, so it goes back to thumbs down.\n function finish() {\n setAsking(false);\n showThanks();\n thumbsDownButton.current?.focus();\n }\n\n function copy() {\n navigator.clipboard?.writeText(reply).then(() => {\n if (!mounted.current) return;\n setCopied(true);\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n }, () => {});\n }\n\n function endRun() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n setPhase('reply');\n // 'Stop' is gone and the buttons are back, so focus returns to Regenerate.\n focusNext.current = () => regenerateButton.current?.focus();\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === plan.length - 1) {\n setVersion((v) => (v + 1) % replies.length);\n setRepliedAt(new Date());\n setThumb(null);\n endRun();\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The reply's row turns into the agent's progress row, as the case 'Agent at work' shows.\n function regenerate() {\n clearTimeout(thanksTimer.current);\n setThanks(false);\n setAsking(false);\n setStopped(false);\n setCurrent(0);\n setSeconds(0);\n setPhase('running');\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n // Regenerate had focus and is gone; 'Stop' takes its place.\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Stop asks the server to end the run. The reply stays as it was.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n setStopped(true);\n endRun();\n }, 1200);\n }\n\n const working = phase !== 'reply';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(working ? undefined : repliedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : (\n // One reply is on screen, so 'reply' is enough in the names. With several, each name says which reply.\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Tooltip title=\"Mark as helpful\">\n <IconButton color=\"iconOnly\" state={thumb === 'up' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsUp\" ariaLabel=\"Mark reply as helpful\" aria-pressed={thumb === 'up'} onClick={() => mark('up')} />\n </Tooltip>\n <Tooltip title=\"Mark as not helpful\">\n <IconButton ref={thumbsDownButton} color=\"iconOnly\" state={thumb === 'down' ? 'selected' : 'enabled'} size=\"small\" iconName=\"ThumbsDown\" ariaLabel=\"Mark reply as not helpful\" aria-pressed={thumb === 'down'} onClick={() => mark('down')} />\n </Tooltip>\n <Tooltip title={copied ? 'Copied' : 'Copy'}>\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName={copied ? 'Check' : 'Copy'} ariaLabel={copied ? 'Copied' : 'Copy reply'} onClick={copy} />\n </Tooltip>\n {/* Only on the latest reply. */}\n <Tooltip title=\"Regenerate\">\n <IconButton ref={regenerateButton} color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"RefreshCw\" ariaLabel=\"Regenerate reply\" onClick={regenerate} />\n </Tooltip>\n {/* A real app wraps the thanks in a polite live region. */}\n {thanks && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Thanks. This helps the agent improve.</Paragraph>}\n </Cluster>\n {asking && (\n <Cluster gap=\"small\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">What was wrong?</Paragraph>\n {/* Each reason is an answer, not a filter, so it is not a toggle. A Cluster cannot be named:\n a real app groups the reasons under the question, named 'What was wrong?'. */}\n {reasons.map((r) => (\n <Tag key={r} variant=\"contained\" size=\"small\" toggle={false} label={r} onClick={finish} />\n ))}\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Skip\" onClickButton={finish} />\n </Cluster>\n )}\n </Stack>\n )\n }\n >\n {working ? (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n ) : (\n <Stack gap=\"small\">\n <Paragraph measure=\"none\">{reply}</Paragraph>\n {stopped && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Stopped. Nothing was changed.</Paragraph>}\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
4371
5366
  "uses": [
4372
5367
  "Button",
4373
5368
  "Center",
@@ -4547,6 +5542,62 @@
4547
5542
  }
4548
5543
  ]
4549
5544
  },
5545
+ {
5546
+ "id": "section-index",
5547
+ "title": "Section index",
5548
+ "kind": "design",
5549
+ "level": "organism",
5550
+ "area": "content",
5551
+ "situation": "A section of a site, such as the guides, has its own first page that shows the places inside it, so a person can pick one.",
5552
+ "do": [
5553
+ "Use `PageHeader` with `level={1}`: the section's name is the one level 1 heading, with a `lede` of one sentence.",
5554
+ "Put the places in a `Grid columns={3}` for `cards`: three across from the medium breakpoint, one on a phone. Make each a `LinkCard` with a `title` and a `description` of one short line.",
5555
+ "Write the title as the name of the page it goes to, and the description as what a person finds there, not as a call to action.",
5556
+ "Keep a card that leaves the site, a `LinkCard` with `external`, in a group of its own, so a person is not sent away by surprise.",
5557
+ "Group the places under level 2 `SectionIntro`s for `list`, and put the places of each group in a `List`, each a `Link` with `size=\"subtitle1\"` and a `Paragraph` line under it. Put the places a new person needs first.",
5558
+ "Order the places the way a person does the work, not alphabetically, unless there are more than about twenty.",
5559
+ "Pass `image` to the `LinkCard` when a place has an image, with alt text that says what it shows, or `alt=\"\"` when the title says it all."
5560
+ ],
5561
+ "dont": [
5562
+ "Do not put more than about nine cards in a grid. A person cannot compare more, so use `list`.",
5563
+ "Do not repeat the section name in every title.",
5564
+ "Do not write a description that repeats its title.",
5565
+ "Do not make a card out of a place with nothing in it yet. Leave it out until it has a page.",
5566
+ "Do not wrap a `LinkCard` in a second link or put a Button inside it."
5567
+ ],
5568
+ "native": "On Apple use a `List` of `NavigationLink` rows with a subtitle, grouped in `Section`s. On Android use a `LazyColumn` of list items with supporting text, or a grid of cards for a few places.",
5569
+ "options": [
5570
+ {
5571
+ "id": "cards",
5572
+ "title": "Cards with a line each",
5573
+ "useWhen": "Up to about nine places, each with a short line that says what is there.",
5574
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport LinkCard from 'oneslash-design-system/components/linkCard';\nimport { Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// Six places, each with a line that says what is there. A real site lists its own pages.\nconst guides = [\n { id: 'start', title: 'Get started', line: 'Name your workspace and add the first people.' },\n { id: 'channels', title: 'Channels', line: 'One place for the talk about each subject.' },\n { id: 'tasks', title: 'Tasks', line: 'Give work an owner and a due date.' },\n { id: 'notes', title: 'Notes', line: 'Write a decision once and find it later.' },\n { id: 'agent', title: 'The agent', line: 'Ask a question and see the sources it used.' },\n { id: 'billing', title: 'Plans and billing', line: 'Change plan and download invoices.' },\n];\n\nexport default function SectionIndexCards() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Guides\" lede=\"How to do each thing in Acme, one page for each.\" />\n {/* Three across from md, one on a phone. Every card is one link, named by its title and its line. */}\n <Grid columns={3}>\n {guides.map((g) => (\n <LinkCard key={g.id} href={`#${g.id}`} title={g.title} description={g.line} />\n ))}\n </Grid>\n </Stack>\n </PageShell>\n );\n}\n",
5575
+ "uses": [
5576
+ "Grid",
5577
+ "LinkCard",
5578
+ "PageHeader",
5579
+ "PageShell",
5580
+ "Stack"
5581
+ ]
5582
+ },
5583
+ {
5584
+ "id": "list",
5585
+ "title": "A list of links in groups",
5586
+ "useWhen": "More places than nine, or names that say enough without a line of their own.",
5587
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Link from 'oneslash-design-system/components/link';\nimport List from 'oneslash-design-system/components/list';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Many places, in groups. A real site builds this from its own list of pages.\nconst groups = [\n {\n id: 'section-index-start',\n name: 'Start here',\n pages: [\n { id: 'workspace', title: 'Make a workspace', line: 'Name it and choose a plan.' },\n { id: 'invite', title: 'Invite people', line: 'Invite by email and choose what each person can do.' },\n { id: 'tour', title: 'A tour of Acme', line: 'Channels, tasks, notes and the agent in one page.' },\n ],\n },\n {\n id: 'section-index-work',\n name: 'Everyday work',\n pages: [\n { id: 'channels', title: 'Channels', line: 'One place for the talk about each subject.' },\n { id: 'threads', title: 'Threads', line: 'Reply to one message without filling the channel.' },\n { id: 'tasks', title: 'Tasks', line: 'Give work an owner and a due date.' },\n { id: 'notes', title: 'Notes', line: 'Write a decision once and find it later.' },\n { id: 'search', title: 'Search', line: 'Find a message, a note or a file from one box.' },\n ],\n },\n {\n id: 'section-index-admin',\n name: 'Run a workspace',\n pages: [\n { id: 'members', title: 'Members and roles', line: 'Who can read, write and change settings.' },\n { id: 'billing', title: 'Plans and billing', line: 'Change plan and download invoices.' },\n { id: 'export', title: 'Export your notes', line: 'Take a note or a whole workspace as PDF.' },\n { id: 'delete', title: 'Delete a workspace', line: 'What is removed, and what you can get back.' },\n ],\n },\n];\n\nexport default function SectionIndexList() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <PageHeader level={1} title=\"Guides\" lede=\"How to do each thing in Acme, one page for each.\" />\n {groups.map((group) => (\n <PageSection key={group.id} gap=\"xlarge\">\n {/* The group's name is the level 2 heading. Each link has its line under it. */}\n <SectionIntro id={group.id} name={group.name} />\n <List\n items={group.pages.map((p) => (\n <Stack key={p.id} gap=\"small\">\n <Link href={`#${p.id}`} size=\"subtitle1\">{p.title}</Link>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{p.line}</Paragraph>\n </Stack>\n ))}\n />\n </PageSection>\n ))}\n </Stack>\n </PageShell>\n );\n}\n",
5588
+ "uses": [
5589
+ "Link",
5590
+ "List",
5591
+ "PageHeader",
5592
+ "PageSection",
5593
+ "PageShell",
5594
+ "Paragraph",
5595
+ "SectionIntro",
5596
+ "Stack"
5597
+ ]
5598
+ }
5599
+ ]
5600
+ },
4550
5601
  {
4551
5602
  "id": "set-new-password",
4552
5603
  "title": "Set new password",
@@ -5010,7 +6061,7 @@
5010
6061
  "Give a site with sections one `TabsContainer` of `Tab`s with `href`, four sections or fewer and one short word each. Pass it as `nav` to `SiteHeader` with `links` empty: it is a second row of the bar at every width.",
5011
6062
  "Pass search and the theme menu as `phoneAction`, so they stay at the end of the bar on a phone. With no `links` and no `actions` there is no menu.",
5012
6063
  "Keep the section tabs in the bar, so no section is hidden. On a phone, put the pages of the open section in a menu, as the case 'Menu on a phone' shows in 'Sections with their pages'.",
5013
- "Open the theme menu as the case 'Theme switcher' says, and name the search `IconButton` 'Search'."
6064
+ "Open the theme menu as the case 'Theme switcher' says, and open search as the case 'Site search' says."
5014
6065
  ],
5015
6066
  "dont": [
5016
6067
  "Do not show more than five links in the bar.",
@@ -5057,6 +6108,53 @@
5057
6108
  }
5058
6109
  ]
5059
6110
  },
6111
+ {
6112
+ "id": "site-search",
6113
+ "title": "Site search",
6114
+ "kind": "design",
6115
+ "level": "organism",
6116
+ "area": "content",
6117
+ "situation": "A site has many pages, and a person wants to reach one by its name or by a word in it, from any page.",
6118
+ "do": [
6119
+ "Put a 'Search' `Button` with `decoIcon=\"Search\"` in the `SiteHeader`, in `phoneAction`, so it stays in the bar at every width. Give it `aria-haspopup=\"dialog\"` and `aria-keyshortcuts=\"Meta+K Control+K\"`.",
6120
+ "Put Search before 'Sign Up' in `phoneAction` on a site with a main action, as an `IconButton` named 'Search', so both fit on a phone.",
6121
+ "Open the same dialog with Cmd+K, or Ctrl+K on Windows, using `useHotkey('k', …)`. The shortcut does nothing while a person types in a field. Say it on the page in words, as the case 'Quick switcher' does.",
6122
+ "Use `SearchDialog`. Keep the query and the results in your page and pass them in with `status`. Focus stays in the field; the arrow keys move the highlight, Enter follows the highlighted link and Escape closes it.",
6123
+ "Group the results under names such as 'Components' and 'Cases', and give each a `secondLabel` that says where it is and an `excerpt` of the text around the match. The words typed are marked in the title and the excerpt, as written, so 'c++ (beta)' is not read as a pattern.",
6124
+ "Set `status` to 'loading' when you ask and 'done' when the answer comes. After 300 ms the dialog says 'Searching' once and keeps the old results, marked `aria-busy`. A search that is faster than that shows no flash.",
6125
+ "Number each request and drop a reply for an older query. Keep timers in a ref and clear them on unmount.",
6126
+ "Show `recent` places before anything is typed, at most six, newest first.",
6127
+ "Let the dialog say what was searched when nothing matches, with 'Clear Search' that puts focus back in the field, as the case 'Empty search' says. Set `status` to 'error' when the request fails: it says 'Search is not working right now.' with 'Try Again'; pass `onRetry`.",
6128
+ "Use the case 'Quick switcher' instead inside an app, with workspaces, channels and people."
6129
+ ],
6130
+ "dont": [
6131
+ "Do not put the Search Button in `actions`. On a phone it moves into the menu, which closes when it is chosen, so the dialog has no Button to give focus back to.",
6132
+ "Do not search on every key with no wait for the answer. Drop an answer that is out of date instead.",
6133
+ "Do not build the dialog, the list and the keys by hand. `SearchDialog` does the roles, the focus and the status.",
6134
+ "Do not write the match as a pattern. A person may type brackets or a plus sign.",
6135
+ "Do not show a spinner in place of the results. Keep the old results on screen while the new ones load.",
6136
+ "Do not close the dialog when 'Clear Search' is pressed. A person who cleared the words wants to search again."
6137
+ ],
6138
+ "native": "On Apple use `searchable` on a `NavigationStack`, with `searchSuggestions` for recent places and `searchScopes` for the groups. On Android use a `SearchBar` with a `DockedSearchBar` or a full-screen search view.",
6139
+ "options": [
6140
+ {
6141
+ "id": "dialog",
6142
+ "title": "Search in a dialog",
6143
+ "useWhen": "A site with many pages, searched from anywhere.",
6144
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport SearchDialog, { type SearchGroup, type SearchResult } from 'oneslash-design-system/components/searchDialog';\nimport useHotkey from 'oneslash-design-system/components/useHotkey';\nimport Button from 'oneslash-design-system/components/button';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\ntype Entry = SearchResult & { group: 'Components' | 'Cases'; text: string };\n\n// A real site asks its server, which has every page. These are the pages of a made-up docs site.\nconst entries: Entry[] = [\n { id: 'button', group: 'Components', title: 'Button', secondLabel: 'Components', href: '#button', iconName: 'MousePointerClick', text: 'The control that starts an action, in four sizes.' },\n { id: 'tag', group: 'Components', title: 'Tag', secondLabel: 'Components', href: '#tag', iconName: 'Tag', text: 'A short label for a state, such as Paid or Draft.' },\n { id: 'tabs', group: 'Components', title: 'Tabs', secondLabel: 'Components', href: '#tabs', iconName: 'PanelTop', text: 'Switch between views of one thing on one page.' },\n { id: 'table', group: 'Components', title: 'Table', secondLabel: 'Components', href: '#table', iconName: 'Table', text: 'Rows and columns that scroll inside their own region.' },\n { id: 'accordion', group: 'Components', title: 'Accordion', secondLabel: 'Components', href: '#accordion', iconName: 'ChevronsUpDown', text: 'Headings that open a panel under them.' },\n { id: 'faq', group: 'Cases', title: 'FAQ', secondLabel: 'Cases', href: '#faq', iconName: 'CircleHelp', text: 'Answer the questions a visitor asks before signing up.' },\n { id: 'pricing', group: 'Cases', title: 'Pricing section', secondLabel: 'Cases', href: '#pricing', iconName: 'CreditCard', text: 'Show the plans side by side with one price each.' },\n { id: 'login', group: 'Cases', title: 'Login page', secondLabel: 'Cases', href: '#login', iconName: 'LogIn', text: 'Let a person log in with an email or a provider.' },\n { id: 'tabbed', group: 'Cases', title: 'Tabbed panels', secondLabel: 'Cases', href: '#tabbed', iconName: 'PanelTop', text: 'Four views of one thing, and a visitor reads one.' },\n];\n\nconst SEARCH_MS = 300;\n\n// A stand-in for the request. A real site calls its server here and may fail.\nfunction searchPages(query: string, keep: (t: ReturnType<typeof setTimeout>) => void): Promise<SearchGroup[]> {\n return new Promise((resolve) => {\n keep(setTimeout(() => {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n const found = entries.filter((e) => words.every((w) => `${e.title} ${e.text}`.toLowerCase().includes(w)));\n const groups = (['Components', 'Cases'] as const)\n .map((label) => ({ label, items: found.filter((e) => e.group === label).map(({ group, text, ...item }) => ({ ...item, excerpt: text })) }))\n .filter((g) => g.items.length > 0);\n resolve(groups);\n }, SEARCH_MS));\n });\n}\n\n// Visited pages, most recent first. A real site keeps them for the person.\nconst recent: SearchResult[] = entries.slice(0, 3).map(({ group, text, ...item }) => item);\n\nexport default function SiteSearchDialog() {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [groups, setGroups] = useState<SearchGroup[]>([]);\n const [status, setStatus] = useState<'idle' | 'loading' | 'done' | 'error'>('idle');\n // Each request has a number; only the newest one may answer.\n const latest = useRef(0);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n useEffect(() => () => clearTimeout(timer.current), []);\n\n function run(next: string) {\n const id = ++latest.current;\n if (next.trim() === '') {\n setStatus('idle');\n setGroups([]);\n return;\n }\n setStatus('loading');\n // An older request's timer is cleared, so only one is ever pending and unmount clears it\n searchPages(next, (t) => {\n clearTimeout(timer.current);\n timer.current = t;\n })\n .then((found) => {\n // A reply for an older query is dropped\n if (id !== latest.current) return;\n setGroups(found);\n setStatus('done');\n })\n .catch(() => {\n if (id !== latest.current) return;\n setStatus('error');\n });\n }\n\n function change(next: string) {\n setQuery(next);\n run(next);\n }\n\n function show() {\n setQuery('');\n run('');\n setOpen(true);\n }\n\n // Cmd+K, or Ctrl+K on Windows, from anywhere on the page except a text field\n useHotkey('k', () => {\n if (!open) show();\n });\n\n return (\n <>\n {/* The Search Button is the main action of the bar, so it stays beside the brand at every width. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme' }}\n links={[\n { label: 'Guides', href: '#guides' },\n { label: 'Components', href: '#components', current: true },\n { label: 'Cases', href: '#cases' },\n ]}\n phoneAction={\n <Button\n size=\"medium\"\n type=\"secondary\"\n state=\"enabled\"\n label=\"Search\"\n decoIcon=\"Search\"\n aria-haspopup=\"dialog\"\n aria-keyshortcuts=\"Meta+K Control+K\"\n onClickButton={show}\n />\n }\n mainId=\"site-search-main\"\n />\n <PageShell id=\"site-search-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Components</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Press Cmd+K, or Ctrl+K on Windows, to search every page.</Paragraph>\n </Stack>\n </PageShell>\n <SearchDialog\n isOpen={open}\n onClose={() => setOpen(false)}\n query={query}\n onQueryChange={change}\n groups={groups}\n status={status}\n onRetry={() => run(query)}\n recent={recent}\n placeholder=\"Search components and cases\"\n />\n </>\n );\n}\n",
6145
+ "uses": [
6146
+ "Button",
6147
+ "Heading",
6148
+ "PageShell",
6149
+ "Paragraph",
6150
+ "SearchDialog",
6151
+ "SiteHeader",
6152
+ "Stack",
6153
+ "useHotkey"
6154
+ ]
6155
+ }
6156
+ ]
6157
+ },
5060
6158
  {
5061
6159
  "id": "slash-command-list",
5062
6160
  "title": "Command list",
@@ -5252,6 +6350,52 @@
5252
6350
  ],
5253
6351
  "native": "On Apple there is no toast. Show the result in place."
5254
6352
  },
6353
+ {
6354
+ "id": "tabbed-panels",
6355
+ "title": "Tabbed panels",
6356
+ "kind": "design",
6357
+ "level": "organism",
6358
+ "area": "marketing",
6359
+ "situation": "A page shows several views of one thing, and a visitor reads one of them at a time.",
6360
+ "do": [
6361
+ "Put the section's name in `SectionIntro`, so the section has a level 2 heading. Give the panel's title a level 3 `Heading`.",
6362
+ "Use `TabsContainer` with one `Tab` for each view. Write each label in Title Case, as one short word, and use `size=\"small\"` so four fit on a phone.",
6363
+ "Give each `Tab` an `id` and `controls`, and put each view in a `TabPanel` named by its Tab. Every panel is in the page; only the selected one shows. Name the tablist with `aria-labelledby` on `TabsContainer`.",
6364
+ "Keep the selected tab in state. Put the view most visitors need first.",
6365
+ "Keep two to five tabs, and four when you can: they fit on a phone. A fifth scrolls inside the row and the page does not.",
6366
+ "Give every panel the same shape: a title, a line and a short `List`, so the page does not jump when a visitor changes tab.",
6367
+ "Use stacked sections, each with its own level 2 heading, for more than five views or for views everyone must read.",
6368
+ "Use `SegmentedControl` instead when the choice changes a value, as the case 'Range switch' says."
6369
+ ],
6370
+ "dont": [
6371
+ "Do not hide something a visitor must read behind a tab.",
6372
+ "Do not use these tabs for a site's sections or an app's areas. Those are `Tab`s with `href`, as the cases 'Site header' and 'Settings page' say.",
6373
+ "Do not give a tab an icon or a long label. It will not fit on a phone.",
6374
+ "Do not change the tab on a timer.",
6375
+ "Do not nest tabs inside a panel."
6376
+ ],
6377
+ "native": "On Apple use a segmented `Picker` for two to five views, and a `TabView` only for the app's own areas. On Android use a `TabRow`.",
6378
+ "options": [
6379
+ {
6380
+ "id": "tabs",
6381
+ "title": "Tabs over one panel",
6382
+ "useWhen": "There are two to five views of one thing, and a visitor reads one.",
6383
+ "source": "'use client';\nimport { useState } from 'react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport TabPanel from 'oneslash-design-system/components/tabPanel';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport { PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Four views of one thing, and a visitor reads one. The first is the one most visitors need.\nconst views = [\n { id: 'channels', label: 'Channels', title: 'One place for each subject', line: 'A channel holds the talk about one team or project.', points: ['Everyone in a channel sees every message.', 'Pin the messages people need again.', 'Turn a message into a task when it needs an owner.'] },\n { id: 'tasks', label: 'Tasks', title: 'A task and its talk together', line: 'A task keeps its owner, its status and its talk together.', points: ['Give a task one owner and one due date.', 'Reply in the task, not in the channel.', 'Close the task when the work is done.'] },\n { id: 'notes', label: 'Notes', title: 'Notes the whole team can search', line: 'Write a decision once and find it later.', points: ['Link a note to the task it came from.', 'Search every note from one box.', 'Export a note to PDF on Pro and Business.'] },\n { id: 'agent', label: 'Agent', title: 'Answers with their sources', line: 'Ask the agent a question in any channel or task.', points: ['It says which notes and messages it used.', 'It never reads a channel you are not in.', 'Each reply counts as one AI agent response.'] },\n];\n\nexport default function TabbedPanelsTabs() {\n const [selected, setSelected] = useState('channels');\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"how-it-works\" name=\"How it works\" statement=\"Four parts, each for one kind of work.\" />\n <Stack gap=\"xlarge\">\n {/* Title Case, one short word each. The tablist is named by the section's heading, and each Tab controls its panel. */}\n <TabsContainer aria-labelledby=\"how-it-works\">\n {views.map((v) => (\n <Tab key={v.id} id={`tabbed-panels-tab-${v.id}`} controls={`tabbed-panels-panel-${v.id}`} size=\"small\" label={v.label} isSelected={v.id === selected} onClickTab={() => setSelected(v.id)} />\n ))}\n </TabsContainer>\n {/* Every panel is in the page. Only the selected one shows. */}\n {views.map((v) => (\n <TabPanel key={v.id} id={`tabbed-panels-panel-${v.id}`} labelledBy={`tabbed-panels-tab-${v.id}`} selected={v.id === selected}>\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h5\">{v.title}</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">{v.line}</Paragraph>\n <List items={v.points} marker=\"dot\" />\n </Stack>\n </TabPanel>\n ))}\n </Stack>\n </PageSection>\n </PageShell>\n );\n}\n",
6384
+ "uses": [
6385
+ "Heading",
6386
+ "List",
6387
+ "PageSection",
6388
+ "PageShell",
6389
+ "Paragraph",
6390
+ "SectionIntro",
6391
+ "Stack",
6392
+ "Tab",
6393
+ "TabPanel",
6394
+ "TabsContainer"
6395
+ ]
6396
+ }
6397
+ ]
6398
+ },
5255
6399
  {
5256
6400
  "id": "tag-filter",
5257
6401
  "title": "Tag filter",