oneslash-design-system 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/DESIGN.md +13 -2
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +240 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +542 -0
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/dashboard/numbers-first.jsx +62 -1
- package/dist/cases/dashboard.md +75 -3
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/number-format.md +4 -2
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/stat-row.md +1 -1
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +645 -7
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +90 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/popover.jsx +7 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/native-mapping.json +19 -1
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +16 -0
- package/dist/stories/Cases.generated.stories.jsx +32 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +1 -0
- package/dist/stories/Popover.stories.jsx +17 -0
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/package.json +1 -1
package/dist/cases.json
CHANGED
|
@@ -162,6 +162,86 @@
|
|
|
162
162
|
}
|
|
163
163
|
]
|
|
164
164
|
},
|
|
165
|
+
{
|
|
166
|
+
"id": "activity-timeline",
|
|
167
|
+
"title": "History and activity",
|
|
168
|
+
"kind": "design",
|
|
169
|
+
"level": "organism",
|
|
170
|
+
"area": "shell",
|
|
171
|
+
"situation": "A person reads what happened on a task, or opens an older version of a document and brings it back.",
|
|
172
|
+
"do": [
|
|
173
|
+
"Show the history in a `SidePane` titled 'History' beside the page, as the case 'Side pane' says.",
|
|
174
|
+
"Use `Timeline`, newest first. It draws one dot per row and a line to the next.",
|
|
175
|
+
"Write each event as who did what: 'Dana Lee approved the plan', 'Acme Agent opened a pull request'.",
|
|
176
|
+
"Write each time in full in `when`, such as 'Nov 16, 2026, 2:40 PM', and the ISO value in `dateTime`.",
|
|
177
|
+
"Pass `actor` with `agent: true` for the agent, so its row shows the agent face and no picture.",
|
|
178
|
+
"Pass `href` when an event has a page of its own, such as a pull request. The title becomes the link.",
|
|
179
|
+
"Mark an event that needs a look with a `tag`, such as a warning 'Needs fixing' on 'Check failed'. The word says it, not the dot.",
|
|
180
|
+
"Pass `onSelect` and `selectedId` for versions. Each row is one button, and the chosen one has `aria-current`.",
|
|
181
|
+
"Give the newest version the `tag` 'Current'.",
|
|
182
|
+
"Show the chosen version under the list, with who saved it and when, and a secondary Button 'Restore This Version'. The current version has no Restore.",
|
|
183
|
+
"Confirm a restore in a small Modal, as the rule 'A confirm says exactly what will happen' says. Title it 'Restore Version', with 'Cancel' and then 'Restore'.",
|
|
184
|
+
"Say in the body what changes and what is kept: 'This makes the version from Nov 15, 2026, 5:45 PM the current plan, and everyone signs it off again. Your current plan is kept as a version.'",
|
|
185
|
+
"Make 'Restore' `loading` with its label, disable 'Cancel' and ignore `onClose` while the request runs.",
|
|
186
|
+
"Add the restore as the newest version once it works, marked Current, and say so in an inline success `Alert`.",
|
|
187
|
+
"Show `Skeleton` rows while the history loads, then the list as soon as it loads.",
|
|
188
|
+
"Say that it failed when the history cannot load, as the case 'Load failure' says: 'Could not load the history', with 'Try Again'.",
|
|
189
|
+
"Show `EmptyBox` when there is nothing yet, as the rule 'An empty list says what will fill it' says: 'No changes yet' and 'Each saved edit shows here.'"
|
|
190
|
+
],
|
|
191
|
+
"dont": [
|
|
192
|
+
"Do not color the dots by the kind of event. A color with no word means nothing to a screen reader.",
|
|
193
|
+
"Do not show a relative time alone, such as '2h'. Write the date and the time.",
|
|
194
|
+
"Do not show the empty text when the history failed to load.",
|
|
195
|
+
"Do not let a restore overwrite the current version. Keep it as a version first.",
|
|
196
|
+
"Do not draw the dots and the line by hand. Use `Timeline`."
|
|
197
|
+
],
|
|
198
|
+
"native": "On Apple use a `List` of rows with a `Circle` and a connecting line in an overlay, in an inspector, and a `confirmationDialog` for a restore. On Android use a `LazyColumn` with the dot and line drawn behind each row, in a side sheet.",
|
|
199
|
+
"options": [
|
|
200
|
+
{
|
|
201
|
+
"id": "activity",
|
|
202
|
+
"title": "Activity",
|
|
203
|
+
"useWhen": "A person reads what happened on a task, in order.",
|
|
204
|
+
"source": "'use client';\nimport { useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Timeline, { type TimelineItem } from 'oneslash-design-system/components/timeline';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst task = 'Launch checklist';\n\n// Newest first. Each title says who did what, and each time is written in full.\nconst events: TimelineItem[] = [\n { id: 'e6', title: 'Check failed', when: 'Nov 16, 2026, 3:05 PM', dateTime: '2026-11-16T15:05', detail: 'The sign-up form test failed on a phone.', tag: { label: 'Needs fixing', color: 'warning' } },\n { id: 'e5', title: 'Acme Agent opened a pull request', when: 'Nov 16, 2026, 2:58 PM', dateTime: '2026-11-16T14:58', actor: { name: 'Acme Agent', agent: true }, detail: 'Updates the home page and its tests', href: '/pulls/42' },\n { id: 'e4', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },\n { id: 'e3', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },\n { id: 'e2', title: 'Ben Carter added Omar Reyes to the task', when: 'Nov 15, 2026, 4:10 PM', dateTime: '2026-11-15T16:10', actor: { name: 'Ben Carter' } },\n { id: 'e1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function ActivityTimelineActivity() {\n const [navOpen, setNavOpen] = useState(false);\n // The person opened the history from the task header. The example starts with the pane open.\n const [open, setOpen] = useState(true);\n const pane = useRef<SidePaneHandle>(null);\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane ref={pane} title=\"History\" onClose={() => setOpen(false)}>\n {/* A real app shows Skeleton rows while it loads, the case 'Load failure' if it fails, and EmptyBox when there is nothing yet. */}\n <Timeline id=\"activity-timeline-events\" aria-label={`History of ${task}`} items={events} />\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n actions={\n <Tooltip title=\"History\">\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"History\"\n ariaLabel={`Show the history of ${task}`}\n aria-expanded={open}\n onClick={() => (open ? pane.current?.focus() : setOpen(true))}\n />\n </Tooltip>\n }\n />\n <Paragraph tone=\"secondary\" measure=\"none\">Acme Agent opened a pull request for the new home page. One check failed.</Paragraph>\n </Stack>\n </AppShell>\n );\n}\n",
|
|
205
|
+
"uses": [
|
|
206
|
+
"AppShell",
|
|
207
|
+
"IconButton",
|
|
208
|
+
"MenuItem",
|
|
209
|
+
"Navigation",
|
|
210
|
+
"Paragraph",
|
|
211
|
+
"SidePane",
|
|
212
|
+
"Stack",
|
|
213
|
+
"Timeline",
|
|
214
|
+
"TitleBar",
|
|
215
|
+
"Tooltip"
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"id": "versions",
|
|
220
|
+
"title": "Versions",
|
|
221
|
+
"useWhen": "A document has saved versions that a person can open and restore.",
|
|
222
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Timeline from 'oneslash-design-system/components/timeline';\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 Line from 'oneslash-design-system/components/line';\nimport Button from 'oneslash-design-system/components/button';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Alert from 'oneslash-design-system/components/alert';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Version = {\n id: string;\n title: string;\n when: string;\n dateTime: string;\n by: string;\n agent?: boolean;\n steps: string[];\n};\n\nconst task = 'Launch checklist';\n\n// The plan's saved versions, newest first. The newest is the current plan.\nconst firstVersions: Version[] = [\n { id: 'v5', title: 'Moved the launch to Nov 20, 2026', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', by: 'Dana Lee', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 20, 2026.'] },\n { id: 'v4', title: 'Added a check on a phone', when: 'Nov 16, 2026, 9:10 AM', dateTime: '2026-11-16T09:10', by: 'Acme Agent', agent: true, steps: ['Update the home page and its tests.', 'Write the new copy.', 'Check the screens on a phone.', 'Merge on Nov 18, 2026.'] },\n { id: 'v3', title: 'Gave the copy to Omar Reyes', when: 'Nov 15, 2026, 5:45 PM', dateTime: '2026-11-15T17:45', by: 'Ben Carter', steps: ['Update the home page and its tests.', 'Write the new copy.', 'Merge on Nov 18, 2026.'] },\n { id: 'v2', title: 'Split the release into two steps', when: 'Nov 15, 2026, 1:00 PM', dateTime: '2026-11-15T13:00', by: 'Acme Agent', agent: true, steps: ['Update the home page.', 'Merge on Nov 18, 2026.'] },\n { id: 'v1', title: 'Wrote the first plan', when: 'Nov 14, 2026, 10:20 AM', dateTime: '2026-11-14T10:20', by: 'Acme Agent', agent: true, steps: ['Update the home page and merge it.'] },\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function ActivityTimelineVersions() {\n const [navOpen, setNavOpen] = useState(false);\n // The person opened the history from the task header and chose a version. The example starts there.\n const [open, setOpen] = useState(true);\n const [versions, setVersions] = useState(firstVersions);\n const [selectedId, setSelectedId] = useState('v4');\n const [confirming, setConfirming] = useState(false);\n const [restoring, setRestoring] = useState(false);\n const [restored, setRestored] = useState<string | null>(null);\n const pane = useRef<SidePaneHandle>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // On unmount it stops the request.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const current = versions[0];\n const chosen = versions.find((v) => v.id === selectedId) ?? current;\n\n // While the request runs, Escape and Cancel do nothing.\n function keepCurrent() {\n if (restoring) return;\n setConfirming(false);\n }\n\n // The current plan stays as a version. The restore is a new version on top, marked Current.\n // The Modal gives focus back to 'Restore This Version', which stays: the chosen version is not the current one.\n function restore() {\n if (restoring) return;\n setRestoring(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setRestoring(false);\n setConfirming(false);\n setVersions((list) => [\n { ...chosen, id: `v${list.length + 1}`, title: `Restored the version from ${chosen.when}`, when: 'Nov 16, 2026, 2:55 PM', dateTime: '2026-11-16T14:55', by: 'Dana Lee', agent: false },\n ...list,\n ]);\n setRestored(chosen.when);\n }, 1200);\n }\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane ref={pane} title=\"History\" onClose={() => setOpen(false)}>\n <Stack gap=\"large\">\n {restored && (\n // An inline Alert is a polite status, so a screen reader hears it.\n <Alert variant=\"inline\" type=\"success\" autoDismiss={false} message={`Restored the version from ${restored}.`} />\n )}\n <Timeline\n id=\"activity-timeline-versions\"\n aria-label={`Versions of the plan for ${task}`}\n items={versions.map((v, i) => ({\n id: v.id,\n title: v.title,\n when: v.when,\n dateTime: v.dateTime,\n actor: { name: v.by, agent: v.agent },\n tag: i === 0 ? { label: 'Current' } : undefined,\n }))}\n selectedId={chosen.id}\n onSelect={setSelectedId}\n />\n <Line />\n {/* The chosen version, under the list. */}\n <Stack gap=\"medium\">\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">{chosen.title}</Heading>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Saved by {chosen.by}, {chosen.when}</Paragraph>\n </Stack>\n <List marker=\"number\" items={chosen.steps} />\n {chosen.id !== current.id && (\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Restore This Version\" onClickButton={() => setConfirming(true)} />\n </Cluster>\n )}\n </Stack>\n </Stack>\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n actions={\n <Tooltip title=\"History\">\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"History\"\n ariaLabel={`Show the history of ${task}`}\n aria-expanded={open}\n onClick={() => (open ? pane.current?.focus() : setOpen(true))}\n />\n </Tooltip>\n }\n />\n <Paragraph tone=\"secondary\" measure=\"none\">The plan for this task has {versions.length} saved versions.</Paragraph>\n </Stack>\n <Modal\n isOpen={confirming}\n size=\"small\"\n title=\"Restore Version\"\n onClose={keepCurrent}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={restoring ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={keepCurrent} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Restore\" loading={restoring} onClickButton={restore} />\n </>\n }\n >\n <Paragraph measure=\"none\">This makes the version from {chosen.when} the current plan, and everyone signs it off again. Your current plan is kept as a version.</Paragraph>\n </Modal>\n </AppShell>\n );\n}\n",
|
|
223
|
+
"uses": [
|
|
224
|
+
"Alert",
|
|
225
|
+
"AppShell",
|
|
226
|
+
"Button",
|
|
227
|
+
"Cluster",
|
|
228
|
+
"Heading",
|
|
229
|
+
"IconButton",
|
|
230
|
+
"Line",
|
|
231
|
+
"List",
|
|
232
|
+
"MenuItem",
|
|
233
|
+
"Modal",
|
|
234
|
+
"Navigation",
|
|
235
|
+
"Paragraph",
|
|
236
|
+
"SidePane",
|
|
237
|
+
"Stack",
|
|
238
|
+
"Timeline",
|
|
239
|
+
"TitleBar",
|
|
240
|
+
"Tooltip"
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
165
245
|
{
|
|
166
246
|
"id": "admin-inbox",
|
|
167
247
|
"title": "Admin inbox",
|
|
@@ -433,7 +513,8 @@
|
|
|
433
513
|
"Say on the card that the agent is redoing the changes once the request is sent, and remove its buttons.",
|
|
434
514
|
"Move focus to the field when 'Edit' or 'Request Changes' opens it, and back to that button after 'Discard', or after 'Save' in an edit.",
|
|
435
515
|
"Move focus to 'Stop' when the run's progress row appears.",
|
|
436
|
-
"Move focus to the message box when the card's buttons or 'Stop' go away and nothing takes their place."
|
|
516
|
+
"Move focus to the message box when the card's buttons or 'Stop' go away and nothing takes their place.",
|
|
517
|
+
"Use the case 'Plan sign-off' when several people must approve one plan, or the plan is a document beside the task."
|
|
437
518
|
],
|
|
438
519
|
"dont": [
|
|
439
520
|
"Do not carry out any step before the person approves.",
|
|
@@ -890,6 +971,92 @@
|
|
|
890
971
|
}
|
|
891
972
|
]
|
|
892
973
|
},
|
|
974
|
+
{
|
|
975
|
+
"id": "ask-page",
|
|
976
|
+
"title": "Ask page",
|
|
977
|
+
"kind": "design",
|
|
978
|
+
"level": "organism",
|
|
979
|
+
"area": "agent",
|
|
980
|
+
"situation": "A page where a person asks the agent about their work across one or more workspaces, and reads the answers with their sources.",
|
|
981
|
+
"do": [
|
|
982
|
+
"Follow the cases 'Conversation starters', 'Scope picker', 'Reply sources' and 'Message composer'.",
|
|
983
|
+
"Put the page in `AppShell`, with a `TitleBar` 'Ask' and the scope Button as its `actions`: 'All 3 Workspaces'.",
|
|
984
|
+
"Show the empty page as `EmptyBox size=\"large\"` with the text 'No questions yet' and a `secondText` that says what to do. Pass up to four starter `Tag`s as its `action`.",
|
|
985
|
+
"Write each starter as a whole question in plain words. A starter fills the `Composer` and focuses it, and the person sends it.",
|
|
986
|
+
"Say where the agent looks above the `Composer`: 'Acme Agent looks in the docs, chats and tasks of all 3 of your workspaces.' Change it with the scope.",
|
|
987
|
+
"Name the `Composer` for who reads it: 'Ask Acme Agent'.",
|
|
988
|
+
"Show the question as the person's `Message`, and the answer as the agent's, with its sources as cards under it, as the case 'Reply sources' says.",
|
|
989
|
+
"Offer 'Save to Docs' under an answer when the product keeps answers as docs. While it saves it is `loading`. Then a toast says 'Answer saved to Docs.', a link 'Open in Docs' takes its place, and focus goes to the link.",
|
|
990
|
+
"Keep the conversation when the person leaves the page, and show it again when they come back.",
|
|
991
|
+
"Show the agent's progress row where the answer will appear while it works, with a Stop Button, as the rule 'An agent shows its progress' says. Once the run has ended, Stop gives way to 'Stopped. Nothing was changed.' and focus goes back to the `Composer`.",
|
|
992
|
+
"Say so in one plain sentence when the agent found nothing in the scope. Name the scope and show no sources: 'I found nothing about this in the docs, chats and tasks of Acme Design.'",
|
|
993
|
+
"Say which limit stopped the agent, and who can change it or when to try again, as the rule 'An agent refuses clearly' says."
|
|
994
|
+
],
|
|
995
|
+
"dont": [
|
|
996
|
+
"Do not offer more than four starters.",
|
|
997
|
+
"Do not put a blank to fill in a starter, such as '[project]'. The person edits the question in the Composer.",
|
|
998
|
+
"Do not show an answer with no sources when the agent read something, as the rule 'An agent shows its sources' says.",
|
|
999
|
+
"Do not hide where the agent looks behind the scope menu alone. Say it in words."
|
|
1000
|
+
],
|
|
1001
|
+
"native": "On Apple use a `NavigationStack` with the scope as a toolbar `Menu`, the starters as buttons in a `ContentUnavailableView`, and a text field in a bottom bar. On Android use a `Scaffold` with a dropdown menu in the top bar and suggestion chips over the text field.",
|
|
1002
|
+
"options": [
|
|
1003
|
+
{
|
|
1004
|
+
"id": "first-visit",
|
|
1005
|
+
"title": "Nothing asked yet",
|
|
1006
|
+
"useWhen": "The person has not asked anything yet.",
|
|
1007
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Button from 'oneslash-design-system/components/button';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport Line from 'oneslash-design-system/components/line';\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 Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport Tag from 'oneslash-design-system/components/tag';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads these from the session.\nconst me = 'Dana Lee';\nconst agentName = 'Acme Agent';\nconst workspaces = ['Acme Design', 'Acme Engineering', 'Acme Marketing'];\nconst all = `All ${workspaces.length} Workspaces`;\n\n// Four things to ask at most, in plain words. Each one fills the Composer, where the person can change it.\nconst starters = [\n 'What changed in my workspaces this week?',\n 'What is still open on the launch?',\n 'Who is working on the pricing page?',\n 'What did we decide about the press kit?',\n];\n\ntype Row = { id: string; from: string; at: Date; text: string };\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n {[\n ['Home', 'House', '/'],\n ['Ask', 'MessageCircle', '/ask'],\n ['Docs', 'BookOpen', '/docs'],\n ].map(([label, icon, href]) => (\n <MenuItem\n key={href}\n size=\"small\"\n label={label}\n iconName={icon}\n href={href}\n isSelected={href === '/ask'}\n aria-current={href === '/ask' ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n ))}\n </Navigation>\n);\n\nexport default function AskPageFirstVisit() {\n const [navOpen, setNavOpen] = useState(false);\n // null means every workspace.\n const [scope, setScope] = useState<string | null>(null);\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const [thread, setThread] = useState<Row[]>([]);\n const [text, setText] = useState('');\n // Set when a starter fills the field; the effect below focuses it with the caret at the end.\n const [filled, setFilled] = useState(0);\n const field = useRef<HTMLTextAreaElement>(null);\n const label = scope ?? all;\n\n useEffect(() => {\n if (!filled || !field.current) return;\n const end = field.current.value.length;\n field.current.focus();\n field.current.setSelectionRange(end, end);\n }, [filled]);\n\n function choose(next: string | null) {\n setScope(next);\n setOpen(false);\n }\n\n // Fills the field and does not send: the person can change it first.\n function fillWith(starter: string) {\n setText(starter);\n setFilled((n) => n + 1);\n }\n\n function send() {\n // A real app sends the question to the agent here and shows it at once. The agent's progress row follows,\n // with Stop, then the answer with its sources. The 'answered' example shows both.\n setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date('2026-11-16T14:40:00Z'), text: text.trim() }]);\n setText('');\n }\n\n return (\n <AppShell title=\"Ask\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Stack gap=\"large\">\n <TitleBar\n title=\"Ask\"\n actions={\n // The label is the scope. The chevron says it opens a menu.\n <Button\n size=\"small\"\n type=\"tertiary\"\n state={open ? 'selected' : 'enabled'}\n label={label}\n actionIcon=\"ChevronDown\"\n aria-label={`${label}, change where ${agentName} looks`}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClickButton={(e: { currentTarget: HTMLElement }) => {\n setAnchor(e.currentTarget);\n setOpen((o) => !o);\n }}\n />\n }\n />\n {thread.length === 0 ? (\n <EmptyBox\n size=\"large\"\n icon=\"MessageCircle\"\n text=\"No questions yet\"\n secondText={`Ask ${agentName} anything about your work. It shows where each answer came from.`}\n action={\n <Cluster gap=\"small\">\n {starters.map((s) => (\n <Tag key={s} variant=\"contained\" size=\"small\" label={s} toggle={false} onClick={() => fillWith(s)} />\n ))}\n </Cluster>\n }\n />\n ) : (\n // A real app gives the list that holds the rows role=\"log\".\n <Stack gap=\"small\">\n {thread.map((m) => (\n <Message\n key={m.id}\n aria-label={m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ))}\n </Stack>\n )}\n <Stack gap=\"small\">\n {/* Where the agent looks, said above the box it is asked in. */}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">\n {scope ? `${agentName} looks in the docs, chats and tasks of ${scope}.` : `${agentName} looks in the docs, chats and tasks of all ${workspaces.length} of your workspaces.`}\n </Paragraph>\n <Composer\n ref={field}\n id=\"ask-page-first-visit-question\"\n aria-label={`Ask ${agentName}`}\n placeholder={`Ask ${agentName}`}\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Stack>\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label={`Where ${agentName} looks`} width={220}>\n <MenuItem size=\"small\" label={all} isSelected={scope === null} role=\"menuitemradio\" onClick={() => choose(null)} />\n <Line />\n {workspaces.map((w) => (\n <MenuItem key={w} size=\"small\" label={w} isSelected={scope === w} role=\"menuitemradio\" onClick={() => choose(w)} />\n ))}\n </Menu>\n </Popover>\n </AppShell>\n );\n}\n",
|
|
1008
|
+
"uses": [
|
|
1009
|
+
"AppShell",
|
|
1010
|
+
"Button",
|
|
1011
|
+
"Cluster",
|
|
1012
|
+
"Composer",
|
|
1013
|
+
"EmptyBox",
|
|
1014
|
+
"Line",
|
|
1015
|
+
"Menu",
|
|
1016
|
+
"MenuItem",
|
|
1017
|
+
"Message",
|
|
1018
|
+
"Navigation",
|
|
1019
|
+
"Paragraph",
|
|
1020
|
+
"Popover",
|
|
1021
|
+
"Stack",
|
|
1022
|
+
"Tag",
|
|
1023
|
+
"TimeStamp",
|
|
1024
|
+
"TitleBar",
|
|
1025
|
+
"UserImage"
|
|
1026
|
+
]
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
"id": "answered",
|
|
1030
|
+
"title": "Answered",
|
|
1031
|
+
"useWhen": "A question has its answer and sources, and the person can ask the next one.",
|
|
1032
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { BookOpen, Bot, ListChecks, MessageSquare, Plug } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Button from 'oneslash-design-system/components/button';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport Line from 'oneslash-design-system/components/line';\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 Tag from 'oneslash-design-system/components/tag';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport Composer from 'oneslash-design-system/components/composer';\nimport StepList from 'oneslash-design-system/components/stepList';\nimport { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads these from the session.\nconst me = 'Dana Lee';\nconst agentName = 'Acme Agent';\nconst workspaces = ['Acme Design', 'Acme Engineering', 'Acme Marketing'];\nconst all = `All ${workspaces.length} Workspaces`;\n\nconst question = { from: me, at: new Date('2026-11-16T14:40:00Z'), text: 'Who owns the press kit for the launch?' };\nconst answeredAt = new Date('2026-11-16T14:41:00Z');\nconst answer = 'Mia Park owns the press kit. Ben Carter handed it to her in #launch on Nov 12, 2026, and the launch plan lists her as its owner. It is due Nov 19, 2026.';\n\ntype Kind = 'chat' | 'docs' | 'tasks';\nconst kinds = {\n chat: { label: 'Chat', icon: MessageSquare },\n docs: { label: 'Docs', icon: BookOpen },\n tasks: { label: 'Tasks', icon: ListChecks },\n};\n\n// Each card links to the thing it read.\nconst sources: { kind: Kind; title: string; where: string; href: string }[] = [\n { kind: 'chat', title: 'Press kit hand-off', where: 'Acme Marketing · #launch · Nov 12', href: '/chat/launch/m-2210' },\n { kind: 'docs', title: 'Launch plan', where: 'Acme Marketing', href: '/docs/launch-plan' },\n { kind: 'tasks', title: 'Write the press kit', where: 'Acme Design · Due Nov 19', href: '/tasks/press-kit' },\n];\n\n// 'From Chat · Docs · Tasks': each kind once, in the order it first appears.\nconst kindsTag = `From ${sources.map((s) => kinds[s.kind].label).filter((l, i, list) => list.indexOf(l) === i).join(' · ')}`;\n\n// The next question and the agent's run on it. 'nothing' is the end of a run that found nothing in the scope.\ntype Phase = 'running' | 'stopping' | 'stopped' | 'nothing';\ntype Turn = { id: string; text: string; scope: string | null; phase: Phase; seconds: number };\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n {[\n ['Home', 'House', '/'],\n ['Ask', 'MessageCircle', '/ask'],\n ['Docs', 'BookOpen', '/docs'],\n ].map(([label, icon, href]) => (\n <MenuItem\n key={href}\n size=\"small\"\n label={label}\n iconName={icon}\n href={href}\n isSelected={href === '/ask'}\n aria-current={href === '/ask' ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n ))}\n </Navigation>\n);\n\nexport default function AskPageAnswered() {\n const [navOpen, setNavOpen] = useState(false);\n // null means every workspace.\n const [scope, setScope] = useState<string | null>(null);\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [open, setOpen] = useState(false);\n const [turns, setTurns] = useState<Turn[]>([]);\n const [text, setText] = useState('');\n const [saving, setSaving] = useState(false);\n const [saved, setSaved] = useState(false);\n const openButton = useRef<Focusable>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const run = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const field = useRef<HTMLTextAreaElement>(null);\n const toastIds = useRef<string[]>([]);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n const label = scope ?? all;\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearTimeout(run.current);\n clearInterval(tick.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 choose(next: string | null) {\n setScope(next);\n setOpen(false);\n }\n\n // The answer goes to Docs, away from this page, so a toast says where it went.\n // 'Save to Docs' gives way to a link to the new doc, and focus goes to it.\n function saveToDocs() {\n if (saving || saved) return;\n setSaving(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setSaving(false);\n setSaved(true);\n toastIds.current.push(toast({ type: 'success', message: 'Answer saved to Docs.' }));\n focusNext.current = () => openButton.current?.focus({ preventScroll: true });\n }, 1200);\n }\n\n const running = turns.some((t) => t.phase === 'running' || t.phase === 'stopping');\n\n // Changes the last turn, the one the agent is working on.\n function setLast(change: Partial<Turn>) {\n setTurns((list) => list.map((t, i) => (i === list.length - 1 ? { ...t, ...change } : t)));\n }\n\n function endRun() {\n clearTimeout(run.current);\n clearInterval(tick.current);\n }\n\n // The question shows at once, and the agent's progress row takes the place of its answer while it works.\n // This run finds nothing in the scope, so its answer says so in one plain sentence and shows no sources.\n function send() {\n if (running) return;\n setTurns((list) => [...list, { id: `t${list.length + 1}`, text: text.trim(), scope, phase: 'running', seconds: 0 }]);\n setText('');\n tick.current = setInterval(() => setTurns((list) => list.map((t, i) => (i === list.length - 1 ? { ...t, seconds: t.seconds + 1 } : t))), 1000);\n // Stands in for the agent's run.\n run.current = setTimeout(() => {\n endRun();\n setLast({ phase: 'nothing' });\n }, 3000);\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended,\n // then focus goes back to the question box, since Stop is gone.\n function stop() {\n clearTimeout(run.current);\n setLast({ phase: 'stopping' });\n run.current = setTimeout(() => {\n endRun();\n setLast({ phase: 'stopped' });\n focusNext.current = () => field.current?.focus({ preventScroll: true });\n }, 1200);\n }\n\n return (\n <AppShell title=\"Ask\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Stack gap=\"large\">\n <TitleBar\n title=\"Ask\"\n actions={\n // The label is the scope. The chevron says it opens a menu.\n <Button\n size=\"small\"\n type=\"tertiary\"\n state={open ? 'selected' : 'enabled'}\n label={label}\n actionIcon=\"ChevronDown\"\n aria-label={`${label}, change where ${agentName} looks`}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClickButton={(e: { currentTarget: HTMLElement }) => {\n setAnchor(e.currentTarget);\n setOpen((o) => !o);\n }}\n />\n }\n />\n {/* A real app keeps the conversation when the person leaves, and gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={question.from}\n avatar={<UserImage userHandle={question.from} decorative />}\n name={question.from}\n meta={<TimeStamp createdAt={question.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{question.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={answeredAt} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n }\n // The sources sit directly under the answer they support.\n footer={\n <Stack gap=\"medium\">\n <Cluster>\n <Tag variant=\"contained\" size=\"small\" color=\"success\" icon={Plug} label={kindsTag} />\n </Cluster>\n <Grid columns={2} gap=\"medium\">\n {sources.map((s) => (\n <SourceCard key={s.href} icon={kinds[s.kind].icon} title={s.title} meta={`${kinds[s.kind].label} · ${s.where}`} href={s.href} />\n ))}\n </Grid>\n <Cluster>\n {saved ? (\n <Button ref={openButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Open in Docs\" decoIcon=\"FileText\" href=\"/docs/press-kit-owner\" />\n ) : (\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Save to Docs\" decoIcon=\"BookmarkPlus\" loading={saving} onClickButton={saveToDocs} />\n )}\n </Cluster>\n </Stack>\n }\n >\n <Paragraph measure=\"none\">{answer}</Paragraph>\n </Message>\n {turns.map((t) => {\n const place = t.scope ?? `all ${workspaces.length} of your workspaces`;\n const working = t.phase === 'running' || t.phase === 'stopping';\n return (\n <Stack key={t.id} gap=\"small\">\n <Message\n aria-label={me}\n avatar={<UserImage userHandle={me} decorative />}\n name={me}\n meta={<TimeStamp createdAt={new Date('2026-11-16T14:45:00Z')} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{t.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={new Date('2026-11-16T14:45:00Z')} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n }\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n footer={working ? (\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={t.phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : undefined}\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\">{`Working for ${t.seconds} ${t.seconds === 1 ? 'second' : 'seconds'}`}</Paragraph>\n <StepList\n aria-label={`${agentName}'s steps`}\n steps={[\n { label: 'Read your question', status: 'done' },\n { label: `Looking in the docs, chats and tasks of ${place}`, status: 'running' },\n ]}\n />\n </Stack>\n ) : t.phase === 'stopped' ? (\n <Paragraph measure=\"none\">Stopped. Nothing was changed.</Paragraph>\n ) : (\n // It read nothing it could use, so the answer has no sources section.\n <Paragraph measure=\"none\">{`I found nothing about this in the docs, chats and tasks of ${place}. Try other words, or change where I look.`}</Paragraph>\n )}\n </Message>\n </Stack>\n );\n })}\n </Stack>\n <Stack gap=\"small\">\n {/* Where the agent looks, said above the box it is asked in. */}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">\n {scope ? `${agentName} looks in the docs, chats and tasks of ${scope}.` : `${agentName} looks in the docs, chats and tasks of all ${workspaces.length} of your workspaces.`}\n </Paragraph>\n <Composer\n ref={field}\n id=\"ask-page-answered-question\"\n aria-label={`Ask ${agentName}`}\n placeholder={`Ask ${agentName}`}\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Stack>\n <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>\n <Menu navigable aria-label={`Where ${agentName} looks`} width={220}>\n <MenuItem size=\"small\" label={all} isSelected={scope === null} role=\"menuitemradio\" onClick={() => choose(null)} />\n <Line />\n {workspaces.map((w) => (\n <MenuItem key={w} size=\"small\" label={w} isSelected={scope === w} role=\"menuitemradio\" onClick={() => choose(w)} />\n ))}\n </Menu>\n </Popover>\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n </AppShell>\n );\n}\n",
|
|
1033
|
+
"uses": [
|
|
1034
|
+
"AppShell",
|
|
1035
|
+
"Button",
|
|
1036
|
+
"Cluster",
|
|
1037
|
+
"Composer",
|
|
1038
|
+
"Grid",
|
|
1039
|
+
"Line",
|
|
1040
|
+
"Menu",
|
|
1041
|
+
"MenuItem",
|
|
1042
|
+
"Message",
|
|
1043
|
+
"Navigation",
|
|
1044
|
+
"Paragraph",
|
|
1045
|
+
"Popover",
|
|
1046
|
+
"SourceCard",
|
|
1047
|
+
"Stack",
|
|
1048
|
+
"StepList",
|
|
1049
|
+
"Tag",
|
|
1050
|
+
"TimeStamp",
|
|
1051
|
+
"TitleBar",
|
|
1052
|
+
"Toaster",
|
|
1053
|
+
"UserImage",
|
|
1054
|
+
"dismissToast",
|
|
1055
|
+
"toast"
|
|
1056
|
+
]
|
|
1057
|
+
}
|
|
1058
|
+
]
|
|
1059
|
+
},
|
|
893
1060
|
{
|
|
894
1061
|
"id": "auth-gate-loading",
|
|
895
1062
|
"title": "Login check loading",
|
|
@@ -1250,6 +1417,69 @@
|
|
|
1250
1417
|
}
|
|
1251
1418
|
]
|
|
1252
1419
|
},
|
|
1420
|
+
{
|
|
1421
|
+
"id": "chart",
|
|
1422
|
+
"title": "Chart",
|
|
1423
|
+
"kind": "design",
|
|
1424
|
+
"level": "organism",
|
|
1425
|
+
"area": "dashboard",
|
|
1426
|
+
"situation": "A dashboard shows how a count moved over its range, day by day or week by week.",
|
|
1427
|
+
"do": [
|
|
1428
|
+
"Follow the rule 'A number shows its unit and never shows 0 for unknown'. The axis shows a number from 10,000 up in its short form, and the readout and the table show it exact.",
|
|
1429
|
+
"Put the chart in a `SettingsSection` under the stat row, and count it over the dashboard's one range, as the case 'Range switch' says. Name the range in the section's title: 'Comments this week'.",
|
|
1430
|
+
"Use `BarChart` for one count per day or week, and `LineChart` for one or two trends.",
|
|
1431
|
+
"Write the `summary` as one sentence that says what changed, from the same data: 'Comments rose from 40 on Nov 10 to 72 on Nov 16.'",
|
|
1432
|
+
"Pass the `unit` the chart counts, such as 'comments', so the readout says '58 comments'.",
|
|
1433
|
+
"Count by week when the range is long, and pass `labelHeader` 'Week of' for the table.",
|
|
1434
|
+
"Keep one unit per chart. Two series share it, such as 'opened' and 'done' threads.",
|
|
1435
|
+
"Pass `loading` while the range changes, so the plot holds its place. Pass `null` for a day with no data: it draws nothing and reads 'No data'.",
|
|
1436
|
+
"Keep 'Show Table' under every chart, so the exact values are one press away.",
|
|
1437
|
+
"Pass `emptyText` in the person's words when the range has no data at all, such as 'No comments this week'. Keep the section.",
|
|
1438
|
+
"Show a chart that could not load as the case 'Load failure' says: an inline error `Alert` 'Could not load comments' with 'Try Again' in its place. Keep the rest of the dashboard.",
|
|
1439
|
+
"Write the summary from the days with data. Leave out a day with no data, and never read it as 0."
|
|
1440
|
+
],
|
|
1441
|
+
"dont": [
|
|
1442
|
+
"Do not draw a pie, a donut, or a stacked or grouped bar. Show a split as the case 'Breakdown of a total' says.",
|
|
1443
|
+
"Do not put two units or two y scales in one chart.",
|
|
1444
|
+
"Do not add a third series. Split it into a second chart.",
|
|
1445
|
+
"Do not print a value on every bar. The readout and the table give each one.",
|
|
1446
|
+
"Do not use color to mean good or bad. More is not good or bad by itself.",
|
|
1447
|
+
"Do not draw a chart for one number. Use a `StatTile`, as the case 'Stat row' says."
|
|
1448
|
+
],
|
|
1449
|
+
"native": "On Apple use Swift Charts: `BarMark` or `LineMark`, a dashed `lineStyle` for the second series, an `accessibilityLabel` and `accessibilityValue` per mark, and an audio graph through `AXChartDescriptor`. On Android, which has no system chart, draw on a `Canvas` with `semantics` per point, or show the table.",
|
|
1450
|
+
"options": [
|
|
1451
|
+
{
|
|
1452
|
+
"id": "bars",
|
|
1453
|
+
"title": "Bars",
|
|
1454
|
+
"useWhen": "One count per day or week over the range, such as comments per day.",
|
|
1455
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport BarChart from 'oneslash-design-system/components/barChart';\nimport { formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Range = 'week' | 'month' | 'quarter';\ntype Point = { label: string; value: number | null };\n\nconst ranges = [\n { value: 'week', label: 'Week' },\n { value: 'month', label: 'Month' },\n { value: 'quarter', label: 'Quarter' },\n];\n\nconst months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n// 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.\nfunction day(back: number) {\n const d = new Date(Date.UTC(2026, 10, 16 - back));\n return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;\n}\n\n// A real app counts these on the server. The last seven days are the week.\nconst week = [40, 46, 38, 52, 58, 61, 72];\nconst month = [...Array.from({ length: 23 }, (_, i) => 28 + Math.round(i * 0.8) + ((i * 7) % 5) * 3), ...week];\n// The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.\nconst quarter = [236, 251, 228, 262, 270, 249, 281, 290, 276, 302, 311, 334, 367];\n\nconst data: Record<Range, Point[]> = {\n week: week.map((value, i) => ({ label: day(6 - i), value })),\n month: month.map((value, i) => ({ label: day(29 - i), value })),\n quarter: quarter.map((value, i) => ({ label: day(6 + (12 - i) * 7), value })),\n};\n\nconst noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };\n\n// The summary says what changed, written from the same data the chart draws. A day with no data (null)\n// is left out, never read as 0: the summary runs from the first day with data to the last.\nfunction summary(points: Point[], range: Range) {\n const known = points.filter((p): p is { label: string; value: number } => p.value !== null);\n if (known.length === 0) return `No comments were counted ${noun[range]}.`;\n const first = known[0];\n const last = known[known.length - 1];\n const when = (p: Point) => (range === 'quarter' ? `in the week of ${p.label}` : `on ${p.label}`);\n if (known.length === 1) return `Comments were counted only ${when(first)}: ${formatCount(first.value)}.`;\n const move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';\n return move === 'stayed'\n ? `Comments stayed at ${formatCount(first.value)} from ${first.label} to ${last.label}.`\n : `Comments ${move} from ${formatCount(first.value)} ${when(first)} to ${formatCount(last.value)} ${when(last)}.`;\n}\n\nexport default function ChartBars() {\n const [range, setRange] = useState<Range>('week');\n // The numbers load again when the range changes.\n const [loading, setLoading] = 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 function changeRange(next: string) {\n clearTimeout(timer.current);\n setRange(next as Range);\n setLoading(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => setLoading(false), 600);\n }\n\n const points = data[range];\n // The total adds the days with data, and says so when a day has none.\n const total = points.reduce((sum, p) => sum + (p.value ?? 0), 0);\n const gap = points.some((p) => p.value === null);\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n {/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}\n <TitleBar\n title=\"Dashboard\"\n actionsBelow\n actions={<SegmentedControl size=\"small\" width=\"fit\" aria-label=\"Range\" options={ranges} value={range} onChange={changeRange} />}\n />\n <SettingsSection\n title={`Comments ${noun[range]}`}\n description={`${formatCount(total)} comments ${gap ? 'on the days with data ' : ''}from ${points[0].label} to Nov 16, 2026`}\n id=\"chart-bars-comments\"\n >\n <BarChart\n id=\"chart-bars-per-day\"\n title={range === 'quarter' ? 'Comments per week' : 'Comments per day'}\n summary={summary(points, range)}\n data={points}\n unit=\"comments\"\n labelHeader={range === 'quarter' ? 'Week of' : 'Date'}\n loading={loading}\n emptyText={`No comments ${noun[range]}`}\n />\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
1456
|
+
"uses": [
|
|
1457
|
+
"BarChart",
|
|
1458
|
+
"Center",
|
|
1459
|
+
"SegmentedControl",
|
|
1460
|
+
"SettingsSection",
|
|
1461
|
+
"Stack",
|
|
1462
|
+
"TitleBar",
|
|
1463
|
+
"formatCount"
|
|
1464
|
+
]
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
"id": "lines",
|
|
1468
|
+
"title": "Lines",
|
|
1469
|
+
"useWhen": "A trend over the range, one or two series in the same unit, such as threads opened and done.",
|
|
1470
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport LineChart from 'oneslash-design-system/components/lineChart';\nimport { formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Range = 'week' | 'month' | 'quarter';\ntype Counts = { labels: string[]; opened: number[]; done: number[] };\n\nconst ranges = [\n { value: 'week', label: 'Week' },\n { value: 'month', label: 'Month' },\n { value: 'quarter', label: 'Quarter' },\n];\n\nconst months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n// 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.\nfunction day(back: number) {\n const d = new Date(Date.UTC(2026, 10, 16 - back));\n return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;\n}\n\n// A real app counts these on the server. Both lines count threads, so they share one unit and one scale.\nconst openedMonth = Array.from({ length: 30 }, (_, i) => 18 + Math.round(i * 0.9) + ((i * 5) % 7));\nconst doneMonth = Array.from({ length: 30 }, (_, i) => 12 + Math.round(i * 0.8) + ((i * 3) % 5));\n\nconst data: Record<Range, Counts> = {\n week: { labels: Array.from({ length: 7 }, (_, i) => day(6 - i)), opened: openedMonth.slice(23), done: doneMonth.slice(23) },\n month: { labels: Array.from({ length: 30 }, (_, i) => day(29 - i)), opened: openedMonth, done: doneMonth },\n // The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.\n quarter: {\n labels: Array.from({ length: 13 }, (_, i) => day(6 + (12 - i) * 7)),\n opened: [150, 162, 158, 171, 166, 180, 177, 189, 196, 204, 199, 221, 238],\n done: [131, 140, 149, 152, 160, 158, 169, 171, 180, 186, 192, 201, 214],\n },\n};\n\nconst noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };\n\n// The summary says what changed, written from the same data the chart draws.\nfunction summary({ labels, opened, done }: Counts, range: Range) {\n const when = (i: number) => (range === 'quarter' ? `in the week of ${labels[i]}` : `on ${labels[i]}`);\n const last = labels.length - 1;\n const move = (list: number[]) => (list[last] > list[0] ? 'rose' : list[last] < list[0] ? 'fell' : 'stayed');\n return `Threads opened ${move(opened)} from ${formatCount(opened[0])} ${when(0)} to ${formatCount(opened[last])} ${when(last)}, and threads done ${move(done)} from ${formatCount(done[0])} to ${formatCount(done[last])}.`;\n}\n\nexport default function ChartLines() {\n // A trend needs more than a few points, so this chart opens on the month.\n const [range, setRange] = useState<Range>('month');\n // The numbers load again when the range changes.\n const [loading, setLoading] = 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 function changeRange(next: string) {\n clearTimeout(timer.current);\n setRange(next as Range);\n setLoading(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => setLoading(false), 600);\n }\n\n const counts = data[range];\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n {/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}\n <TitleBar\n title=\"Dashboard\"\n actionsBelow\n actions={<SegmentedControl size=\"small\" width=\"fit\" aria-label=\"Range\" options={ranges} value={range} onChange={changeRange} />}\n />\n <SettingsSection\n title={`Threads ${noun[range]}`}\n description={`Opened and marked done, ${range === 'quarter' ? 'per week' : 'per day'}, from ${counts.labels[0]} to Nov 16, 2026`}\n id=\"chart-lines-threads\"\n >\n {/* Two series in one unit. A third would go in a chart of its own. */}\n <LineChart\n id=\"chart-lines-opened-done\"\n title={`Opened and done ${noun[range]}`}\n summary={summary(counts, range)}\n labels={counts.labels}\n series={[\n { name: 'opened', values: counts.opened },\n { name: 'done', values: counts.done },\n ]}\n unit=\"threads\"\n labelHeader={range === 'quarter' ? 'Week of' : 'Date'}\n loading={loading}\n emptyText={`No threads opened or done ${noun[range]}`}\n />\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
1471
|
+
"uses": [
|
|
1472
|
+
"Center",
|
|
1473
|
+
"LineChart",
|
|
1474
|
+
"SegmentedControl",
|
|
1475
|
+
"SettingsSection",
|
|
1476
|
+
"Stack",
|
|
1477
|
+
"TitleBar",
|
|
1478
|
+
"formatCount"
|
|
1479
|
+
]
|
|
1480
|
+
}
|
|
1481
|
+
]
|
|
1482
|
+
},
|
|
1253
1483
|
{
|
|
1254
1484
|
"id": "check-your-email",
|
|
1255
1485
|
"title": "Check your email",
|
|
@@ -1410,6 +1640,82 @@
|
|
|
1410
1640
|
}
|
|
1411
1641
|
]
|
|
1412
1642
|
},
|
|
1643
|
+
{
|
|
1644
|
+
"id": "comment-thread",
|
|
1645
|
+
"title": "Comment and thread",
|
|
1646
|
+
"kind": "design",
|
|
1647
|
+
"level": "organism",
|
|
1648
|
+
"area": "chat",
|
|
1649
|
+
"situation": "A person reads comments left on a piece of work, opens one, and reads and answers its thread.",
|
|
1650
|
+
"do": [
|
|
1651
|
+
"Follow the cases 'Message row' and 'Message composer'.",
|
|
1652
|
+
"Show each comment as a `Message`: the face, the name, then the time and any state in `meta`, such as a text `Tag` 'Done'.",
|
|
1653
|
+
"Write a card's date and time in full, such as 'Nov 16, 2026, 2:40 PM', since a list of cards spans days.",
|
|
1654
|
+
"Say where the comment is, in a secondary line under the text: 'Homepage design, frame Hero'.",
|
|
1655
|
+
"Cut a long comment to about three lines in the text you pass, and show it in full in the thread.",
|
|
1656
|
+
"Open the thread from a link in the card, named for whose it is: 'Open thread from Ben Carter'. Say how many replies it has beside it.",
|
|
1657
|
+
"Put the card's actions in a More menu, as the case 'Message actions' says: `<Popover returnFocus>` around `<Menu navigable aria-label=\"Comment actions\">`. The More button is in the tab order, so a keyboard always reaches it.",
|
|
1658
|
+
"Mark an unread comment with a dot `Tag` 'Unread' in `info`, as the case 'Admin inbox' does, and say it in the row's `aria-label`: 'Unread comment from Ben Carter'.",
|
|
1659
|
+
"Title the open thread with `TitleBar level={2}` 'Thread' under the page's level 1 heading. On a phone, where it takes the screen, pass `back` 'Back to Comments'.",
|
|
1660
|
+
"Give the thread a secondary 'Mark Done'. Once done it reads 'Reopen', and a text `Tag` 'Done' shows in the `meta` line.",
|
|
1661
|
+
"Announce the change politely: the app says 'Marked done.' or 'Reopened.' in a polite live region, since a screen reader may not read a Button's new name while it has focus. Do the same when the change comes from the card's menu. Show no toast, since the change is in view.",
|
|
1662
|
+
"Show the first comment in full, then the replies in order. Make a reply `compact` when the reply above is from the same person, as the case 'Message row' says.",
|
|
1663
|
+
"Put a `Composer` under the replies, named for who reads it: 'Reply to Ben Carter'. Add the reply to the thread at once and empty the box."
|
|
1664
|
+
],
|
|
1665
|
+
"dont": [
|
|
1666
|
+
"Do not show the actions on pointer hover only. A keyboard and a touch screen must reach them too.",
|
|
1667
|
+
"Do not make the whole card one clickable box. Its link opens the thread, and its buttons stay their own.",
|
|
1668
|
+
"Do not mark unread with bold text alone. Show the word.",
|
|
1669
|
+
"Do not leave out where the comment is. A comment about a frame means little without it.",
|
|
1670
|
+
"Do not group replies from two people into one row."
|
|
1671
|
+
],
|
|
1672
|
+
"native": "On Apple show the comments in a `List` with a `NavigationLink` per comment, its actions in a `contextMenu` and `swipeActions`, and the thread as a pushed view with a text field in a bottom bar. On Android use a `LazyColumn` of cards that each have a clickable title, a dropdown menu for the actions, and a thread screen.",
|
|
1673
|
+
"options": [
|
|
1674
|
+
{
|
|
1675
|
+
"id": "card",
|
|
1676
|
+
"title": "Comment cards",
|
|
1677
|
+
"useWhen": "Comments show in a list or a feed, and each one opens its thread.",
|
|
1678
|
+
"source": "'use client';\nimport { useState } from '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 Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\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 Alert from 'oneslash-design-system/components/alert';\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\ntype Comment = {\n id: string;\n from: string;\n when: string;\n text: string;\n place: string;\n replies: number;\n unread?: boolean;\n done?: boolean;\n saved?: boolean;\n reacted?: boolean;\n};\n\nconst firstComments: Comment[] = [\n {\n id: 'c1',\n from: 'Ben Carter',\n when: 'Nov 16, 2026, 2:40 PM',\n text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',\n place: 'Homepage design, frame Hero',\n replies: 2,\n unread: true,\n },\n {\n id: 'c2',\n from: 'Omar Reyes',\n when: 'Nov 16, 2026, 11:15 AM',\n text: 'The Team plan should read $25 per seat, not $25.',\n place: 'Homepage design, frame Pricing',\n replies: 1,\n done: true,\n },\n {\n id: 'c3',\n from: 'Mia Park',\n when: 'Nov 15, 2026, 4:30 PM',\n text: 'The footer links need more room between them on a phone.',\n place: 'Homepage design, frame Footer',\n replies: 0,\n },\n];\n\n// The card shows about three lines. The caller cuts the text at a word, and the thread shows it in full.\nfunction excerpt(text: string, max = 160) {\n if (text.length <= max) return text;\n return `${text.slice(0, text.lastIndexOf(' ', max))}…`;\n}\n\nfunction repliesLine(n: number) {\n if (n === 0) return 'No replies yet';\n return `${n} ${n === 1 ? 'reply' : 'replies'}`;\n}\n\nexport default function CommentThreadCard() {\n const [comments, setComments] = useState(firstComments);\n // The comment whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuId, setMenuId] = useState<string | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // What the polite line says after Mark Done or Reopen. The count gives each change a fresh line, so it is read again.\n const [said, setSaid] = useState<{ text: string; n: number } | null>(null);\n\n const menuComment = comments.find((c) => c.id === menuId);\n\n function openMenu(c: Comment, anchor: HTMLElement) {\n if (menuOpen && menuId === c.id) {\n setMenuOpen(false);\n return;\n }\n setMenuId(c.id);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Every item closes the menu, and the Popover gives focus back to More. The change shows on the card.\n function choose(change: (c: Comment) => Partial<Comment>) {\n const id = menuId;\n setMenuOpen(false);\n // A real app sends the change to the server here.\n setComments((list) => list.map((c) => (c.id === id ? { ...c, ...change(c) } : c)));\n }\n\n // Focus goes back to More, whose name does not change, so the polite line says what happened.\n function toggleDone() {\n const wasDone = !!menuComment?.done;\n choose((c) => ({ done: !c.done }));\n setSaid((s) => ({ text: wasDone ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Comments</Heading>\n {said && (\n // An inline Alert is a polite status. It leaves after 5 seconds; the card's Tag still shows the state.\n <Alert key={said.n} variant=\"inline\" type=\"success\" message={said.text} onClose={() => setSaid(null)} />\n )}\n {/* A real app gives the list that holds the cards role=\"feed\". */}\n <Stack gap=\"medium\">\n {comments.map((c) => (\n <Message\n key={c.id}\n aria-label={c.unread ? `Unread comment from ${c.from}` : `Comment from ${c.from}`}\n avatar={<UserImage userHandle={c.from} decorative />}\n name={c.from}\n meta={\n <>\n {/* Cards span days, so each says its date and time in full, written by the app. */}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{c.when}</Paragraph>\n {c.unread && <Tag variant=\"dot\" size=\"small\" color=\"info\" label=\"Unread\" />}\n {c.done && <Tag variant=\"textOnly\" size=\"small\" label=\"Done\" />}\n {c.saved && <Tag variant=\"textOnly\" size=\"small\" label=\"Saved\" />}\n </>\n }\n footer={\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{c.place}</Paragraph>\n {c.reacted && (\n <Cluster>\n <Tag variant=\"contained\" size=\"small\" state=\"selected\" label=\"👍 1\" aria-label=\"Thumbs up, 1 reaction\" />\n </Cluster>\n )}\n {/* The link opens the thread. The card itself is not a button. */}\n <Cluster gap=\"small\">\n <Link href={`/comments/${c.id}`} size=\"body2\">Open thread from {c.from}</Link>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{repliesLine(c.replies)}</Paragraph>\n </Cluster>\n </Stack>\n }\n // One More button, in the tab order. It stays on screen while its menu is open.\n actionsVisible={menuOpen && menuId === c.id}\n actions={\n <Tooltip title=\"More\">\n <IconButton\n color=\"iconOnly\"\n state={menuOpen && menuId === c.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for comment from ${c.from}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuId === c.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(c, e.currentTarget)}\n />\n </Tooltip>\n }\n >\n <Paragraph measure=\"none\">{excerpt(c.text)}</Paragraph>\n </Message>\n ))}\n </Stack>\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={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label=\"Comment actions\" width={200}>\n <MenuItem size=\"small\" iconName=\"SmilePlus\" label={menuComment?.reacted ? 'Remove Reaction' : 'Add Reaction'} onClick={() => choose((c) => ({ reacted: !c.reacted }))} />\n <MenuItem size=\"small\" iconName=\"Bookmark\" label={menuComment?.saved ? 'Remove from Saved' : 'Save'} onClick={() => choose((c) => ({ saved: !c.saved }))} />\n <MenuItem size=\"small\" iconName=\"Check\" label={menuComment?.done ? 'Reopen' : 'Mark Done'} onClick={toggleDone} />\n {menuComment?.unread && <MenuItem size=\"small\" iconName=\"MailOpen\" label=\"Mark as Read\" onClick={() => choose(() => ({ unread: false }))} />}\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
|
|
1679
|
+
"uses": [
|
|
1680
|
+
"Alert",
|
|
1681
|
+
"Center",
|
|
1682
|
+
"Cluster",
|
|
1683
|
+
"Heading",
|
|
1684
|
+
"IconButton",
|
|
1685
|
+
"Link",
|
|
1686
|
+
"Menu",
|
|
1687
|
+
"MenuItem",
|
|
1688
|
+
"Message",
|
|
1689
|
+
"Paragraph",
|
|
1690
|
+
"Popover",
|
|
1691
|
+
"Stack",
|
|
1692
|
+
"Tag",
|
|
1693
|
+
"Tooltip",
|
|
1694
|
+
"UserImage"
|
|
1695
|
+
]
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
"id": "thread",
|
|
1699
|
+
"title": "Open thread",
|
|
1700
|
+
"useWhen": "One thread is open, with its replies and a reply box.",
|
|
1701
|
+
"source": "'use client';\nimport { useState } from '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 TitleBar from 'oneslash-design-system/components/titleBar';\nimport Button from 'oneslash-design-system/components/button';\nimport Composer from 'oneslash-design-system/components/composer';\nimport Alert from 'oneslash-design-system/components/alert';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Reply = { id: string; from: string; at: Date; text: string };\n\nconst comment = {\n from: 'Ben Carter',\n at: new Date('2026-11-16T14:40:00Z'),\n text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',\n place: 'Homepage design, frame Hero',\n};\n\nconst firstReplies: Reply[] = [\n { id: 'r1', from: 'Omar Reyes', at: new Date('2026-11-16T14:52:00Z'), text: 'I can cut it to \"Plan your launch in one place.\" That fits on one line on a phone.' },\n { id: 'r2', from: 'Ben Carter', at: new Date('2026-11-16T15:01:00Z'), text: 'That works for me.' },\n { id: 'r3', from: 'Ben Carter', at: new Date('2026-11-16T15:02:00Z'), text: 'Keep the type size as it is, then.' },\n];\n\n// A reply is compact when the one above is from the same person, on the same day and less than 5 minutes older.\nfunction isFollowOn(list: Reply[], i: number) {\n const above = list[i - 1];\n if (!above || above.from !== list[i].from) return false;\n const sameDay = above.at.toDateString() === list[i].at.toDateString();\n return sameDay && list[i].at.getTime() - above.at.getTime() < 5 * 60 * 1000;\n}\n\nexport default function CommentThreadThread() {\n const [replies, setReplies] = useState(firstReplies);\n const [text, setText] = useState('');\n const [done, setDone] = useState(false);\n // What the polite line says after the last press. The count gives each press a fresh line, so it is read again.\n const [said, setSaid] = useState<{ text: string; n: number } | null>(null);\n\n // A real app sends the change to the server here. The Button keeps focus as its label changes,\n // and a screen reader may not read that new name, so the polite line says it.\n function toggleDone() {\n setDone(!done);\n setSaid((s) => ({ text: done ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));\n }\n\n function send() {\n // A real app sends the reply to the server here and shows it at once.\n setReplies((list) => [...list, { id: `r${list.length + 1}`, from: me, at: new Date('2026-11-16T15:10:00Z'), text: text.trim() }]);\n setText('');\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Comments</Heading>\n {/* On a phone the thread takes the screen, so Back goes to the list. From md a real app shows the list beside it and leaves Back out. */}\n <TitleBar\n level={2}\n title=\"Thread\"\n back={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" decoIcon=\"ChevronLeft\" label=\"Back to Comments\" />}\n meta={\n <>\n {comment.place}\n {done && <Tag variant=\"textOnly\" size=\"small\" label=\"Done\" />}\n </>\n }\n actions={\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label={done ? 'Reopen' : 'Mark Done'} onClickButton={toggleDone} />\n }\n />\n {said && (\n // An inline Alert is a polite status. It leaves after 5 seconds; the Tag and the Button still show the state.\n <Alert key={said.n} variant=\"inline\" type=\"success\" message={said.text} onClose={() => setSaid(null)} />\n )}\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={comment.from}\n avatar={<UserImage userHandle={comment.from} decorative />}\n name={comment.from}\n meta={<TimeStamp createdAt={comment.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{comment.text}</Paragraph>\n </Message>\n {replies.map((r, i) => {\n const compact = isFollowOn(replies, i);\n return (\n <Message\n key={r.id}\n compact={compact}\n aria-label={r.from}\n avatar={compact ? undefined : <UserImage userHandle={r.from} decorative />}\n name={compact ? undefined : r.from}\n meta={compact ? undefined : <TimeStamp createdAt={r.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{r.text}</Paragraph>\n </Message>\n );\n })}\n </Stack>\n <Composer\n id=\"comment-thread-reply\"\n aria-label={`Reply to ${comment.from}`}\n placeholder={`Reply to ${comment.from}`}\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Center>\n );\n}\n",
|
|
1702
|
+
"uses": [
|
|
1703
|
+
"Alert",
|
|
1704
|
+
"Button",
|
|
1705
|
+
"Center",
|
|
1706
|
+
"Composer",
|
|
1707
|
+
"Heading",
|
|
1708
|
+
"Message",
|
|
1709
|
+
"Paragraph",
|
|
1710
|
+
"Stack",
|
|
1711
|
+
"Tag",
|
|
1712
|
+
"TimeStamp",
|
|
1713
|
+
"TitleBar",
|
|
1714
|
+
"UserImage"
|
|
1715
|
+
]
|
|
1716
|
+
}
|
|
1717
|
+
]
|
|
1718
|
+
},
|
|
1413
1719
|
{
|
|
1414
1720
|
"id": "composer-limit",
|
|
1415
1721
|
"title": "Composer at a limit",
|
|
@@ -1838,6 +2144,7 @@
|
|
|
1838
2144
|
"Put the page in `AppShell`, with a `TitleBar` named 'Dashboard' and a 'Range' `SegmentedControl` as its `actions`, as the case 'Range switch' says. Set `actionsBelow` so the switch takes its own line under the title on a phone.",
|
|
1839
2145
|
"Let the one range drive every number on the page, and name it in every heading and caption: 'this week'.",
|
|
1840
2146
|
"Show the stat row as the case 'Stat row' says, and a share of a total as the case 'Breakdown of a total' says.",
|
|
2147
|
+
"Show a trend over the range as the case 'Chart' says, under the stat row, over the same range.",
|
|
1841
2148
|
"Make each section a `SettingsSection`: a hairline, a title and its content. Do not put a section in a box.",
|
|
1842
2149
|
"Put the list of what waits on the person in a section titled with its count and unit: '3 comments waiting on you'. Make each row a link.",
|
|
1843
2150
|
"Show a list that can be longer than its section as the case 'Short list on a dashboard' says.",
|
|
@@ -1846,23 +2153,24 @@
|
|
|
1846
2153
|
"Show a `Skeleton` or the tile's own loading state while the range changes. Do not show 0."
|
|
1847
2154
|
],
|
|
1848
2155
|
"dont": [
|
|
1849
|
-
"Do not draw a chart
|
|
2156
|
+
"Do not draw a chart for one number or for a share. A trend over the range follows the case 'Chart'.",
|
|
1850
2157
|
"Do not count different sections over different ranges.",
|
|
1851
2158
|
"Do not replace the whole page when one section failed.",
|
|
1852
2159
|
"Do not put more than four tiles in the stat row.",
|
|
1853
2160
|
"Do not hide a section that has nothing, or leave it blank.",
|
|
1854
2161
|
"Do not box the sections in cards."
|
|
1855
2162
|
],
|
|
1856
|
-
"native": "On Apple use a `List` of `Section`s in a `NavigationStack`, with a `Picker` in the `.segmented` style in the toolbar. On Android use a `LazyColumn` with a `SingleChoiceSegmentedButtonRow` in the top bar.",
|
|
2163
|
+
"native": "On Apple use a `List` of `Section`s in a `NavigationStack`, with a `Picker` in the `.segmented` style in the toolbar. On Android use a `LazyColumn` with a `SingleChoiceSegmentedButtonRow` in the top bar. Draw a trend over the range with Swift Charts as the case 'Chart' says; on Android draw it on a `Canvas` or show the table.",
|
|
1857
2164
|
"options": [
|
|
1858
2165
|
{
|
|
1859
2166
|
"id": "numbers-first",
|
|
1860
2167
|
"title": "Numbers first",
|
|
1861
2168
|
"useWhen": "The page reports how things went, for a lead who checks on a team.",
|
|
1862
|
-
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport StatTile from 'oneslash-design-system/components/statTile';\nimport Progress from 'oneslash-design-system/components/progress';\nimport Skeleton from 'oneslash-design-system/components/skeleton';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport List from 'oneslash-design-system/components/list';\nimport { formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\ntype Range = 'week' | 'month' | 'quarter';\nconst ranges = [\n { value: 'week', label: 'Week' },\n { value: 'month', label: 'Month' },\n { value: 'quarter', label: 'Quarter' },\n];\n\n// A real app counts these on the server. One range drives every number on the page.\nconst data = {\n week: {\n stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },\n projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ],\n questions: [],\n },\n month: {\n stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },\n projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ['Confirm the release date', '/comments/4'],\n ['Approve the new onboarding text', '/comments/5'],\n ],\n questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],\n },\n quarter: {\n stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },\n projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ['Confirm the release date', '/comments/4'],\n ],\n questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],\n },\n} as const;\n\nconst noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };\n\nexport default function DashboardNumbersFirst() {\n const [range, setRange] = useState<Range>('week');\n // The numbers load again when the range changes.\n const [loading, setLoading] = useState(false);\n // The projects section fails first, so the rest of the page shows that one section can fail alone.\n const [projectsFailed, setProjectsFailed] = useState(true);\n const [retrying, setRetrying] = useState(false);\n const [navOpen, setNavOpen] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const retryTimer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the requests if the example goes away before they end.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearTimeout(retryTimer.current);\n }, []);\n\n function changeRange(next: string) {\n clearTimeout(timer.current);\n setRange(next as Range);\n setLoading(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => setLoading(false), 600);\n }\n\n function tryAgain() {\n if (retrying) return;\n setRetrying(true);\n retryTimer.current = setTimeout(() => {\n setRetrying(false);\n setProjectsFailed(false);\n }, 1200);\n }\n\n const d = data[range];\n const period = range;\n const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);\n const waitingCount: number = d.waiting.length;\n\n const sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {[\n ['Dashboard', 'LayoutDashboard', '/dashboard'],\n ['Comments', 'MessageSquare', '/comments'],\n ['Projects', 'FolderKanban', '/projects'],\n ].map(([label, icon, href]) => (\n <MenuItem\n key={href}\n size=\"small\"\n label={label}\n iconName={icon}\n href={href}\n isSelected={href === '/dashboard'}\n aria-current={href === '/dashboard' ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Navigation>\n );\n\n const statRow = (\n <SettingsSection key=\"stats\" title={`Numbers ${noun[range]}`} id=\"dashboard-stats\">\n <Grid compact columns={4}>\n <StatTile label=\"New comments\" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />\n <StatTile label=\"Marked done\" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />\n <StatTile label=\"People engaged\" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />\n <StatTile label=\"Average reply time\" value={d.stats.reply[0]} format=\"duration\" previous={d.stats.reply[1]} period={period} loading={loading} />\n </Grid>\n </SettingsSection>\n );\n\n const projects = (\n <SettingsSection key=\"projects\" title=\"Projects\" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id=\"dashboard-projects\">\n {projectsFailed ? (\n <>\n {/* Only this section failed. The rest of the page still shows. */}\n <Alert type=\"error\" variant=\"inline\" message=\"Could not load projects.\" autoDismiss={false} />\n <Cluster>\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Try Again\" loading={retrying} onClickButton={tryAgain} />\n </Cluster>\n </>\n ) : loading ? (\n <Skeleton variant=\"text\" lines={3} label=\"Loading projects\" />\n ) : (\n <List\n size=\"body2\"\n items={d.projects.map(([name, count]) => (\n <Progress key={name} kind=\"share\" label={name} value={count} max={projectTotal} unit=\"comments\" />\n ))}\n />\n )}\n </SettingsSection>\n );\n\n const waiting = (\n <SettingsSection key=\"waiting\" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id=\"dashboard-waiting\">\n {loading ? (\n <Skeleton variant=\"text\" lines={3} label=\"Loading what waits on you\" />\n ) : (\n <Stack gap=\"small\">\n {d.waiting.map(([text, href]) => (\n <MenuItem\n key={href}\n size=\"medium\"\n label={text}\n href={href}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Stack>\n )}\n </SettingsSection>\n );\n\n const questions = (\n <SettingsSection key=\"questions\" title=\"Questions from your agents\" id=\"dashboard-questions\">\n {loading ? (\n <Skeleton variant=\"text\" lines={2} label=\"Loading questions\" />\n ) : d.questions.length === 0 ? (\n // A section with nothing keeps its place and says what will fill it.\n <EmptyBox size=\"small\" text={`No questions from your agents ${noun[range]}`} secondText=\"Questions your agents ask you appear here.\" />\n ) : (\n <Stack gap=\"small\">\n {d.questions.map(([text, href]) => (\n <MenuItem\n key={href}\n size=\"medium\"\n label={text}\n href={href}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Stack>\n )}\n </SettingsSection>\n );\n\n return (\n <AppShell title=\"Dashboard\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Stack gap=\"xlarge\">\n {/* One range drives every number below, and each heading says which one. */}\n {/* Below md the range switch takes its own line under the title. */}\n <TitleBar\n title=\"Dashboard\"\n actionsBelow\n actions={<SegmentedControl size=\"small\" width=\"fit\" aria-label=\"Range\" options={ranges} value={range} onChange={changeRange} />}\n />\n {statRow}\n {projects}\n {waiting}\n {questions}\n </Stack>\n </AppShell>\n );\n}\n",
|
|
2169
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport StatTile from 'oneslash-design-system/components/statTile';\nimport Progress from 'oneslash-design-system/components/progress';\nimport Skeleton from 'oneslash-design-system/components/skeleton';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport List from 'oneslash-design-system/components/list';\nimport BarChart from 'oneslash-design-system/components/barChart';\nimport { formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';\n\ntype Range = 'week' | 'month' | 'quarter';\nconst ranges = [\n { value: 'week', label: 'Week' },\n { value: 'month', label: 'Month' },\n { value: 'quarter', label: 'Quarter' },\n];\n\n// A real app counts these on the server. One range drives every number on the page.\nconst data = {\n week: {\n stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },\n projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ],\n questions: [],\n },\n month: {\n stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },\n projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ['Confirm the release date', '/comments/4'],\n ['Approve the new onboarding text', '/comments/5'],\n ],\n questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],\n },\n quarter: {\n stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },\n projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],\n waiting: [\n ['Ben Carter asked for the new screens', '/comments/1'],\n ['Omar Reyes mentioned you in Launch plan', '/comments/2'],\n ['Review the pricing copy', '/comments/3'],\n ['Confirm the release date', '/comments/4'],\n ],\n questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],\n },\n} as const;\n\nconst noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };\n\nconst months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n// 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.\nfunction day(back: number) {\n const d = new Date(Date.UTC(2026, 10, 16 - back));\n return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;\n}\n\n// New comments per day, adding up to the tile above. The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.\nconst week = [152, 168, 149, 181, 190, 186, 214];\nconst month = [144, 157, 148, 162, 153, 145, 159, 150, 164, 155, 147, 160, 152, 166, 157, 149, 162, 153, 168, 159, 151, 164, 155, ...week];\nconst quarter = [1181, 1234, 1216, 1198, 1251, 1233, 1215, 1197, 1250, 1232, 1214, 1219, 1240];\nconst perDay: Record<Range, { label: string; value: number }[]> = {\n week: week.map((value, i) => ({ label: day(6 - i), value })),\n month: month.map((value, i) => ({ label: day(29 - i), value })),\n quarter: quarter.map((value, i) => ({ label: day(6 + (12 - i) * 7), value })),\n};\n\n// The summary says what changed, written from the same data the chart draws.\nfunction summary(range: Range) {\n const points = perDay[range];\n const first = points[0];\n const last = points[points.length - 1];\n const when = (p: { label: string }) => (range === 'quarter' ? `in the week of ${p.label}` : `on ${p.label}`);\n const move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';\n return move === 'stayed'\n ? `Comments stayed at ${formatCount(first.value)} from ${first.label} to ${last.label}.`\n : `Comments ${move} from ${formatCount(first.value)} ${when(first)} to ${formatCount(last.value)} ${when(last)}.`;\n}\n\nexport default function DashboardNumbersFirst() {\n const [range, setRange] = useState<Range>('week');\n // The numbers load again when the range changes.\n const [loading, setLoading] = useState(false);\n // The projects section fails first, so the rest of the page shows that one section can fail alone.\n const [projectsFailed, setProjectsFailed] = useState(true);\n const [retrying, setRetrying] = useState(false);\n // The chart starts loaded. A real app sets this when the chart's request fails.\n const [trendFailed, setTrendFailed] = useState(false);\n const [trendRetrying, setTrendRetrying] = useState(false);\n const [navOpen, setNavOpen] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const retryTimer = useRef<ReturnType<typeof setTimeout>>();\n const trendTimer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the requests if the example goes away before they end.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearTimeout(retryTimer.current);\n clearTimeout(trendTimer.current);\n }, []);\n\n function changeRange(next: string) {\n clearTimeout(timer.current);\n setRange(next as Range);\n setLoading(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => setLoading(false), 600);\n }\n\n function tryAgain() {\n if (retrying) return;\n setRetrying(true);\n retryTimer.current = setTimeout(() => {\n setRetrying(false);\n setProjectsFailed(false);\n }, 1200);\n }\n\n function tryTrendAgain() {\n if (trendRetrying) return;\n setTrendRetrying(true);\n trendTimer.current = setTimeout(() => {\n setTrendRetrying(false);\n setTrendFailed(false);\n }, 1200);\n }\n\n const d = data[range];\n const period = range;\n const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);\n const waitingCount: number = d.waiting.length;\n\n const sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {[\n ['Dashboard', 'LayoutDashboard', '/dashboard'],\n ['Comments', 'MessageSquare', '/comments'],\n ['Projects', 'FolderKanban', '/projects'],\n ].map(([label, icon, href]) => (\n <MenuItem\n key={href}\n size=\"small\"\n label={label}\n iconName={icon}\n href={href}\n isSelected={href === '/dashboard'}\n aria-current={href === '/dashboard' ? 'page' : undefined}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Navigation>\n );\n\n const statRow = (\n <SettingsSection key=\"stats\" title={`Numbers ${noun[range]}`} id=\"dashboard-stats\">\n <Grid compact columns={4}>\n <StatTile label=\"New comments\" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />\n <StatTile label=\"Marked done\" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />\n <StatTile label=\"People engaged\" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />\n <StatTile label=\"Average reply time\" value={d.stats.reply[0]} format=\"duration\" previous={d.stats.reply[1]} period={period} loading={loading} />\n </Grid>\n </SettingsSection>\n );\n\n // A trend over the range goes under the stat row, over the same range.\n const trend = (\n <SettingsSection key=\"trend\" title={`Comments ${noun[range]}`} id=\"dashboard-trend\">\n {trendFailed ? (\n <>\n {/* Only the chart failed, as the case 'Load failure' says. The rest of the page still shows. */}\n <Alert type=\"error\" variant=\"inline\" message=\"Could not load comments.\" autoDismiss={false} />\n <Cluster>\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Try Again\" loading={trendRetrying} onClickButton={tryTrendAgain} />\n </Cluster>\n </>\n ) : (\n <BarChart\n id=\"dashboard-comments-per-day\"\n title={range === 'quarter' ? 'Comments per week' : 'Comments per day'}\n summary={summary(range)}\n data={perDay[range]}\n unit=\"comments\"\n labelHeader={range === 'quarter' ? 'Week of' : 'Date'}\n loading={loading}\n emptyText={`No comments ${noun[range]}`}\n />\n )}\n </SettingsSection>\n );\n\n const projects = (\n <SettingsSection key=\"projects\" title=\"Projects\" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id=\"dashboard-projects\">\n {projectsFailed ? (\n <>\n {/* Only this section failed. The rest of the page still shows. */}\n <Alert type=\"error\" variant=\"inline\" message=\"Could not load projects.\" autoDismiss={false} />\n <Cluster>\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Try Again\" loading={retrying} onClickButton={tryAgain} />\n </Cluster>\n </>\n ) : loading ? (\n <Skeleton variant=\"text\" lines={3} label=\"Loading projects\" />\n ) : (\n <List\n size=\"body2\"\n items={d.projects.map(([name, count]) => (\n <Progress key={name} kind=\"share\" label={name} value={count} max={projectTotal} unit=\"comments\" />\n ))}\n />\n )}\n </SettingsSection>\n );\n\n const waiting = (\n <SettingsSection key=\"waiting\" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id=\"dashboard-waiting\">\n {loading ? (\n <Skeleton variant=\"text\" lines={3} label=\"Loading what waits on you\" />\n ) : (\n <Stack gap=\"small\">\n {d.waiting.map(([text, href]) => (\n <MenuItem\n key={href}\n size=\"medium\"\n label={text}\n href={href}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Stack>\n )}\n </SettingsSection>\n );\n\n const questions = (\n <SettingsSection key=\"questions\" title=\"Questions from your agents\" id=\"dashboard-questions\">\n {loading ? (\n <Skeleton variant=\"text\" lines={2} label=\"Loading questions\" />\n ) : d.questions.length === 0 ? (\n // A section with nothing keeps its place and says what will fill it.\n <EmptyBox size=\"small\" text={`No questions from your agents ${noun[range]}`} secondText=\"Questions your agents ask you appear here.\" />\n ) : (\n <Stack gap=\"small\">\n {d.questions.map(([text, href]) => (\n <MenuItem\n key={href}\n size=\"medium\"\n label={text}\n href={href}\n onClick={(event: { preventDefault: () => void }) => {\n // A real app lets the link go to its page. The example stays here.\n event.preventDefault();\n }}\n />\n ))}\n </Stack>\n )}\n </SettingsSection>\n );\n\n return (\n <AppShell title=\"Dashboard\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Stack gap=\"xlarge\">\n {/* One range drives every number below, and each heading says which one. */}\n {/* Below md the range switch takes its own line under the title. */}\n <TitleBar\n title=\"Dashboard\"\n actionsBelow\n actions={<SegmentedControl size=\"small\" width=\"fit\" aria-label=\"Range\" options={ranges} value={range} onChange={changeRange} />}\n />\n {statRow}\n {trend}\n {projects}\n {waiting}\n {questions}\n </Stack>\n </AppShell>\n );\n}\n",
|
|
1863
2170
|
"uses": [
|
|
1864
2171
|
"Alert",
|
|
1865
2172
|
"AppShell",
|
|
2173
|
+
"BarChart",
|
|
1866
2174
|
"Button",
|
|
1867
2175
|
"Cluster",
|
|
1868
2176
|
"EmptyBox",
|
|
@@ -3325,6 +3633,79 @@
|
|
|
3325
3633
|
}
|
|
3326
3634
|
]
|
|
3327
3635
|
},
|
|
3636
|
+
{
|
|
3637
|
+
"id": "leaderboard",
|
|
3638
|
+
"title": "Leaderboard",
|
|
3639
|
+
"kind": "design",
|
|
3640
|
+
"level": "organism",
|
|
3641
|
+
"area": "dashboard",
|
|
3642
|
+
"situation": "A dashboard shows who did the most of something over its range, such as who left the most comments this week.",
|
|
3643
|
+
"do": [
|
|
3644
|
+
"Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
|
|
3645
|
+
"Say what is counted and over which range, in the title and the description: 'Most active this week', 'Comments each person left from Nov 10 to Nov 16, 2026'.",
|
|
3646
|
+
"Show the top five in a `SettingsSection` as a `List marker=\"number\"`, so the list's numbers are the ranks.",
|
|
3647
|
+
"Make each row a `Cluster justify=\"between\"`: the face as `UserImage decorative size={24}` and the name, then the count with its unit, '42 comments', and the change beside it. On a phone they wrap under the name.",
|
|
3648
|
+
"Write the change in words with `formatChange`: 'Up 12% from last week', 'New this week'.",
|
|
3649
|
+
"List people with the same count in the top five by name. The table shows the shared rank.",
|
|
3650
|
+
"Show the person viewing their own row under the list, with their rank, when they are not in the top five.",
|
|
3651
|
+
"End the list with a `Link` 'See All People' to the table of everyone.",
|
|
3652
|
+
"Show everyone in a table, as the case 'Breakdown of a total' says: Rank, Person, Comments, Replies and Change. Mark the sorted column with `sort`, and right-align the numbers. Leave out the Total row: a ranking is read by person.",
|
|
3653
|
+
"Give people with the same count the same rank in the table, and skip the next: '2', '2', '4'.",
|
|
3654
|
+
"Page the table with `Pagination` past 25 people.",
|
|
3655
|
+
"Leave out the person viewing only when the heading says so, such as 'Most active this week, besides you'."
|
|
3656
|
+
],
|
|
3657
|
+
"dont": [
|
|
3658
|
+
"Do not give the top people medals, crowns or their own colors.",
|
|
3659
|
+
"Do not show the change as an arrow alone, or as a percent with no period.",
|
|
3660
|
+
"Do not draw a bar against the top person. The rank and the number say it, and a bar with no total reads like a share.",
|
|
3661
|
+
"Do not show a count with no unit."
|
|
3662
|
+
],
|
|
3663
|
+
"native": "On Apple use a `List` of rows with the rank, a face, the name and the count with `monospacedDigit()`, and a `Table` for everyone on a Mac or iPad. On Android use a `LazyColumn` of rows, and a table screen for everyone.",
|
|
3664
|
+
"options": [
|
|
3665
|
+
{
|
|
3666
|
+
"id": "ranked",
|
|
3667
|
+
"title": "Ranked list",
|
|
3668
|
+
"useWhen": "The top five or so people, read in order on a dashboard.",
|
|
3669
|
+
"source": "'use client';\nimport Heading from 'oneslash-design-system/components/heading';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport List from 'oneslash-design-system/components/list';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app counts these on the server, largest first. `previous` is last week's count.\n// The table example has a tie for second; this list has none, since its numbers are the ranks.\nconst people = [\n { name: 'Omar Reyes', comments: 58, previous: 52 },\n { name: 'Ben Carter', comments: 42, previous: 0 },\n { name: 'Mia Park', comments: 37, previous: 41 },\n { name: 'Dana Lee', comments: 30, previous: 30 },\n { name: 'Leo Grant', comments: 21, previous: 14 },\n { name: 'Ana Silva', comments: 9, previous: 12 },\n];\n\nconst top = people.slice(0, 5);\n\nexport default function LeaderboardRanked() {\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Dashboard</Heading>\n <SettingsSection title=\"Most active this week\" description=\"Comments each person left from Nov 10 to Nov 16, 2026\" id=\"leaderboard-ranked-people\">\n <Stack gap=\"large\">\n {/* The list's numbers are the ranks. The count and the change say the rest, so there are no bars. */}\n <List\n marker=\"number\"\n items={top.map((p) => (\n <Cluster key={p.name} justify=\"between\" gap=\"small\">\n <Cluster gap=\"small\">\n <UserImage userHandle={p.name} decorative size={24} />\n <Paragraph measure=\"none\">{p.name}</Paragraph>\n </Cluster>\n <Cluster gap=\"small\">\n <Paragraph measure=\"none\">{`${formatCount(p.comments)} ${p.comments === 1 ? 'comment' : 'comments'}`}</Paragraph>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{formatChange(p.comments, p.previous, 'week').text}</Paragraph>\n </Cluster>\n </Cluster>\n ))}\n />\n {/* A real app goes to the table of everyone. */}\n <Link href=\"/people\" size=\"body2\">See All People</Link>\n </Stack>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
3670
|
+
"uses": [
|
|
3671
|
+
"Center",
|
|
3672
|
+
"Cluster",
|
|
3673
|
+
"Heading",
|
|
3674
|
+
"Link",
|
|
3675
|
+
"List",
|
|
3676
|
+
"Paragraph",
|
|
3677
|
+
"SettingsSection",
|
|
3678
|
+
"Stack",
|
|
3679
|
+
"UserImage",
|
|
3680
|
+
"formatChange",
|
|
3681
|
+
"formatCount"
|
|
3682
|
+
]
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
"id": "table",
|
|
3686
|
+
"title": "Table of everyone",
|
|
3687
|
+
"useWhen": "Everyone, sorted and compared on more than one number.",
|
|
3688
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Pagination from 'oneslash-design-system/components/pagination';\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 { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app counts these on the server. `previous` is last week's count of comments.\nconst people = [\n { name: 'Ben Carter', comments: 42, replies: 31, previous: 0 },\n { name: 'Omar Reyes', comments: 58, replies: 44, previous: 52 },\n { name: 'Ana Silva', comments: 9, replies: 15, previous: 12 },\n { name: 'Mia Park', comments: 42, replies: 18, previous: 40 },\n { name: 'Leo Grant', comments: 21, replies: 9, previous: 14 },\n { name: 'Dana Lee', comments: 30, replies: 27, previous: 30 },\n];\n\n// Sorted by comments, largest first. People with the same count share a rank, and the next rank skips: 1, 2, 2, 4.\nconst sorted = [...people].sort((a, b) => b.comments - a.comments || a.name.localeCompare(b.name));\nconst ranked = sorted.map((p) => ({ ...p, rank: sorted.findIndex((q) => q.comments === p.comments) + 1 }));\n\nconst PAGE_SIZE = 25;\n\nexport default function LeaderboardTable() {\n const [page, setPage] = useState(1);\n const pageCount = Math.ceil(ranked.length / PAGE_SIZE);\n const rows = ranked.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">People</Heading>\n <SettingsSection title=\"Comments by person this week\" description=\"Everyone who commented from Nov 10 to Nov 16, 2026, by comments\" id=\"leaderboard-table-people\">\n <Stack gap=\"large\">\n {/* A named table sits in a region that scrolls sideways by itself, so the page never does. */}\n <TableContainer aria-label=\"Comments by person this week\" minWidth=\"640px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell align=\"right\" width=\"64px\">Rank</TableHeaderCell>\n <TableHeaderCell>Person</TableHeaderCell>\n <TableHeaderCell align=\"right\" width=\"110px\" sort=\"descending\">Comments</TableHeaderCell>\n <TableHeaderCell align=\"right\" width=\"90px\">Replies</TableHeaderCell>\n <TableHeaderCell align=\"right\" width=\"200px\">Change</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {rows.map((p) => (\n <TableRow key={p.name}>\n <TableCell align=\"right\" width=\"64px\">{String(p.rank)}</TableCell>\n <TableCell>\n <Cluster gap=\"small\">\n <UserImage userHandle={p.name} decorative size={24} />\n <Paragraph size=\"body2\" measure=\"none\">{p.name}</Paragraph>\n </Cluster>\n </TableCell>\n <TableCell align=\"right\" width=\"110px\">{formatCount(p.comments)}</TableCell>\n <TableCell align=\"right\" width=\"90px\">{formatCount(p.replies)}</TableCell>\n <TableCell align=\"right\" width=\"200px\">{formatChange(p.comments, p.previous, 'week').text}</TableCell>\n </TableRow>\n ))}\n </TableContainer>\n {/* Past 25 people the table pages. With one page, Pagination draws nothing. */}\n <Pagination page={page} pageCount={pageCount} onPageChange={setPage} aria-label=\"Pages of people\" scrollTargetId=\"leaderboard-table-people\" />\n </Stack>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
|
|
3689
|
+
"uses": [
|
|
3690
|
+
"Center",
|
|
3691
|
+
"Cluster",
|
|
3692
|
+
"Heading",
|
|
3693
|
+
"Pagination",
|
|
3694
|
+
"Paragraph",
|
|
3695
|
+
"SettingsSection",
|
|
3696
|
+
"Stack",
|
|
3697
|
+
"TableCell",
|
|
3698
|
+
"TableContainer",
|
|
3699
|
+
"TableHeader",
|
|
3700
|
+
"TableHeaderCell",
|
|
3701
|
+
"TableRow",
|
|
3702
|
+
"UserImage",
|
|
3703
|
+
"formatChange",
|
|
3704
|
+
"formatCount"
|
|
3705
|
+
]
|
|
3706
|
+
}
|
|
3707
|
+
]
|
|
3708
|
+
},
|
|
3328
3709
|
{
|
|
3329
3710
|
"id": "legal-page",
|
|
3330
3711
|
"title": "Legal page",
|
|
@@ -4450,11 +4831,12 @@
|
|
|
4450
4831
|
"level": "rule",
|
|
4451
4832
|
"area": "dashboard",
|
|
4452
4833
|
"situation": "A page shows counts, money, sizes, shares or changes.",
|
|
4453
|
-
"answer": "Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.",
|
|
4834
|
+
"answer": "Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. On a chart's axis, a number from 10,000 up shows its short form too: '12.4K'. The chart's readout and its table show the exact number. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.",
|
|
4454
4835
|
"why": "One page that rounds a cost to four decimals and another that rounds it to two make the same bill look like two different amounts. A 0 shown while a number loads reads as a real answer, so the person believes something that is not true.",
|
|
4455
4836
|
"do": [
|
|
4456
4837
|
"Show a count whole and grouped: '1,240'. In a tile, show a count or an amount from 10,000 up in its short form: '12.4K', '$12.4K'.",
|
|
4457
4838
|
"Show the exact number in a table, right-aligned.",
|
|
4839
|
+
"Show a number from 10,000 up on a chart's axis in its short form too: '12.4K'. Show the exact number in the chart's readout and its table.",
|
|
4458
4840
|
"Show money with its symbol and two decimals, and a cost under a cent as '< $0.01'.",
|
|
4459
4841
|
"Show a time as '340 ms', '1.2 s' or '2 h 24 min'. Show a share as a whole percent, and a small one as '< 1%'. Show a size in base 1024: '52 MB', '1.2 GB'.",
|
|
4460
4842
|
"Put the unit in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'.",
|
|
@@ -4469,9 +4851,10 @@
|
|
|
4469
4851
|
"Do not round a cost to four decimals in one place and two in another.",
|
|
4470
4852
|
"Do not color a change green or red. More is not good or bad by itself.",
|
|
4471
4853
|
"Do not show the compact form ('12.4K') in a table, or give a screen reader only the compact form.",
|
|
4854
|
+
"Do not show only the short form in a chart. Its readout and table are exact.",
|
|
4472
4855
|
"Do not show 100% for a share that is not the whole."
|
|
4473
4856
|
],
|
|
4474
|
-
"native": "On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`."
|
|
4857
|
+
"native": "On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`. On a chart's axis use `.notation(.compactName)` on Apple and `CompactDecimalFormat` on Android."
|
|
4475
4858
|
},
|
|
4476
4859
|
{
|
|
4477
4860
|
"id": "oauth-consent",
|
|
@@ -4625,6 +5008,82 @@
|
|
|
4625
5008
|
}
|
|
4626
5009
|
]
|
|
4627
5010
|
},
|
|
5011
|
+
{
|
|
5012
|
+
"id": "onboarding",
|
|
5013
|
+
"title": "First-run setup",
|
|
5014
|
+
"kind": "design",
|
|
5015
|
+
"level": "organism",
|
|
5016
|
+
"area": "auth",
|
|
5017
|
+
"situation": "A person has just signed up, and the app needs a few things from them before it works or before it is fully set up.",
|
|
5018
|
+
"do": [
|
|
5019
|
+
"Follow the rule 'A form error shows next to the problem'.",
|
|
5020
|
+
"Ask only for what the app cannot work without. Everything else goes in the checklist or in Settings.",
|
|
5021
|
+
"Say the count of steps up front, in words above the heading: 'Step 2 of 3'.",
|
|
5022
|
+
"Center each step in `<Center width=\"form\">`, and title it with a `Heading level={1}` that names the step: 'Name your workspace'.",
|
|
5023
|
+
"Give the heading a `ref` and `tabIndex={-1}`, and move focus to it on every step change, so a screen reader hears where the person is.",
|
|
5024
|
+
"Put each step in its own `Form`. 'Continue' is the primary Button and submits it. Give the last step 'Go to Workspace'.",
|
|
5025
|
+
"Give every step after the first a tertiary 'Back'. Keep what the person typed in state, so Back shows it again.",
|
|
5026
|
+
"Save each step when the person continues. A person who leaves comes back to the first step not done, with what they entered.",
|
|
5027
|
+
"Make Back and Continue again change what was saved, never make it twice: the same workspace name goes on at once, and only new addresses are invited.",
|
|
5028
|
+
"Give an optional step a tertiary 'Skip for Now'. It sends nothing and goes on at once. The last step says what was sent, counting invites sent before Back.",
|
|
5029
|
+
"Make the pressed Button `loading` while the request runs, and keep the step, its fields and its label on screen.",
|
|
5030
|
+
"Keep the step and what was typed when a request fails. Show an inline error `Alert` at the top of the form, above the fields and the Buttons.",
|
|
5031
|
+
"Show a field's error on submit, under the field: 'Enter a name for your workspace.'",
|
|
5032
|
+
"Show what can wait as a `SettingsSection` on the home page: a `Progress kind=\"share\"` with `valueText` such as '2 of 4 done', then a `StepList` of done and waiting steps.",
|
|
5033
|
+
"Link each waiting step to the place where it is done, such as 'Connect Calendar'.",
|
|
5034
|
+
"Say 'Acme is set up.' in an inline success `Alert` once every step is done, and offer a tertiary 'Hide Checklist'. Move focus to the page's heading when it hides."
|
|
5035
|
+
],
|
|
5036
|
+
"dont": [
|
|
5037
|
+
"Do not show progress as a bar of colored segments with no words.",
|
|
5038
|
+
"Do not disable Continue until a field is filled. Show the error on submit.",
|
|
5039
|
+
"Do not swap the step for a spinner while a request runs.",
|
|
5040
|
+
"Do not make a tour of the interface a step. Show help where the person needs it.",
|
|
5041
|
+
"Do not lose what the person typed when they go Back or a request fails.",
|
|
5042
|
+
"Do not make a second workspace or send an invite twice when the person goes Back and on again.",
|
|
5043
|
+
"Do not put a step the app can work without before the app. Put it in the checklist."
|
|
5044
|
+
],
|
|
5045
|
+
"native": "On Apple show the steps as a `NavigationStack` that pushes one `Form` per step, with Back in the navigation bar and Continue in a bottom bar, and post a screen-changed accessibility notification on each step. On Android use one screen per step with a `TopAppBar` back arrow, and the checklist as a card on the home screen.",
|
|
5046
|
+
"options": [
|
|
5047
|
+
{
|
|
5048
|
+
"id": "steps",
|
|
5049
|
+
"title": "Steps before the app",
|
|
5050
|
+
"useWhen": "Two to four steps a new person must pass before the app works, such as naming a workspace.",
|
|
5051
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Form from 'oneslash-design-system/components/form';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst titles = ['Name your workspace', 'Invite your team', 'You are set'];\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nfunction addresses(text: string) {\n return text.split(',').map((a) => a.trim()).filter(Boolean);\n}\n\n// `failOn` makes the workspace request fail once, so a test can see the error. A real app leaves it out.\n// A real app saves each step on Continue. A person who leaves comes back to the first step not done,\n// with what they entered, and the steps before it show what was saved.\nexport default function OnboardingSteps({ failOn }: { failOn?: 'workspace' } = {}) {\n const [step, setStep] = useState(0);\n // What the person typed stays in state, so Back shows it again.\n const [name, setName] = useState('');\n const [emails, setEmails] = useState('');\n const [nameError, setNameError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [error, setError] = useState('');\n const [loading, setLoading] = useState(false);\n // What was saved: the workspace's name once it exists, and the addresses already invited.\n // Back and Continue again never make the workspace twice or send an invite twice.\n const [created, setCreated] = useState<string | null>(null);\n const [sent, setSent] = useState<string[]>([]);\n const heading = useRef<HTMLHeadingElement>(null);\n const failed = useRef(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n // Set on a step change; run after the next render, once the new heading is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Each step change moves focus to the step's heading, so a screen reader reads where the person is.\n // The first step keeps focus where the page put it.\n function go(next: number) {\n setError('');\n setNameError('');\n setEmailError('');\n setStep(next);\n focusNext.current = () => heading.current?.focus({ preventScroll: true });\n }\n\n function back() {\n if (loading) return;\n go(step - 1);\n }\n\n function createWorkspace() {\n if (loading) return;\n setError('');\n setNameError('');\n const wanted = name.trim();\n if (!wanted) {\n setNameError('Enter a name for your workspace.');\n return;\n }\n // Already saved with this name: go on with no request.\n if (wanted === created) {\n go(1);\n return;\n }\n setLoading(true);\n // Stands in for the request to the server: it creates the workspace, or renames it when it exists.\n // The step and its Buttons stay while it runs.\n timer.current = setTimeout(() => {\n setLoading(false);\n if (failOn === 'workspace' && !failed.current) {\n failed.current = true;\n setError(created === null ? 'The workspace was not created. Try again.' : 'The workspace was not renamed. Try again.');\n return;\n }\n setCreated(wanted);\n go(1);\n }, 1200);\n }\n\n function sendInvites() {\n if (loading) return;\n setError('');\n setEmailError('');\n const list = addresses(emails);\n if (list.length === 0 && sent.length === 0) {\n setEmailError('Enter an email address, or choose Skip for Now.');\n return;\n }\n const wrong = list.find((a) => !looksLikeEmail(a));\n if (wrong) {\n setEmailError(`Check ${wrong}. Enter an address like name@example.com.`);\n return;\n }\n // Only addresses not yet invited are sent. With none, the step goes on at once.\n const fresh = list.filter((a) => !sent.includes(a));\n if (fresh.length === 0) {\n go(2);\n return;\n }\n setLoading(true);\n // Stands in for the request to the server. A failed request shows an inline error Alert, as on the first step.\n timer.current = setTimeout(() => {\n setLoading(false);\n setSent((s) => [...s, ...fresh]);\n go(2);\n }, 1200);\n }\n\n // Skip sends nothing and goes on at once. Invites already sent stay sent.\n function skip() {\n if (loading) return;\n go(2);\n }\n\n const workspace = created ?? name.trim();\n\n return (\n <Center width=\"form\">\n <Stack gap=\"small\">\n {/* The count of steps is said up front, in words. */}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{`Step ${step + 1} of ${titles.length}`}</Paragraph>\n <Heading ref={heading} tabIndex={-1} level={1} size=\"h5\">{titles[step]}</Heading>\n </Stack>\n\n {step === 0 && (\n <Form aria-label={titles[0]} onSubmit={createWorkspace}>\n {/* A failed request keeps the step and what was typed, and says so above the fields and the Buttons. */}\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField\n id=\"onboarding-steps-workspace\"\n label=\"Workspace name\"\n value={name}\n disabled={loading}\n error={Boolean(nameError)}\n errorText={nameError}\n helperText=\"Your team works here. You can change the name later.\"\n onChange={(e) => { setName(e.target.value); setNameError(''); }}\n />\n <Cluster gap=\"small\">\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Continue\" htmlType=\"submit\" loading={loading} />\n </Cluster>\n </Form>\n )}\n\n {step === 1 && (\n <Form aria-label={titles[1]} onSubmit={sendInvites}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <Paragraph measure=\"none\">{`Invite the people you work with to ${workspace}. You can skip this and invite them later.`}</Paragraph>\n <TextField\n id=\"onboarding-steps-emails\"\n label=\"Email addresses\"\n type=\"email\"\n value={emails}\n disabled={loading}\n error={Boolean(emailError)}\n errorText={emailError}\n helperText=\"Separate addresses with commas.\"\n onChange={(e) => { setEmails(e.target.value); setEmailError(''); }}\n />\n <Cluster gap=\"small\" justify=\"between\">\n <Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Back\" decoIcon=\"ChevronLeft\" onClickButton={back} />\n <Cluster gap=\"small\">\n <Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Skip for Now\" onClickButton={skip} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Continue\" htmlType=\"submit\" loading={loading} />\n </Cluster>\n </Cluster>\n </Form>\n )}\n\n {step === 2 && (\n <Stack gap=\"large\">\n <Paragraph measure=\"none\">\n {sent.length === 0\n ? `${workspace} is ready. No invites were sent. You can invite your team later in Settings, under Members.`\n : `${workspace} is ready. Invites went to ${sent.length} ${sent.length === 1 ? 'person' : 'people'}.`}\n </Paragraph>\n <Cluster gap=\"small\" justify=\"between\">\n <Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Back\" decoIcon=\"ChevronLeft\" onClickButton={back} />\n {/* A real app goes to the new workspace. */}\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Go to Workspace\" href=\"/workspace\" />\n </Cluster>\n </Stack>\n )}\n </Center>\n );\n}\n",
|
|
5052
|
+
"uses": [
|
|
5053
|
+
"Alert",
|
|
5054
|
+
"Button",
|
|
5055
|
+
"Center",
|
|
5056
|
+
"Cluster",
|
|
5057
|
+
"Form",
|
|
5058
|
+
"Heading",
|
|
5059
|
+
"Paragraph",
|
|
5060
|
+
"Stack",
|
|
5061
|
+
"TextField"
|
|
5062
|
+
]
|
|
5063
|
+
},
|
|
5064
|
+
{
|
|
5065
|
+
"id": "checklist",
|
|
5066
|
+
"title": "Checklist on the home page",
|
|
5067
|
+
"useWhen": "Things to set up that can wait, shown on the home page until they are done.",
|
|
5068
|
+
"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 SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport StepList from 'oneslash-design-system/components/stepList';\nimport Progress from 'oneslash-design-system/components/progress';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Task = { id: string; label: string; detail: string; action: string; href: string; done: boolean };\n\n// Things to set up that can wait. The app works without them. A real app reads them from the server.\nconst first: Task[] = [\n { id: 'workspace', label: 'Name your workspace', detail: 'Done Nov 14, 2026', action: 'Rename Workspace', href: '/settings/workspace', done: true },\n { id: 'invite', label: 'Invite your team', detail: 'Done Nov 14, 2026', action: 'Invite People', href: '/settings/members', done: true },\n { id: 'calendar', label: 'Connect a calendar', detail: 'In Settings, under Integrations', action: 'Connect Calendar', href: '/settings/integrations', done: false },\n { id: 'project', label: 'Create your first project', detail: 'On the Projects page', action: 'Create Project', href: '/projects/new', done: false },\n];\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nexport default function OnboardingChecklist() {\n const [tasks, setTasks] = useState(first);\n const [hidden, setHidden] = useState(false);\n const page = useRef<HTMLHeadingElement>(null);\n const hideButton = useRef<Focusable>(null);\n const firstAction = useRef<Focusable>(null);\n const toastIds = useRef<string[]>([]);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it closes every toast it opened.\n useEffect(() => () => {\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 done = tasks.filter((t) => t.done).length;\n const waiting = tasks.filter((t) => !t.done);\n const allDone = waiting.length === 0;\n\n // A real app lets the link go to its page, and the step is done when the person comes back.\n // The example marks it done here, so the end of the checklist shows.\n function finish(event: { preventDefault: () => void }, id: string) {\n event.preventDefault();\n const next = tasks.map((t) => (t.id === id ? { ...t, done: true, detail: 'Done Nov 16, 2026' } : t));\n setTasks(next);\n // The pressed link goes away. Focus goes to the next link, or to 'Hide Checklist' after the last one.\n focusNext.current = next.every((t) => t.done)\n ? () => hideButton.current?.focus({ preventScroll: true })\n : () => firstAction.current?.focus({ preventScroll: true });\n }\n\n // The checklist leaves the home page for good. Its Button goes with it, so focus goes to the page's heading.\n function hide() {\n setHidden(true);\n toastIds.current.push(toast({ type: 'success', message: 'Setup checklist hidden.' }));\n focusNext.current = () => page.current?.focus({ preventScroll: true });\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Heading ref={page} tabIndex={-1} level={1} size=\"h5\">Home</Heading>\n {!hidden && (\n <SettingsSection title=\"Set up Acme\" description=\"The app works without these. Finish them when you are ready.\" id=\"onboarding-checklist-setup\">\n <Stack gap=\"large\">\n <Progress kind=\"share\" label=\"Set up\" value={done} max={tasks.length} valueText={`${done} of ${tasks.length} done`} />\n <StepList aria-label=\"Setup steps\" steps={tasks.map((t) => ({ label: t.label, detail: t.detail, status: t.done ? 'done' : 'waiting' }))} />\n {allDone ? (\n <Stack gap=\"medium\" align=\"start\">\n {/* An inline Alert is a polite status, so a screen reader hears it. */}\n <Alert variant=\"inline\" type=\"success\" autoDismiss={false} message=\"Acme is set up.\" />\n <Button ref={hideButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Hide Checklist\" onClickButton={hide} />\n </Stack>\n ) : (\n // Each waiting step links to the place where it is done.\n <Cluster gap=\"small\">\n {waiting.map((t, i) => (\n <Button\n key={t.id}\n ref={i === 0 ? firstAction : undefined}\n size=\"small\"\n type=\"secondary\"\n state=\"enabled\"\n label={t.action}\n href={t.href}\n onClickButton={(event: { preventDefault: () => void }) => finish(event, t.id)}\n />\n ))}\n </Cluster>\n )}\n </Stack>\n </SettingsSection>\n )}\n <Paragraph tone=\"secondary\" measure=\"none\">Your projects and comments show here.</Paragraph>\n </Stack>\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n </Center>\n );\n}\n",
|
|
5069
|
+
"uses": [
|
|
5070
|
+
"Alert",
|
|
5071
|
+
"Button",
|
|
5072
|
+
"Center",
|
|
5073
|
+
"Cluster",
|
|
5074
|
+
"Heading",
|
|
5075
|
+
"Paragraph",
|
|
5076
|
+
"Progress",
|
|
5077
|
+
"SettingsSection",
|
|
5078
|
+
"Stack",
|
|
5079
|
+
"StepList",
|
|
5080
|
+
"Toaster",
|
|
5081
|
+
"dismissToast",
|
|
5082
|
+
"toast"
|
|
5083
|
+
]
|
|
5084
|
+
}
|
|
5085
|
+
]
|
|
5086
|
+
},
|
|
4628
5087
|
{
|
|
4629
5088
|
"id": "one-main-action",
|
|
4630
5089
|
"title": "A marketing page asks for one main action, in the same words everywhere",
|
|
@@ -5295,6 +5754,93 @@
|
|
|
5295
5754
|
}
|
|
5296
5755
|
]
|
|
5297
5756
|
},
|
|
5757
|
+
{
|
|
5758
|
+
"id": "plan-sign-off",
|
|
5759
|
+
"title": "Plan sign-off",
|
|
5760
|
+
"kind": "design",
|
|
5761
|
+
"level": "organism",
|
|
5762
|
+
"area": "agent",
|
|
5763
|
+
"situation": "The agent wrote a plan for a task, and people approve it before the agent starts the work.",
|
|
5764
|
+
"do": [
|
|
5765
|
+
"Follow the rule 'An agent asks before a risky action': the agent starts nothing until every required person has said yes.",
|
|
5766
|
+
"Show the plan in a `SidePane` titled 'Plan' beside the task, as the case 'Side pane' says. A plan in a chat message stays a card, as the case 'Plan proposal' says.",
|
|
5767
|
+
"Write the plan as headed sections: a `Heading`, then a `Paragraph` or a `List` for each.",
|
|
5768
|
+
"Say who wrote the plan and when: 'Written by Acme Agent, Nov 16, 2026, 2:40 PM'.",
|
|
5769
|
+
"Put the sign-off at the end of the pane, after the whole plan.",
|
|
5770
|
+
"Give one approver 'Cancel', 'Request Changes', then 'Approve' as the primary Button, as the changes card of the case 'Plan proposal' does. 'Cancel' marks the plan Cancelled, and the agent does nothing. 'Request Changes' opens a `Textarea` labelled 'What should change?' with 'Discard' and 'Send', with the same focus rules.",
|
|
5771
|
+
"Show a team's count as `<Progress kind=\"share\" label=\"Signed off\">` with `valueText` such as '2 of 3 people'.",
|
|
5772
|
+
"List who signed and when in a `List`: 'Ben Carter, Nov 16, 2026'. Keep the list as the record once all have signed.",
|
|
5773
|
+
"Say by name who has not signed: 'Waiting for Dana Lee.'",
|
|
5774
|
+
"Show how long the plan waits, as the rule 'An agent cancels and reports when nobody answers' says: 'Waits until Nov 19, 2026, then cancels.' Notify each person who has not signed.",
|
|
5775
|
+
"Give a person who has not signed 'Request Changes' and 'Sign Off' as the primary Button. Give one who has signed a tertiary 'Withdraw Sign-Off'.",
|
|
5776
|
+
"Clear the sign-offs when the agent rewrites the plan after a request, and say so in the warning `Alert`.",
|
|
5777
|
+
"Show the gaps in an inline warning `Alert` when the agent finds some before a sign-off, with 'Review Plan' and 'Sign Off Anyway'. 'Review Plan' moves focus to the plan's first heading.",
|
|
5778
|
+
"Make the pressed Button `loading` and keep its label while the request runs.",
|
|
5779
|
+
"Remove the sign-offs when the plan changes, and say so in an inline warning `Alert`: 'The plan changed, so the 2 sign-offs were removed. Each person signs off again.'",
|
|
5780
|
+
"Show 'Signed off by everyone. Acme Agent starts the work.' in an inline success `Alert` once the last person signs, and remove the Buttons. The Alert is a polite status, so a screen reader hears it.",
|
|
5781
|
+
"Move focus to the pane's title when the Buttons go away and nothing takes their place.",
|
|
5782
|
+
"Give every inline `Alert` here `autoDismiss={false}`, so it stays until the state changes."
|
|
5783
|
+
],
|
|
5784
|
+
"dont": [
|
|
5785
|
+
"Do not let the agent start before every required person has signed off.",
|
|
5786
|
+
"Do not offer an override that skips the sign-offs, such as a commit for an admin.",
|
|
5787
|
+
"Do not change a Button's label while it is loading, such as to 'Checking...'.",
|
|
5788
|
+
"Do not title a confirm 'Sure?'. Name the action, as the rule 'A confirm says exactly what will happen' says.",
|
|
5789
|
+
"Do not show only faces for who signed. Write the names and the dates."
|
|
5790
|
+
],
|
|
5791
|
+
"native": "On Apple show the plan in an inspector or a sheet, the count as a `ProgressView` with a value label, and the sign-off Buttons in a bottom bar. On Android use a side sheet or a bottom sheet with a `LinearProgressIndicator`.",
|
|
5792
|
+
"options": [
|
|
5793
|
+
{
|
|
5794
|
+
"id": "one-approver",
|
|
5795
|
+
"title": "One person approves",
|
|
5796
|
+
"useWhen": "One person approves the agent's plan before it starts.",
|
|
5797
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\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 Line from 'oneslash-design-system/components/line';\nimport Button from 'oneslash-design-system/components/button';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport Alert from 'oneslash-design-system/components/alert';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Status = 'open' | 'requesting' | 'redoing' | 'approved' | 'cancelled';\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst task = 'Launch checklist';\n\n// The plan Acme Agent wrote, as headed sections.\nconst steps = [\n 'Acme Agent updates the home page and its tests.',\n 'Omar Reyes writes the new copy.',\n 'Mia Park checks the screens on a phone.',\n 'Ben Carter merges the pull request.',\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function PlanSignOffOneApprover() {\n const [navOpen, setNavOpen] = useState(false);\n // The person opened the plan from the task header. The example starts with the pane open.\n const [open, setOpen] = useState(true);\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'approve' | 'cancel' | 'send' | null>(null);\n const [draft, setDraft] = useState('');\n const pane = useRef<SidePaneHandle>(null);\n const requestButton = useRef<Focusable>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Acme Agent starts only after 'Approve'. 'Cancel' marks the plan Cancelled, and the agent does nothing.\n // Either way the Buttons go, and nothing takes their place, so focus goes to the pane's title.\n function decide(action: 'approve' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus(action === 'cancel' ? 'cancelled' : 'approved');\n focusNext.current = () => pane.current?.focus();\n }, 1200);\n }\n\n function startRequest() {\n if (pending) return;\n setDraft('');\n setStatus('requesting');\n }\n\n // 'Discard' leaves the field and keeps the plan waiting. Focus goes back to 'Request Changes'.\n function discard() {\n setStatus('open');\n focusNext.current = () => requestButton.current?.focus({ preventScroll: true });\n }\n\n const empty = draft.trim() === '';\n\n // 'Send' gives the agent what should change. The Buttons go, and the agent rewrites the plan.\n function send() {\n if (pending || empty) return;\n setPending('send');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus('redoing');\n focusNext.current = () => pane.current?.focus();\n }, 1200);\n }\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane ref={pane} title=\"Plan\" onClose={() => setOpen(false)}>\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">Goal</Heading>\n <Paragraph measure=\"none\">Ship the new home page on Nov 20, 2026, with the sign-up form above the pricing table.</Paragraph>\n </Stack>\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">Steps</Heading>\n <List marker=\"number\" items={steps} />\n </Stack>\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">Out of scope</Heading>\n <Paragraph measure=\"none\">The pricing page stays as it is.</Paragraph>\n </Stack>\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>\n <Line />\n {/* The approval comes last, after the whole plan. */}\n <Stack gap=\"medium\">\n <Heading level={3} size=\"subtitle1\">Approval</Heading>\n {status === 'approved' ? (\n // An inline Alert is a polite status, so a screen reader hears it.\n <Alert variant=\"inline\" type=\"success\" autoDismiss={false} message=\"Approved by Dana Lee, Nov 16, 2026, 2:52 PM. Acme Agent starts the work.\" />\n ) : status === 'cancelled' ? (\n <Alert variant=\"inline\" type=\"info\" autoDismiss={false} message=\"Cancelled. Nothing was changed.\" />\n ) : status === 'redoing' ? (\n <Alert variant=\"inline\" type=\"info\" autoDismiss={false} message=\"Acme Agent is rewriting the plan. The new plan shows here when it is ready.\" />\n ) : (\n <Paragraph measure=\"none\">Acme Agent starts once Dana Lee approves this plan.</Paragraph>\n )}\n {status === 'requesting' && (\n <Textarea\n id=\"plan-sign-off-change-request\"\n label=\"What should change?\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={send}\n autoFocus\n disabled={pending === 'send'}\n />\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'approve' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={requestButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Request Changes\" onClickButton={startRequest} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Approve\" loading={pending === 'approve'} onClickButton={() => decide('approve')} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'send' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={empty ? 'disabled' : 'enabled'} label=\"Send\" loading={pending === 'send'} onClickButton={send} />\n </Cluster>\n )}\n </Stack>\n </Stack>\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n actions={\n <Tooltip title=\"Plan\">\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"FileText\"\n ariaLabel={`Show the plan for ${task}`}\n aria-expanded={open}\n onClick={() => (open ? pane.current?.focus() : setOpen(true))}\n />\n </Tooltip>\n }\n />\n <Paragraph tone=\"secondary\" measure=\"none\">Acme Agent wrote a plan for this task. It waits for Dana Lee to approve it.</Paragraph>\n </Stack>\n </AppShell>\n );\n}\n",
|
|
5798
|
+
"uses": [
|
|
5799
|
+
"Alert",
|
|
5800
|
+
"AppShell",
|
|
5801
|
+
"Button",
|
|
5802
|
+
"Cluster",
|
|
5803
|
+
"Heading",
|
|
5804
|
+
"IconButton",
|
|
5805
|
+
"Line",
|
|
5806
|
+
"List",
|
|
5807
|
+
"MenuItem",
|
|
5808
|
+
"Navigation",
|
|
5809
|
+
"Paragraph",
|
|
5810
|
+
"SidePane",
|
|
5811
|
+
"Stack",
|
|
5812
|
+
"Textarea",
|
|
5813
|
+
"TitleBar",
|
|
5814
|
+
"Tooltip"
|
|
5815
|
+
]
|
|
5816
|
+
},
|
|
5817
|
+
{
|
|
5818
|
+
"id": "team",
|
|
5819
|
+
"title": "Everyone signs off",
|
|
5820
|
+
"useWhen": "Every member of the task signs off a shared plan, and work starts when all have.",
|
|
5821
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\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 Line from 'oneslash-design-system/components/line';\nimport Button from 'oneslash-design-system/components/button';\nimport Progress from 'oneslash-design-system/components/progress';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport Alert from 'oneslash-design-system/components/alert';\nimport { Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Step = 'waiting' | 'requesting' | 'gaps' | 'signed' | 'done';\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst task = 'Launch checklist';\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\n// Everyone on the task signs off. Acme Agent starts only when all have.\nconst members = ['Ben Carter', 'Omar Reyes', me];\n\nconst steps = [\n 'Acme Agent updates the home page and its tests.',\n 'Omar Reyes writes the new copy.',\n 'Dana Lee checks the screens on a phone.',\n 'Ben Carter merges the pull request.',\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function PlanSignOffTeam() {\n const [navOpen, setNavOpen] = useState(false);\n // The person opened the plan from the task header. The example starts with the pane open.\n const [open, setOpen] = useState(true);\n // Who signed and when, kept as the record.\n const [signers, setSigners] = useState([\n { name: 'Ben Carter', on: 'Nov 16, 2026' },\n { name: 'Omar Reyes', on: 'Nov 16, 2026' },\n ]);\n const [step, setStep] = useState<Step>('waiting');\n const [pending, setPending] = useState<'check' | 'sign' | 'send' | 'withdraw' | null>(null);\n const [draft, setDraft] = useState('');\n // After a rewrite: how many sign-offs it removed. The rewrite also closed the gaps the agent found.\n const [cleared, setCleared] = useState<number | null>(null);\n const pane = useRef<SidePaneHandle>(null);\n const firstHeading = useRef<HTMLHeadingElement>(null);\n const reviewButton = useRef<Focusable>(null);\n const requestButton = useRef<Focusable>(null);\n const signOffButton = useRef<Focusable>(null);\n const withdrawButton = useRef<Focusable>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const waitingFor = members.filter((m) => !signers.some((s) => s.name === m));\n const waitingLine = waitingFor.length === 1 ? waitingFor[0] : `${waitingFor.slice(0, -1).join(', ')} and ${waitingFor[waitingFor.length - 1]}`;\n\n // Dana's sign-off is in. When it was the last, Acme Agent starts: the Buttons go and focus goes to the pane's title.\n // Otherwise 'Withdraw Sign-Off' takes the place of 'Sign Off' and takes focus.\n function addMySignOff() {\n const next = [...signers, { name: me, on: 'Nov 16, 2026' }];\n setSigners(next);\n if (next.length === members.length) {\n setStep('done');\n focusNext.current = () => pane.current?.focus();\n } else {\n setStep('signed');\n focusNext.current = () => withdrawButton.current?.focus({ preventScroll: true });\n }\n }\n\n // Acme Agent checks the plan for gaps first. 'Sign Off' keeps its label while it checks.\n // The first plan has two, so 'Sign Off' gives way to 'Review Plan' and 'Sign Off Anyway', and focus goes to the first.\n function signOff() {\n if (pending) return;\n setPending('check');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (cleared !== null) {\n addMySignOff();\n return;\n }\n setStep('gaps');\n focusNext.current = () => reviewButton.current?.focus({ preventScroll: true });\n }, 1200);\n }\n\n function startRequest() {\n if (pending) return;\n setDraft('');\n setStep('requesting');\n }\n\n // 'Discard' leaves the field and keeps the plan as it is. Focus goes back to 'Request Changes'.\n function discard() {\n setStep('waiting');\n focusNext.current = () => requestButton.current?.focus({ preventScroll: true });\n }\n\n const empty = draft.trim() === '';\n\n // 'Send' gives the agent what should change. The rewritten plan clears every sign-off, and the warning says so.\n // Focus goes to the pane's title, so the person reads the new plan from the top.\n function send() {\n if (pending || empty) return;\n setPending('send');\n // Stands in for the agent rewriting the plan.\n timer.current = setTimeout(() => {\n setPending(null);\n setCleared(signers.length);\n setSigners([]);\n setStep('waiting');\n focusNext.current = () => pane.current?.focus();\n }, 1200);\n }\n\n // Withdrawing puts Dana back on the waiting list, and 'Sign Off' comes back with focus.\n function withdraw() {\n if (pending) return;\n setPending('withdraw');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setSigners((list) => list.filter((s) => s.name !== me));\n setStep('waiting');\n focusNext.current = () => signOffButton.current?.focus({ preventScroll: true });\n }, 1200);\n }\n\n // The person goes back to read the plan. The warning and its Buttons stay.\n function reviewPlan() {\n firstHeading.current?.focus();\n }\n\n function signOffAnyway() {\n if (pending) return;\n setPending('sign');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n addMySignOff();\n }, 1200);\n }\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n open && (\n <SidePane ref={pane} title=\"Plan\" onClose={() => setOpen(false)}>\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading ref={firstHeading} tabIndex={-1} level={3} size=\"subtitle1\">Goal</Heading>\n <Paragraph measure=\"none\">Ship the new home page on Nov 20, 2026, with the sign-up form above the pricing table.</Paragraph>\n </Stack>\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">Steps</Heading>\n <List marker=\"number\" items={steps} />\n </Stack>\n <Stack gap=\"small\">\n <Heading level={3} size=\"subtitle1\">Out of scope</Heading>\n <Paragraph measure=\"none\">The pricing page stays as it is.</Paragraph>\n </Stack>\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{cleared === null ? 'Written by Acme Agent, Nov 16, 2026, 2:40 PM' : 'Rewritten by Acme Agent, Nov 16, 2026, 3:10 PM'}</Paragraph>\n <Line />\n {/* The sign-off comes last, after the whole plan. */}\n <Stack gap=\"medium\">\n <Heading level={3} size=\"subtitle1\">Sign-off</Heading>\n <Progress\n kind=\"share\"\n label=\"Signed off\"\n value={signers.length}\n max={members.length}\n valueText={`${signers.length} of ${members.length} people`}\n />\n {signers.length > 0 && <List items={signers.map((s) => `${s.name}, ${s.on}`)} />}\n {cleared !== null && step !== 'done' && (\n <Alert variant=\"inline\" type=\"warning\" autoDismiss={false} message={`The plan changed, so the ${cleared} sign-offs were removed. Each person signs off again.`} />\n )}\n {step === 'done' ? (\n // An inline Alert is a polite status, so a screen reader hears it.\n <Alert variant=\"inline\" type=\"success\" autoDismiss={false} message=\"Signed off by everyone. Acme Agent starts the work.\" />\n ) : (\n <Paragraph measure=\"none\">Waiting for {waitingLine}.</Paragraph>\n )}\n {step === 'requesting' && (\n <Textarea\n id=\"plan-sign-off-team-change-request\"\n label=\"What should change?\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={send}\n autoFocus\n disabled={pending === 'send'}\n />\n )}\n {step === 'gaps' && (\n <Alert\n variant=\"inline\"\n type=\"warning\"\n autoDismiss={false}\n message=\"Acme Agent found 2 gaps in the plan.\"\n secondMessage=\"No one owns the press kit. The support hand-off has no date.\"\n />\n )}\n {step === 'waiting' && (\n <Cluster gap=\"small\">\n <Button ref={requestButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Request Changes\" onClickButton={startRequest} />\n <Button ref={signOffButton} size=\"small\" type=\"primary\" state=\"enabled\" label=\"Sign Off\" loading={pending === 'check'} onClickButton={signOff} />\n </Cluster>\n )}\n {step === 'requesting' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'send' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={empty ? 'disabled' : 'enabled'} label=\"Send\" loading={pending === 'send'} onClickButton={send} />\n </Cluster>\n )}\n {step === 'signed' && (\n <Cluster gap=\"small\">\n <Button ref={withdrawButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Withdraw Sign-Off\" loading={pending === 'withdraw'} onClickButton={withdraw} />\n </Cluster>\n )}\n {step === 'gaps' && (\n <Cluster gap=\"small\">\n <Button ref={reviewButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Review Plan\" onClickButton={reviewPlan} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Sign Off Anyway\" loading={pending === 'sign'} onClickButton={signOffAnyway} />\n </Cluster>\n )}\n </Stack>\n </Stack>\n </SidePane>\n )\n }\n >\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n actions={\n <Tooltip title=\"Plan\">\n <IconButton\n color=\"iconOnly\"\n state={open ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"FileText\"\n ariaLabel={`Show the plan for ${task}`}\n aria-expanded={open}\n onClick={() => (open ? pane.current?.focus() : setOpen(true))}\n />\n </Tooltip>\n }\n />\n <Paragraph tone=\"secondary\" measure=\"none\">Acme Agent wrote a plan for this task. Everyone on the task signs it off before the work starts.</Paragraph>\n </Stack>\n </AppShell>\n );\n}\n",
|
|
5822
|
+
"uses": [
|
|
5823
|
+
"Alert",
|
|
5824
|
+
"AppShell",
|
|
5825
|
+
"Button",
|
|
5826
|
+
"Cluster",
|
|
5827
|
+
"Heading",
|
|
5828
|
+
"IconButton",
|
|
5829
|
+
"Line",
|
|
5830
|
+
"List",
|
|
5831
|
+
"MenuItem",
|
|
5832
|
+
"Navigation",
|
|
5833
|
+
"Paragraph",
|
|
5834
|
+
"Progress",
|
|
5835
|
+
"SidePane",
|
|
5836
|
+
"Stack",
|
|
5837
|
+
"Textarea",
|
|
5838
|
+
"TitleBar",
|
|
5839
|
+
"Tooltip"
|
|
5840
|
+
]
|
|
5841
|
+
}
|
|
5842
|
+
]
|
|
5843
|
+
},
|
|
5298
5844
|
{
|
|
5299
5845
|
"id": "pricing-section",
|
|
5300
5846
|
"title": "Pricing section",
|
|
@@ -6510,7 +7056,7 @@
|
|
|
6510
7056
|
"Do not show 0 while a number loads or when it is missing.",
|
|
6511
7057
|
"Do not color a change green or red. More is not good or bad by itself.",
|
|
6512
7058
|
"Do not put more than four tiles in a row, or two things in one tile.",
|
|
6513
|
-
"Do not draw a chart or a sparkline in a tile. A trend
|
|
7059
|
+
"Do not draw a chart or a sparkline in a tile. A trend over the range goes in a chart under the row, as the case 'Chart' says.",
|
|
6514
7060
|
"Do not box each tile in a card. The row sits on the page."
|
|
6515
7061
|
],
|
|
6516
7062
|
"native": "On Apple use a `LabeledContent` or a `Grid` of `VStack`s with the number in `.title2` and `monospacedDigit()`. On Android use a `Row` of `Column`s with `headlineMedium` text.",
|
|
@@ -6739,6 +7285,98 @@
|
|
|
6739
7285
|
}
|
|
6740
7286
|
]
|
|
6741
7287
|
},
|
|
7288
|
+
{
|
|
7289
|
+
"id": "task-header",
|
|
7290
|
+
"title": "Task header",
|
|
7291
|
+
"kind": "design",
|
|
7292
|
+
"level": "organism",
|
|
7293
|
+
"area": "shell",
|
|
7294
|
+
"situation": "A task page shows its name, its state, who is on it and when it is due, with the panes and actions for it.",
|
|
7295
|
+
"do": [
|
|
7296
|
+
"Follow the case 'Page header with actions': `TitleBar` with the task's name as the one level 1 heading.",
|
|
7297
|
+
"Put the state, the people and the due date in the `meta` line under the title: a `Tag variant=\"dot\" size=\"small\"` such as 'In progress', an `AvatarStack`, then 'Due Nov 20, 2026'.",
|
|
7298
|
+
"Write the state in sentence case, as the case 'Status in a row' says: 'In progress', not 'IN PROGRESS'.",
|
|
7299
|
+
"Show the people as the case 'People on an item' says: one `AvatarStack` that opens a list of every name and role.",
|
|
7300
|
+
"Let people change the state from a secondary small Button that names it: 'Status: In Progress'. Give it `aria-haspopup=\"menu\"` and `aria-expanded`. A row keeps the change in its More menu, as the case 'Status in a row' says. A task page has room for the Button.",
|
|
7301
|
+
"Open `<Popover returnFocus>` around `<Menu navigable aria-label=\"Task status\">` from that Button, with the current state `isSelected`.",
|
|
7302
|
+
"Show a new state in the `meta` Tag and on the Button at once, and close the menu. Focus goes back to the Button.",
|
|
7303
|
+
"Show the Tag alone when the agent or a check sets the state. Say who sets it near the header, such as 'Acme Agent sets the status as the work moves.'",
|
|
7304
|
+
"Open the plan and the history as panes, as the case 'Side pane' says: an `IconButton` each, with `aria-expanded` and `state=\"selected\"` while its pane is open.",
|
|
7305
|
+
"Name each pane button for its pane and the task: 'Show the plan for Launch checklist'.",
|
|
7306
|
+
"Put a More menu last, as the case 'More menu' says: 'More actions for Launch checklist' with Rename and Archive, then a `Line` and a danger 'Delete Task'.",
|
|
7307
|
+
"Confirm 'Delete Task' in a small Modal, as the case 'Delete confirm' says: 'Delete Task', 'Cancel', then a danger 'Delete'.",
|
|
7308
|
+
"Pass `phoneActions` with the Plan button and More when the row holds only icon buttons. Below `md` the History button folds into More, first and before a `Line`.",
|
|
7309
|
+
"Pass `actionsBelow` instead when the row holds the status Button. It is too wide to sit beside the title on a phone, so below `md` the actions take their own line under it."
|
|
7310
|
+
],
|
|
7311
|
+
"dont": [
|
|
7312
|
+
"Do not make the status Tag a button. A state people change opens from its own Button.",
|
|
7313
|
+
"Do not put a `Tooltip` on each face. Use the stack and its list.",
|
|
7314
|
+
"Do not put Delete in the row as an icon button. It goes last in the More menu.",
|
|
7315
|
+
"Do not write the state in the Tag in upper case or Title Case. The Button and the menu items use Title Case: 'Status: In Progress'.",
|
|
7316
|
+
"Do not use a small heading size for the task name. It is the page's level 1 heading in `TitleBar`."
|
|
7317
|
+
],
|
|
7318
|
+
"native": "On Apple put the name in the navigation title, the state and the people in a `.navigationSubtitle` on Mac and a toolbar `principal` item on iPhone, the status in a `Menu` with a `Picker`, and the panes as an inspector. On Android use a `TopAppBar` with a dropdown menu for the status and the rest.",
|
|
7319
|
+
"options": [
|
|
7320
|
+
{
|
|
7321
|
+
"id": "people-change-status",
|
|
7322
|
+
"title": "People change the status",
|
|
7323
|
+
"useWhen": "People move the task through its states.",
|
|
7324
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Tag from 'oneslash-design-system/components/tag';\nimport AvatarStack from 'oneslash-design-system/components/avatarStack';\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 List from 'oneslash-design-system/components/list';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Timeline from 'oneslash-design-system/components/timeline';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\ntype PaneId = 'plan' | 'history';\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst task = 'Launch checklist';\n\n// A Button and a menu item say the state in Title Case. The Tag says it in sentence case.\nconst statuses = [\n { id: 'to-do', label: 'To Do', tag: 'To do' },\n { id: 'in-progress', label: 'In Progress', tag: 'In progress' },\n { id: 'in-review', label: 'In Review', tag: 'In review' },\n { id: 'done', label: 'Done', tag: 'Done' },\n];\n\n// The person who started the task comes first, here and in every list of these people.\nconst people = [\n { name: 'Ben Carter', role: 'Admin' },\n { name: 'Dana Lee', role: 'Member' },\n { name: 'Omar Reyes', role: 'Member' },\n { name: 'Mia Park', role: 'Member' },\n { name: 'Leo Grant', role: 'Guest' },\n { name: 'Ana Silva', role: 'Guest' },\n];\n\nconst history = [\n { id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },\n { id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },\n { id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function TaskHeaderPeopleChangeStatus() {\n const [navOpen, setNavOpen] = useState(false);\n const [status, setStatus] = useState('in-progress');\n const [statusAnchor, setStatusAnchor] = useState<HTMLElement | null>(null);\n const [peopleAnchor, setPeopleAnchor] = useState<HTMLElement | null>(null);\n const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);\n const [moreOpen, setMoreOpen] = useState(false);\n // One pane at a time. Opening another replaces it.\n const [pane, setPane] = useState<PaneId | null>(null);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const paneRef = useRef<SidePaneHandle>(null);\n const moreButton = useRef<Focusable>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\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 const current = statuses.find((s) => s.id === status) ?? statuses[0];\n\n // The new state shows in the Tag and on the Button at once. The Popover gives focus back to the Button.\n function chooseStatus(id: string) {\n setStatusAnchor(null);\n // A real app sends the new state to the server here.\n setStatus(id);\n }\n\n // Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.\n function togglePane(id: PaneId) {\n if (pane === id) paneRef.current?.focus();\n else setPane(id);\n }\n\n function openMore(el: HTMLElement) {\n setMoreAnchor(el);\n setMoreOpen((o) => !o);\n }\n\n // Every item closes the menu. The Popover gives focus back to More.\n function choose(action: () => void) {\n setMoreOpen(false);\n action();\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 keepTask() {\n if (deleting) return;\n setConfirming(false);\n focusNext.current = () => moreButton.current?.focus({ preventScroll: true });\n }\n\n function confirmDelete() {\n if (deleting) return;\n setDeleting(true);\n // Stands in for the request to the server. A real app then goes back to the task list.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirming(false);\n toastIds.current.push(toast({ type: 'success', message: `${task} deleted.` }));\n }, 1200);\n }\n\n const statusButton = (\n <Button\n size=\"small\"\n type=\"secondary\"\n state=\"enabled\"\n label={`Status: ${current.label}`}\n aria-haspopup=\"menu\"\n aria-expanded={statusAnchor !== null}\n onClickButton={(e: { currentTarget: HTMLElement }) => setStatusAnchor(statusAnchor ? null : e.currentTarget)}\n />\n );\n\n const paneButton = (id: PaneId) => (\n <Tooltip title={id === 'plan' ? 'Plan' : 'History'}>\n <IconButton\n color=\"iconOnly\"\n state={pane === id ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName={id === 'plan' ? 'FileText' : 'History'}\n ariaLabel={id === 'plan' ? `Show the plan for ${task}` : `Show the history of ${task}`}\n aria-expanded={pane === id}\n onClick={() => togglePane(id)}\n />\n </Tooltip>\n );\n\n const more = (\n <Tooltip title=\"More\">\n <IconButton\n ref={moreButton}\n color=\"iconOnly\"\n state={moreOpen ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${task}`}\n aria-haspopup=\"menu\"\n aria-expanded={moreOpen}\n onClick={(e: { currentTarget: HTMLElement }) => openMore(e.currentTarget)}\n />\n </Tooltip>\n );\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n pane && (\n <SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={() => setPane(null)}>\n {pane === 'plan' ? (\n <Stack gap=\"medium\">\n <Paragraph measure=\"none\">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>\n </Stack>\n ) : (\n <Timeline id=\"task-header-history\" aria-label=\"History\" items={history} />\n )}\n </SidePane>\n )\n }\n >\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n meta={\n <>\n <Tag variant=\"dot\" size=\"small\" label={current.tag} />\n <AvatarStack\n people={people}\n aria-label={`Show the ${people.length} people on ${task}`}\n aria-haspopup=\"dialog\"\n aria-expanded={peopleAnchor !== null}\n onClick={(event) => setPeopleAnchor(peopleAnchor ? null : event.currentTarget)}\n />\n Due Nov 20, 2026\n </>\n }\n // The status Button is too wide to sit beside the title on a phone, so below md the actions take their own line.\n actions={\n <>\n {statusButton}\n {paneButton('plan')}\n {paneButton('history')}\n {more}\n </>\n }\n actionsBelow\n />\n <Paragraph tone=\"secondary\" measure=\"none\">Acme Agent is updating the home page. Omar Reyes is writing the copy.</Paragraph>\n </Stack>\n <Popover id=\"task-header-status\" open={statusAnchor !== null} anchorEl={statusAnchor} onClose={() => setStatusAnchor(null)} returnFocus>\n <Menu navigable aria-label=\"Task status\" width={200}>\n {statuses.map((s) => (\n <MenuItem key={s.id} size=\"small\" label={s.label} isSelected={s.id === status} onClick={() => chooseStatus(s.id)} />\n ))}\n </Menu>\n </Popover>\n <Popover id=\"task-header-people\" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={() => setPeopleAnchor(null)} returnFocus>\n <List items={people.map((p) => `${p.name}, ${p.role}`)} />\n </Popover>\n <Popover id=\"task-header-more\" open={moreOpen} anchorEl={moreAnchor} onClose={() => setMoreOpen(false)} returnFocus>\n <Menu navigable aria-label={`Actions for ${task}`} width={200}>\n {/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}\n <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Rename\" onClick={() => choose(() => {})} />\n <MenuItem size=\"small\" iconName=\"Archive\" label=\"Archive\" onClick={() => choose(() => {})} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete Task\" onClick={() => choose(() => setConfirming(true))} />\n </Menu>\n </Popover>\n {/* The task is a page, 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 Task\"\n onClose={keepTask}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={keepTask} />\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 '{task}', its plan and its history.</Paragraph>\n </Modal>\n </AppShell>\n );\n}\n",
|
|
7325
|
+
"uses": [
|
|
7326
|
+
"AppShell",
|
|
7327
|
+
"AvatarStack",
|
|
7328
|
+
"Button",
|
|
7329
|
+
"IconButton",
|
|
7330
|
+
"Line",
|
|
7331
|
+
"List",
|
|
7332
|
+
"Menu",
|
|
7333
|
+
"MenuItem",
|
|
7334
|
+
"Modal",
|
|
7335
|
+
"Navigation",
|
|
7336
|
+
"Paragraph",
|
|
7337
|
+
"Popover",
|
|
7338
|
+
"SidePane",
|
|
7339
|
+
"Stack",
|
|
7340
|
+
"Tag",
|
|
7341
|
+
"Timeline",
|
|
7342
|
+
"TitleBar",
|
|
7343
|
+
"Toaster",
|
|
7344
|
+
"Tooltip",
|
|
7345
|
+
"dismissToast",
|
|
7346
|
+
"toast"
|
|
7347
|
+
]
|
|
7348
|
+
},
|
|
7349
|
+
{
|
|
7350
|
+
"id": "agent-sets-status",
|
|
7351
|
+
"title": "The agent sets the status",
|
|
7352
|
+
"useWhen": "The agent or a check sets the state, and people only read it.",
|
|
7353
|
+
"source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Tag from 'oneslash-design-system/components/tag';\nimport AvatarStack from 'oneslash-design-system/components/avatarStack';\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 List from 'oneslash-design-system/components/list';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Timeline from 'oneslash-design-system/components/timeline';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\ntype PaneId = 'plan' | 'history';\ntype Width = 'wide' | 'phone';\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst task = 'Launch checklist';\n\n// The person who started the task comes first, here and in every list of these people.\nconst people = [\n { name: 'Ben Carter', role: 'Admin' },\n { name: 'Dana Lee', role: 'Member' },\n { name: 'Omar Reyes', role: 'Member' },\n { name: 'Mia Park', role: 'Member' },\n { name: 'Leo Grant', role: 'Guest' },\n { name: 'Ana Silva', role: 'Guest' },\n];\n\nconst history = [\n { id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },\n { id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },\n { id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },\n];\n\n// The places. A real app lets each link go to its page.\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <MenuItem\n size=\"small\"\n label=\"Tasks\"\n iconName=\"ListChecks\"\n href=\"/tasks\"\n isSelected\n aria-current=\"page\"\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n </Navigation>\n);\n\nexport default function TaskHeaderAgentSetsStatus() {\n const [navOpen, setNavOpen] = useState(false);\n const [peopleAnchor, setPeopleAnchor] = useState<HTMLElement | null>(null);\n // Which More button opened the menu: on a phone the menu also holds History. It stays set while the menu fades out.\n const [moreFrom, setMoreFrom] = useState<Width>('wide');\n const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);\n const [moreOpen, setMoreOpen] = useState(false);\n // One pane at a time. Opening another replaces it.\n const [pane, setPane] = useState<PaneId | null>(null);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const paneRef = useRef<SidePaneHandle>(null);\n const moreButtons = useRef<Record<Width, Focusable>>({ wide: null, phone: null });\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\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 // Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.\n function togglePane(id: PaneId) {\n if (pane === id) paneRef.current?.focus();\n else setPane(id);\n }\n\n function openMore(from: Width, el: HTMLElement) {\n if (moreOpen && moreFrom === from) {\n setMoreOpen(false);\n return;\n }\n setMoreFrom(from);\n setMoreAnchor(el);\n setMoreOpen(true);\n }\n\n // Every item closes the menu. The Popover gives focus back to More.\n function choose(action: () => void) {\n setMoreOpen(false);\n action();\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 keepTask() {\n if (deleting) return;\n setConfirming(false);\n focusNext.current = () => moreButtons.current[moreFrom]?.focus({ preventScroll: true });\n }\n\n function confirmDelete() {\n if (deleting) return;\n setDeleting(true);\n // Stands in for the request to the server. A real app then goes back to the task list.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setConfirming(false);\n toastIds.current.push(toast({ type: 'success', message: `${task} deleted.` }));\n }, 1200);\n }\n\n const paneButton = (id: PaneId) => (\n <Tooltip title={id === 'plan' ? 'Plan' : 'History'}>\n <IconButton\n color=\"iconOnly\"\n state={pane === id ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName={id === 'plan' ? 'FileText' : 'History'}\n ariaLabel={id === 'plan' ? `Show the plan for ${task}` : `Show the history of ${task}`}\n aria-expanded={pane === id}\n onClick={() => togglePane(id)}\n />\n </Tooltip>\n );\n\n const more = (from: Width) => (\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[from] = el; }}\n color=\"iconOnly\"\n state={moreOpen && moreFrom === from ? 'selected' : 'enabled'}\n size=\"medium\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${task}`}\n aria-haspopup=\"menu\"\n aria-expanded={moreOpen && moreFrom === from}\n onClick={(e: { currentTarget: HTMLElement }) => openMore(from, e.currentTarget)}\n />\n </Tooltip>\n );\n\n return (\n <AppShell\n title=\"Tasks\"\n navOpen={navOpen}\n onNavOpenChange={setNavOpen}\n sidebar={sidebar}\n pane={\n pane && (\n <SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={() => setPane(null)}>\n {pane === 'plan' ? (\n <Stack gap=\"medium\">\n <Paragraph measure=\"none\">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>\n </Stack>\n ) : (\n <Timeline id=\"task-header-agent-history\" aria-label=\"History\" items={history} />\n )}\n </SidePane>\n )\n }\n >\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <TitleBar\n title={task}\n meta={\n <>\n {/* Acme Agent and the checks set the state. People read it here and do not change it. */}\n <Tag variant=\"dot\" size=\"small\" label=\"In progress\" />\n <AvatarStack\n people={people}\n aria-label={`Show the ${people.length} people on ${task}`}\n aria-haspopup=\"dialog\"\n aria-expanded={peopleAnchor !== null}\n onClick={(event) => setPeopleAnchor(peopleAnchor ? null : event.currentTarget)}\n />\n Due Nov 20, 2026\n </>\n }\n actions={\n <>\n {paneButton('plan')}\n {paneButton('history')}\n {more('wide')}\n </>\n }\n phoneActions={\n <>\n {paneButton('plan')}\n {more('phone')}\n </>\n }\n />\n <Paragraph tone=\"secondary\" measure=\"none\">Acme Agent sets the status as the work moves. It is updating the home page, and Omar Reyes is writing the copy.</Paragraph>\n </Stack>\n <Popover id=\"task-header-agent-people\" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={() => setPeopleAnchor(null)} returnFocus>\n <List items={people.map((p) => `${p.name}, ${p.role}`)} />\n </Popover>\n <Popover id=\"task-header-agent-more\" open={moreOpen} anchorEl={moreAnchor} onClose={() => setMoreOpen(false)} returnFocus>\n <Menu navigable aria-label={`Actions for ${task}`} width={200}>\n {moreFrom === 'phone' && (\n <>\n <MenuItem size=\"small\" iconName=\"History\" label=\"History\" onClick={() => choose(() => togglePane('history'))} />\n <Line />\n </>\n )}\n {/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}\n <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Rename\" onClick={() => choose(() => {})} />\n <MenuItem size=\"small\" iconName=\"Archive\" label=\"Archive\" onClick={() => choose(() => {})} />\n <Line />\n {/* Delete is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Delete Task\" onClick={() => choose(() => setConfirming(true))} />\n </Menu>\n </Popover>\n {/* The task is a page, 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 Task\"\n onClose={keepTask}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={keepTask} />\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 '{task}', its plan and its history.</Paragraph>\n </Modal>\n </AppShell>\n );\n}\n",
|
|
7354
|
+
"uses": [
|
|
7355
|
+
"AppShell",
|
|
7356
|
+
"AvatarStack",
|
|
7357
|
+
"Button",
|
|
7358
|
+
"IconButton",
|
|
7359
|
+
"Line",
|
|
7360
|
+
"List",
|
|
7361
|
+
"Menu",
|
|
7362
|
+
"MenuItem",
|
|
7363
|
+
"Modal",
|
|
7364
|
+
"Navigation",
|
|
7365
|
+
"Paragraph",
|
|
7366
|
+
"Popover",
|
|
7367
|
+
"SidePane",
|
|
7368
|
+
"Stack",
|
|
7369
|
+
"Tag",
|
|
7370
|
+
"Timeline",
|
|
7371
|
+
"TitleBar",
|
|
7372
|
+
"Toaster",
|
|
7373
|
+
"Tooltip",
|
|
7374
|
+
"dismissToast",
|
|
7375
|
+
"toast"
|
|
7376
|
+
]
|
|
7377
|
+
}
|
|
7378
|
+
]
|
|
7379
|
+
},
|
|
6742
7380
|
{
|
|
6743
7381
|
"id": "theme-switcher",
|
|
6744
7382
|
"title": "Theme switcher",
|