oneslash-design-system 2.16.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/README.md +2 -2
  2. package/dist/DESIGN.md +56 -17
  3. package/dist/cases/accept-invite/signed-in.jsx +1 -1
  4. package/dist/cases/accept-invite/signed-out.jsx +1 -1
  5. package/dist/cases/accept-invite.md +3 -7
  6. package/dist/cases/account-menu/menu.d.ts +1 -0
  7. package/dist/cases/account-menu/menu.jsx +99 -0
  8. package/dist/cases/account-menu.md +164 -0
  9. package/dist/cases/agent-asks-before-risky-action.md +0 -4
  10. package/dist/cases/agent-cancels-when-unanswered.md +0 -4
  11. package/dist/cases/agent-options/cards.d.ts +1 -0
  12. package/dist/cases/agent-options/cards.jsx +91 -0
  13. package/dist/cases/agent-options.md +164 -0
  14. package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
  15. package/dist/cases/agent-pending-reply/steps.jsx +149 -0
  16. package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
  17. package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
  18. package/dist/cases/agent-pending-reply.md +428 -0
  19. package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
  20. package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
  21. package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
  22. package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
  23. package/dist/cases/agent-plan-proposal.md +652 -0
  24. package/dist/cases/agent-question/choices.d.ts +1 -0
  25. package/dist/cases/agent-question/choices.jsx +132 -0
  26. package/dist/cases/agent-question/free-text.d.ts +1 -0
  27. package/dist/cases/agent-question/free-text.jsx +81 -0
  28. package/dist/cases/agent-question.md +334 -0
  29. package/dist/cases/agent-refuses-clearly.md +0 -4
  30. package/dist/cases/agent-says-what-it-is.md +0 -2
  31. package/dist/cases/agent-settings/form.d.ts +1 -0
  32. package/dist/cases/agent-settings/form.jsx +164 -0
  33. package/dist/cases/agent-settings.md +259 -0
  34. package/dist/cases/agent-shows-progress.md +0 -2
  35. package/dist/cases/agent-shows-sources.md +2 -4
  36. package/dist/cases/api-keys/list.d.ts +1 -0
  37. package/dist/cases/api-keys/list.jsx +162 -0
  38. package/dist/cases/api-keys.md +229 -0
  39. package/dist/cases/artifact-card/card.d.ts +1 -0
  40. package/dist/cases/artifact-card/card.jsx +45 -0
  41. package/dist/cases/artifact-card.md +99 -0
  42. package/dist/cases/auth-gate-loading.md +0 -4
  43. package/dist/cases/check-your-email.md +0 -4
  44. package/dist/cases/collapsible-search/popover.d.ts +1 -0
  45. package/dist/cases/collapsible-search/popover.jsx +74 -0
  46. package/dist/cases/collapsible-search.md +143 -0
  47. package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
  48. package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
  49. package/dist/cases/composer-limit/notice.d.ts +1 -0
  50. package/dist/cases/composer-limit/notice.jsx +84 -0
  51. package/dist/cases/composer-limit.md +282 -0
  52. package/dist/cases/confirm-destructive-action.md +0 -4
  53. package/dist/cases/confirm-dialogs.md +0 -4
  54. package/dist/cases/conversation-starters/chips.d.ts +1 -0
  55. package/dist/cases/conversation-starters/chips.jsx +69 -0
  56. package/dist/cases/conversation-starters/none.d.ts +1 -0
  57. package/dist/cases/conversation-starters/none.jsx +45 -0
  58. package/dist/cases/conversation-starters.md +204 -0
  59. package/dist/cases/create-modal.md +0 -4
  60. package/dist/cases/danger-zone/collapsed.d.ts +1 -0
  61. package/dist/cases/danger-zone/collapsed.jsx +75 -0
  62. package/dist/cases/danger-zone/shown.d.ts +1 -0
  63. package/dist/cases/danger-zone/shown.jsx +95 -0
  64. package/dist/cases/danger-zone.md +263 -0
  65. package/dist/cases/device-login.md +0 -4
  66. package/dist/cases/email-confirmed.md +0 -4
  67. package/dist/cases/empty-list.md +0 -4
  68. package/dist/cases/empty-lists.md +0 -4
  69. package/dist/cases/empty-not-set-up.md +0 -4
  70. package/dist/cases/empty-search.md +0 -4
  71. package/dist/cases/error-page.md +0 -4
  72. package/dist/cases/feedback-form.md +0 -4
  73. package/dist/cases/filter-menu/presets.d.ts +1 -0
  74. package/dist/cases/filter-menu/presets.jsx +53 -0
  75. package/dist/cases/filter-menu/with-clear.d.ts +1 -0
  76. package/dist/cases/filter-menu/with-clear.jsx +56 -0
  77. package/dist/cases/filter-menu.md +204 -0
  78. package/dist/cases/forgot-password.md +0 -4
  79. package/dist/cases/form-errors.md +0 -4
  80. package/dist/cases/import-checklist.md +0 -4
  81. package/dist/cases/inline-form-feedback.md +0 -4
  82. package/dist/cases/integrations-list/nested.d.ts +1 -0
  83. package/dist/cases/integrations-list/nested.jsx +164 -0
  84. package/dist/cases/integrations-list/rows.d.ts +1 -0
  85. package/dist/cases/integrations-list/rows.jsx +134 -0
  86. package/dist/cases/integrations-list.md +379 -0
  87. package/dist/cases/invite-member.md +0 -4
  88. package/dist/cases/load-failure.md +0 -4
  89. package/dist/cases/log-out-confirm.md +0 -4
  90. package/dist/cases/login-page.md +0 -4
  91. package/dist/cases/members-list/rows.d.ts +1 -0
  92. package/dist/cases/members-list/rows.jsx +318 -0
  93. package/dist/cases/members-list/table.d.ts +1 -0
  94. package/dist/cases/members-list/table.jsx +351 -0
  95. package/dist/cases/members-list.md +799 -0
  96. package/dist/cases/mention-list/in-composer.d.ts +1 -0
  97. package/dist/cases/mention-list/in-composer.jsx +169 -0
  98. package/dist/cases/mention-list.md +248 -0
  99. package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
  100. package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
  101. package/dist/cases/message-actions/menu.d.ts +1 -0
  102. package/dist/cases/message-actions/menu.jsx +258 -0
  103. package/dist/cases/message-actions.md +647 -0
  104. package/dist/cases/message-attachments/in-composer.d.ts +1 -0
  105. package/dist/cases/message-attachments/in-composer.jsx +134 -0
  106. package/dist/cases/message-attachments/in-message.d.ts +1 -0
  107. package/dist/cases/message-attachments/in-message.jsx +46 -0
  108. package/dist/cases/message-attachments.md +306 -0
  109. package/dist/cases/message-composer/plain.d.ts +1 -0
  110. package/dist/cases/message-composer/plain.jsx +57 -0
  111. package/dist/cases/message-composer/with-tools.d.ts +1 -0
  112. package/dist/cases/message-composer/with-tools.jsx +182 -0
  113. package/dist/cases/message-composer.md +352 -0
  114. package/dist/cases/message-edit/in-place.d.ts +1 -0
  115. package/dist/cases/message-edit/in-place.jsx +99 -0
  116. package/dist/cases/message-edit.md +175 -0
  117. package/dist/cases/message-reactions/chips.d.ts +1 -0
  118. package/dist/cases/message-reactions/chips.jsx +118 -0
  119. package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
  120. package/dist/cases/message-reactions/quick-pick.jsx +155 -0
  121. package/dist/cases/message-reactions.md +367 -0
  122. package/dist/cases/message-row/grouped.d.ts +1 -0
  123. package/dist/cases/message-row/grouped.jsx +56 -0
  124. package/dist/cases/message-row/person-and-agent.d.ts +1 -0
  125. package/dist/cases/message-row/person-and-agent.jsx +41 -0
  126. package/dist/cases/message-row.md +185 -0
  127. package/dist/cases/not-found-page.md +0 -4
  128. package/dist/cases/notification-menu/menu.d.ts +1 -0
  129. package/dist/cases/notification-menu/menu.jsx +74 -0
  130. package/dist/cases/notification-menu.md +135 -0
  131. package/dist/cases/oauth-consent.md +0 -4
  132. package/dist/cases/on-off-settings/list.d.ts +1 -0
  133. package/dist/cases/on-off-settings/list.jsx +97 -0
  134. package/dist/cases/on-off-settings.md +116 -0
  135. package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
  136. package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
  137. package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
  138. package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
  139. package/dist/cases/overflow-menu.md +410 -0
  140. package/dist/cases/profile-form/form.d.ts +1 -0
  141. package/dist/cases/profile-form/form.jsx +153 -0
  142. package/dist/cases/profile-form.md +236 -0
  143. package/dist/cases/quick-switcher/modal.d.ts +1 -0
  144. package/dist/cases/quick-switcher/modal.jsx +114 -0
  145. package/dist/cases/quick-switcher.md +205 -0
  146. package/dist/cases/range-switch/segmented.d.ts +1 -0
  147. package/dist/cases/range-switch/segmented.jsx +30 -0
  148. package/dist/cases/range-switch.md +67 -0
  149. package/dist/cases/rename.md +0 -4
  150. package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
  151. package/dist/cases/reply-feedback/thumbs.jsx +191 -0
  152. package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
  153. package/dist/cases/reply-feedback/with-reason.jsx +221 -0
  154. package/dist/cases/reply-feedback.md +548 -0
  155. package/dist/cases/reply-sources/cards.d.ts +1 -0
  156. package/dist/cases/reply-sources/cards.jsx +83 -0
  157. package/dist/cases/reply-sources/tag-only.d.ts +1 -0
  158. package/dist/cases/reply-sources/tag-only.jsx +45 -0
  159. package/dist/cases/reply-sources.md +243 -0
  160. package/dist/cases/route-loading.md +0 -2
  161. package/dist/cases/scope-picker/menu.d.ts +1 -0
  162. package/dist/cases/scope-picker/menu.jsx +47 -0
  163. package/dist/cases/scope-picker.md +97 -0
  164. package/dist/cases/set-new-password.md +0 -4
  165. package/dist/cases/settings-page/side-nav.d.ts +1 -0
  166. package/dist/cases/settings-page/side-nav.jsx +171 -0
  167. package/dist/cases/settings-page/top-tabs.d.ts +1 -0
  168. package/dist/cases/settings-page/top-tabs.jsx +129 -0
  169. package/dist/cases/settings-page.md +378 -0
  170. package/dist/cases/settings-save.md +35 -0
  171. package/dist/cases/sign-up-page.md +1 -5
  172. package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
  173. package/dist/cases/slash-command-list/in-composer.jsx +162 -0
  174. package/dist/cases/slash-command-list.md +243 -0
  175. package/dist/cases/success-feedback.md +1 -5
  176. package/dist/cases/tag-filter/tags.d.ts +1 -0
  177. package/dist/cases/tag-filter/tags.jsx +226 -0
  178. package/dist/cases/tag-filter.md +298 -0
  179. package/dist/cases/type-to-confirm.md +0 -4
  180. package/dist/cases/typing-and-status/line.d.ts +1 -0
  181. package/dist/cases/typing-and-status/line.jsx +50 -0
  182. package/dist/cases/typing-and-status.md +92 -0
  183. package/dist/cases/unsaved-changes-guard.md +0 -4
  184. package/dist/cases/upgrade-prompt.md +0 -4
  185. package/dist/cases.json +2331 -294
  186. package/dist/components/alert.d.ts +3 -1
  187. package/dist/components/alert.jsx +2 -2
  188. package/dist/components/button.d.ts +3 -2
  189. package/dist/components/button.jsx +14 -9
  190. package/dist/components/checkBox.d.ts +5 -1
  191. package/dist/components/checkBox.jsx +2 -2
  192. package/dist/components/composer.d.ts +74 -0
  193. package/dist/components/composer.jsx +122 -0
  194. package/dist/components/copyField.d.ts +20 -0
  195. package/dist/components/copyField.jsx +99 -0
  196. package/dist/components/fileChip.d.ts +33 -0
  197. package/dist/components/fileChip.jsx +61 -0
  198. package/dist/components/formField.d.ts +34 -0
  199. package/dist/components/formField.jsx +28 -0
  200. package/dist/components/heading.d.ts +3 -1
  201. package/dist/components/heading.jsx +2 -2
  202. package/dist/components/iconButton.d.ts +3 -3
  203. package/dist/components/iconButton.jsx +9 -7
  204. package/dist/components/layout.d.ts +7 -1
  205. package/dist/components/layout.jsx +5 -2
  206. package/dist/components/menu.d.ts +21 -0
  207. package/dist/components/menu.jsx +27 -3
  208. package/dist/components/menuItem.d.ts +12 -2
  209. package/dist/components/menuItem.jsx +6 -5
  210. package/dist/components/message.d.ts +28 -0
  211. package/dist/components/message.jsx +25 -0
  212. package/dist/components/navigation.d.ts +9 -1
  213. package/dist/components/navigation.jsx +15 -3
  214. package/dist/components/paragraph.d.ts +3 -1
  215. package/dist/components/paragraph.jsx +2 -2
  216. package/dist/components/popover.d.ts +7 -1
  217. package/dist/components/popover.jsx +35 -9
  218. package/dist/components/radioGroup.d.ts +12 -1
  219. package/dist/components/radioGroup.jsx +20 -9
  220. package/dist/components/segmentedControl.d.ts +22 -0
  221. package/dist/components/segmentedControl.jsx +54 -0
  222. package/dist/components/select.d.ts +5 -1
  223. package/dist/components/select.jsx +2 -2
  224. package/dist/components/settingsSection.d.ts +31 -0
  225. package/dist/components/settingsSection.jsx +58 -0
  226. package/dist/components/slidingIndicator.d.ts +50 -0
  227. package/dist/components/slidingIndicator.jsx +102 -0
  228. package/dist/components/sourceCard.d.ts +23 -0
  229. package/dist/components/sourceCard.jsx +56 -0
  230. package/dist/components/stepList.d.ts +17 -0
  231. package/dist/components/stepList.jsx +79 -0
  232. package/dist/components/switch.d.ts +25 -0
  233. package/dist/components/switch.jsx +55 -0
  234. package/dist/components/tab.jsx +5 -11
  235. package/dist/components/tabsContainer.jsx +5 -67
  236. package/dist/components/tag.d.ts +9 -1
  237. package/dist/components/tag.jsx +6 -4
  238. package/dist/components/textField.d.ts +12 -2
  239. package/dist/components/textField.jsx +11 -4
  240. package/dist/components/textarea.d.ts +5 -1
  241. package/dist/components/textarea.jsx +6 -21
  242. package/dist/components/useHotkey.d.ts +7 -0
  243. package/dist/components/useHotkey.js +24 -0
  244. package/dist/components/userImage.d.ts +9 -1
  245. package/dist/components/userImage.jsx +10 -3
  246. package/dist/index.d.ts +6 -0
  247. package/dist/index.js +6 -0
  248. package/dist/internal/autoGrow.d.ts +11 -0
  249. package/dist/internal/autoGrow.js +28 -0
  250. package/dist/internal/composer.d.ts +16 -0
  251. package/dist/internal/composer.js +18 -0
  252. package/dist/internal/copyField.d.ts +5 -0
  253. package/dist/internal/copyField.js +61 -0
  254. package/dist/internal/hotkey.d.ts +16 -0
  255. package/dist/internal/hotkey.js +20 -0
  256. package/dist/internal/menu.d.ts +6 -0
  257. package/dist/internal/menu.js +31 -0
  258. package/dist/internal/switch.d.ts +5 -0
  259. package/dist/internal/switch.js +9 -0
  260. package/dist/native-mapping.json +62 -1
  261. package/dist/stories/Button.stories.d.ts +1 -0
  262. package/dist/stories/Button.stories.jsx +17 -1
  263. package/dist/stories/Cases.generated.stories.d.ts +53 -0
  264. package/dist/stories/Cases.generated.stories.jsx +106 -0
  265. package/dist/stories/Composer.stories.d.ts +23 -0
  266. package/dist/stories/Composer.stories.jsx +121 -0
  267. package/dist/stories/CopyField.stories.d.ts +11 -0
  268. package/dist/stories/CopyField.stories.jsx +65 -0
  269. package/dist/stories/FileChip.stories.d.ts +7 -0
  270. package/dist/stories/FileChip.stories.jsx +35 -0
  271. package/dist/stories/FormField.stories.d.ts +6 -0
  272. package/dist/stories/FormField.stories.jsx +44 -0
  273. package/dist/stories/IconButton.stories.d.ts +1 -0
  274. package/dist/stories/IconButton.stories.jsx +18 -1
  275. package/dist/stories/Menu.stories.d.ts +4 -0
  276. package/dist/stories/Menu.stories.jsx +46 -1
  277. package/dist/stories/MenuItem.stories.d.ts +1 -0
  278. package/dist/stories/MenuItem.stories.jsx +8 -0
  279. package/dist/stories/Message.stories.d.ts +10 -0
  280. package/dist/stories/Message.stories.jsx +77 -0
  281. package/dist/stories/Navigation.stories.d.ts +1 -0
  282. package/dist/stories/Navigation.stories.jsx +17 -1
  283. package/dist/stories/PageComponents.stories.d.ts +1 -0
  284. package/dist/stories/PageComponents.stories.jsx +21 -0
  285. package/dist/stories/RadioGroup.stories.d.ts +2 -0
  286. package/dist/stories/RadioGroup.stories.jsx +40 -1
  287. package/dist/stories/SegmentedControl.stories.d.ts +8 -0
  288. package/dist/stories/SegmentedControl.stories.jsx +33 -0
  289. package/dist/stories/SettingsSection.stories.d.ts +11 -0
  290. package/dist/stories/SettingsSection.stories.jsx +64 -0
  291. package/dist/stories/SourceCard.stories.d.ts +8 -0
  292. package/dist/stories/SourceCard.stories.jsx +33 -0
  293. package/dist/stories/StepList.stories.d.ts +8 -0
  294. package/dist/stories/StepList.stories.jsx +35 -0
  295. package/dist/stories/Switch.stories.d.ts +14 -0
  296. package/dist/stories/Switch.stories.jsx +87 -0
  297. package/dist/stories/TextField.stories.d.ts +1 -0
  298. package/dist/stories/TextField.stories.jsx +13 -0
  299. package/dist/stories/UserImage.stories.d.ts +2 -0
  300. package/dist/stories/UserImage.stories.jsx +19 -0
  301. package/package.json +8 -3
@@ -0,0 +1 @@
1
+ export default function NotificationMenuExample(): import("react").JSX.Element;
@@ -0,0 +1,74 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import IconButton from '../../components/iconButton';
7
+ import Tooltip from '../../components/tooltip';
8
+ import Popover from '../../components/popover';
9
+ import Menu from '../../components/menu';
10
+ import MenuItem from '../../components/menuItem';
11
+ import { Center, Cluster, Stack } from '../../components/layout';
12
+ var choices = [
13
+ { value: 'all', label: 'All Messages', line: 'Every message in this channel.', current: 'All messages' },
14
+ { value: 'mentions', label: 'Mentions Only', line: 'Only when someone mentions you.', current: 'Mentions only' },
15
+ { value: 'none', label: 'Muted', line: 'No notifications from this channel.', current: 'Muted' },
16
+ ];
17
+ export default function NotificationMenuExample() {
18
+ var _a;
19
+ var _b = useState('all'), pref = _b[0], setPref = _b[1];
20
+ var _c = useState(false), saving = _c[0], setSaving = _c[1];
21
+ var _d = useState(null), anchor = _d[0], setAnchor = _d[1];
22
+ var _e = useState(false), open = _e[0], setOpen = _e[1];
23
+ var timer = useRef();
24
+ var toastIds = useRef([]);
25
+ var current = (_a = choices.find(function (c) { return c.value === pref; })) !== null && _a !== void 0 ? _a : choices[0];
26
+ // On unmount it stops the request and closes the toast it opened.
27
+ useEffect(function () { return function () {
28
+ clearTimeout(timer.current);
29
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
30
+ toastIds.current = [];
31
+ }; }, []);
32
+ function toggle(anchorEl) {
33
+ if (saving)
34
+ return;
35
+ setAnchor(anchorEl);
36
+ setOpen(function (o) { return !o; });
37
+ }
38
+ // Saves at once and shows nothing when it works: the bell already shows the new value.
39
+ // The menu is gone by now, so a failure says so in a toast, and the bell goes back.
40
+ function choose(next) {
41
+ var previous = pref;
42
+ setOpen(false);
43
+ if (next === previous)
44
+ return;
45
+ setPref(next);
46
+ setSaving(true);
47
+ // Stands in for the request to the server. 'Muted' never saves, as if the connection were down.
48
+ timer.current = setTimeout(function () {
49
+ setSaving(false);
50
+ if (next === 'none') {
51
+ setPref(previous);
52
+ toastIds.current.push(toast({ type: 'error', message: 'Could not save your notification setting. Try again.' }));
53
+ }
54
+ }, 900);
55
+ }
56
+ return (<Center width="page">
57
+ {/* A real app mounts one Toaster near its root. */}
58
+ <Toaster />
59
+ <Stack gap="large">
60
+ <Cluster justify="between">
61
+ <Heading level={1} size="h5">Design team</Heading>
62
+ <Tooltip title={current.current}>
63
+ <IconButton color={pref === 'none' ? 'secondary' : 'iconOnly'} state={open ? 'selected' : 'enabled'} size="small" iconName={pref === 'none' ? 'BellOff' : 'Bell'} ariaLabel={"Notifications: ".concat(current.current)} aria-haspopup="menu" aria-expanded={open} aria-busy={saving} onClick={function (e) { return toggle(e.currentTarget); }}/>
64
+ </Tooltip>
65
+ </Cluster>
66
+ <Paragraph tone="secondary" size="body2" measure="none">Ben Carter: The press kit is in the shared folder.</Paragraph>
67
+ </Stack>
68
+ <Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
69
+ <Menu navigable aria-label="Notifications" width={260}>
70
+ {choices.map(function (c) { return (<MenuItem key={c.value} size="small" label={c.label} secondLabel={c.line} isSelected={c.value === pref} role="menuitemradio" onClick={function () { return choose(c.value); }}/>); })}
71
+ </Menu>
72
+ </Popover>
73
+ </Center>);
74
+ }
@@ -0,0 +1,135 @@
1
+ # Notification setting
2
+
3
+ A person chooses how much a channel or a thread notifies them.
4
+
5
+ ## Do
6
+
7
+ - Use an `IconButton` with `iconName="Bell"`, and `BellOff` when the channel is muted.
8
+ - Say the current value in the button's `ariaLabel`: 'Notifications: All messages'. Show it in a `Tooltip` too.
9
+ - Open a navigable menu of three choices: `<Popover returnFocus>` around `<Menu navigable aria-label="Notifications">`.
10
+ - Give each choice a `secondLabel` of one line: 'All Messages', then 'Every message in this channel.'
11
+ - Give each item `role="menuitemradio"` and mark the current choice with `isSelected`, which sets `aria-checked`.
12
+ - Save as soon as a choice is made, as the rule 'A setting saves in place, or with one Save Button' says. Close the menu and show nothing when it works.
13
+ - Set `aria-busy` on the bell while the request runs.
14
+ - Put the bell back to its old value when the save fails, and show an error toast: 'Could not save your notification setting. Try again.' This is the exception in the rule 'A setting saves in place, or with one Save Button': a setting chosen from a menu shows a failed save in a toast, because the menu closes.
15
+ - Dismiss the toast when the example goes away.
16
+
17
+ ## Don't
18
+
19
+ - Do not add a Save Button to the menu.
20
+ - Do not show a toast when the save works.
21
+ - Do not leave the bell on the new value when the save failed.
22
+ - Do not show a failure inside the menu. It has already closed.
23
+ - Do not use only the icon to say muted. The button's name says it too.
24
+
25
+ ## Example: Bell with a menu
26
+
27
+ Uses: `Center`, `Cluster`, `Heading`, `IconButton`, `Menu`, `MenuItem`, `Paragraph`, `Popover`, `Stack`, `Toaster`, `Tooltip`, `dismissToast`, `toast`
28
+
29
+ ```tsx
30
+ 'use client';
31
+ import { useEffect, useRef, useState } from 'react';
32
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
33
+ import Heading from 'oneslash-design-system/components/heading';
34
+ import Paragraph from 'oneslash-design-system/components/paragraph';
35
+ import IconButton from 'oneslash-design-system/components/iconButton';
36
+ import Tooltip from 'oneslash-design-system/components/tooltip';
37
+ import Popover from 'oneslash-design-system/components/popover';
38
+ import Menu from 'oneslash-design-system/components/menu';
39
+ import MenuItem from 'oneslash-design-system/components/menuItem';
40
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
41
+
42
+ type Pref = 'all' | 'mentions' | 'none';
43
+
44
+ const choices: { value: Pref; label: string; line: string; current: string }[] = [
45
+ { value: 'all', label: 'All Messages', line: 'Every message in this channel.', current: 'All messages' },
46
+ { value: 'mentions', label: 'Mentions Only', line: 'Only when someone mentions you.', current: 'Mentions only' },
47
+ { value: 'none', label: 'Muted', line: 'No notifications from this channel.', current: 'Muted' },
48
+ ];
49
+
50
+ export default function NotificationMenuExample() {
51
+ const [pref, setPref] = useState<Pref>('all');
52
+ const [saving, setSaving] = useState(false);
53
+ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
54
+ const [open, setOpen] = useState(false);
55
+ const timer = useRef<ReturnType<typeof setTimeout>>();
56
+ const toastIds = useRef<string[]>([]);
57
+ const current = choices.find((c) => c.value === pref) ?? choices[0];
58
+
59
+ // On unmount it stops the request and closes the toast it opened.
60
+ useEffect(() => () => {
61
+ clearTimeout(timer.current);
62
+ toastIds.current.forEach((id) => dismissToast(id));
63
+ toastIds.current = [];
64
+ }, []);
65
+
66
+ function toggle(anchorEl: HTMLElement) {
67
+ if (saving) return;
68
+ setAnchor(anchorEl);
69
+ setOpen((o) => !o);
70
+ }
71
+
72
+ // Saves at once and shows nothing when it works: the bell already shows the new value.
73
+ // The menu is gone by now, so a failure says so in a toast, and the bell goes back.
74
+ function choose(next: Pref) {
75
+ const previous = pref;
76
+ setOpen(false);
77
+ if (next === previous) return;
78
+ setPref(next);
79
+ setSaving(true);
80
+ // Stands in for the request to the server. 'Muted' never saves, as if the connection were down.
81
+ timer.current = setTimeout(() => {
82
+ setSaving(false);
83
+ if (next === 'none') {
84
+ setPref(previous);
85
+ toastIds.current.push(toast({ type: 'error', message: 'Could not save your notification setting. Try again.' }));
86
+ }
87
+ }, 900);
88
+ }
89
+
90
+ return (
91
+ <Center width="page">
92
+ {/* A real app mounts one Toaster near its root. */}
93
+ <Toaster />
94
+ <Stack gap="large">
95
+ <Cluster justify="between">
96
+ <Heading level={1} size="h5">Design team</Heading>
97
+ <Tooltip title={current.current}>
98
+ <IconButton
99
+ color={pref === 'none' ? 'secondary' : 'iconOnly'}
100
+ state={open ? 'selected' : 'enabled'}
101
+ size="small"
102
+ iconName={pref === 'none' ? 'BellOff' : 'Bell'}
103
+ ariaLabel={`Notifications: ${current.current}`}
104
+ aria-haspopup="menu"
105
+ aria-expanded={open}
106
+ aria-busy={saving}
107
+ onClick={(e: { currentTarget: HTMLElement }) => toggle(e.currentTarget)}
108
+ />
109
+ </Tooltip>
110
+ </Cluster>
111
+ <Paragraph tone="secondary" size="body2" measure="none">Ben Carter: The press kit is in the shared folder.</Paragraph>
112
+ </Stack>
113
+ <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
114
+ <Menu navigable aria-label="Notifications" width={260}>
115
+ {choices.map((c) => (
116
+ <MenuItem
117
+ key={c.value}
118
+ size="small"
119
+ label={c.label}
120
+ secondLabel={c.line}
121
+ isSelected={c.value === pref}
122
+ role="menuitemradio"
123
+ onClick={() => choose(c.value)}
124
+ />
125
+ ))}
126
+ </Menu>
127
+ </Popover>
128
+ </Center>
129
+ );
130
+ }
131
+ ```
132
+
133
+ ## Native
134
+
135
+ On Apple use a toolbar `Menu` with a `Picker` inside it, with the bell symbol changing to `bell.slash`. On Android use a dropdown menu with radio items.
@@ -2,8 +2,6 @@
2
2
 
3
3
  Another app, such as a CLI or an MCP client, asks to act for a person who is logged in, and the person must allow it.
4
4
 
5
- **Not built yet:** Scindo on the web turns on access to every workspace for the person, and shows its spinner on neither Button while the request runs. Commentify puts 'Allow' before 'Deny', writes its error in a red caption by hand, and says nothing about how to remove the access.
6
-
7
5
  ## Do
8
6
 
9
7
  - Name the app in a `Heading` with `level={1}`: 'Acme CLI wants to connect to Acme'.
@@ -229,5 +227,3 @@ export default function OAuthConsentWithScope() {
229
227
  );
230
228
  }
231
229
  ```
232
-
233
- Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function OnOffSettingsList(): import("react").JSX.Element;
@@ -0,0 +1,97 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ import { useEffect, useRef, useState } from 'react';
23
+ import Heading from '../../components/heading';
24
+ import Paragraph from '../../components/paragraph';
25
+ import Switch from '../../components/switch';
26
+ import SettingsSection from '../../components/settingsSection';
27
+ import { Center, Stack } from '../../components/layout';
28
+ var failedMessage = 'Could not save. Try again.';
29
+ var emailSettings = [
30
+ { id: 'mentions', label: 'Mentions', description: 'An email when someone mentions you.', on: true },
31
+ { id: 'replies', label: 'Replies', description: 'An email when someone replies to your message.', on: true },
32
+ { id: 'digest', label: 'Weekly digest', description: 'A summary of last week, every Monday.', on: false },
33
+ ];
34
+ // Stands in for a connection that is down: this one never saves.
35
+ var appSettings = [
36
+ { id: 'slack', label: 'Slack digest', description: 'Post the weekly digest in #general.', on: false, fails: true },
37
+ { id: 'push', label: 'Push on your phone', description: 'Mentions and replies, while the app is closed.', on: true },
38
+ ];
39
+ var everySetting = __spreadArray(__spreadArray([], emailSettings, true), appSettings, true);
40
+ export default function OnOffSettingsList() {
41
+ var _a = useState(function () { return Object.fromEntries(everySetting.map(function (s) { return [s.id, s.on]; })); }), values = _a[0], setValues = _a[1];
42
+ var _b = useState({}), busy = _b[0], setBusy = _b[1];
43
+ // Opens on a failed save, as if the person just turned Slack digest on.
44
+ var _c = useState({ slack: failedMessage }), errors = _c[0], setErrors = _c[1];
45
+ var timers = useRef({});
46
+ // Stops every request if the example goes away before they end.
47
+ useEffect(function () { return function () { return Object.values(timers.current).forEach(clearTimeout); }; }, []);
48
+ // Saves as soon as it changes. Nothing shows when it works. When it fails, the switch goes back and says why.
49
+ function handleChange(setting, next) {
50
+ setErrors(function (current) {
51
+ var _a;
52
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = '', _a)));
53
+ });
54
+ setBusy(function (current) {
55
+ var _a;
56
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = true, _a)));
57
+ });
58
+ setValues(function (current) {
59
+ var _a;
60
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = next, _a)));
61
+ });
62
+ // Stands in for the request to the server.
63
+ timers.current[setting.id] = setTimeout(function () {
64
+ setBusy(function (current) {
65
+ var _a;
66
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = false, _a)));
67
+ });
68
+ if (setting.fails) {
69
+ setValues(function (current) {
70
+ var _a;
71
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = !next, _a)));
72
+ });
73
+ setErrors(function (current) {
74
+ var _a;
75
+ return (__assign(__assign({}, current), (_a = {}, _a[setting.id] = failedMessage, _a)));
76
+ });
77
+ }
78
+ }, 900);
79
+ }
80
+ function renderSwitch(setting) {
81
+ return (<Switch key={setting.id} id={"on-off-settings-".concat(setting.id)} label={setting.label} description={setting.description} checked={values[setting.id]} busy={Boolean(busy[setting.id])} error={errors[setting.id] || undefined} onChange={function (next) { return handleChange(setting, next); }}/>);
82
+ }
83
+ return (<Center width="page">
84
+ <Stack gap="xlarge">
85
+ <Stack gap="small">
86
+ <Heading level={1} size="h5">Notifications</Heading>
87
+ <Paragraph tone="secondary" size="body2" measure="none">Each switch saves as soon as you change it.</Paragraph>
88
+ </Stack>
89
+ <SettingsSection title="Email" description="Sent to dana@acme.example.">
90
+ {emailSettings.map(renderSwitch)}
91
+ </SettingsSection>
92
+ <SettingsSection title="Apps" description="Where else Acme tells you.">
93
+ {appSettings.map(renderSwitch)}
94
+ </SettingsSection>
95
+ </Stack>
96
+ </Center>);
97
+ }
@@ -0,0 +1,116 @@
1
+ # On and off settings
2
+
3
+ A person turns things on and off, such as which notifications they get.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A setting saves in place, or with one Save Button'. Every `Switch` saves as soon as it changes, and the page has no Save Button.
8
+ - Give each `Switch` a visible `label` and a `description` that says what happens when it is on.
9
+ - Group the switches in `SettingsSection`s with a title and one line under it.
10
+ - Set `busy` on the switch while its request runs. It keeps its position and ignores presses. Show nothing when the save works.
11
+ - Put the switch back to its old value when the save fails, and set `error` to a short line: 'Could not save. Try again.'
12
+ - Clear the `error` when the person presses the switch again.
13
+ - Use a `Checkbox` for an on/off choice only inside a form that has a Save Button, such as a consent line above a Submit Button.
14
+ - Give each switch a unique `id`.
15
+
16
+ ## Don't
17
+
18
+ - Do not use a `Checkbox` for an on/off setting that saves on change. Use a `Switch`.
19
+ - Do not add a Save Button to a list of switches.
20
+ - Do not show a toast when a switch saves.
21
+ - Do not leave a switch in its new position when the save failed.
22
+ - Do not put 'On' or 'Off' in the label. The switch shows it.
23
+
24
+ ## Example: A list of switches
25
+
26
+ Uses: `Center`, `Heading`, `Paragraph`, `SettingsSection`, `Stack`, `Switch`
27
+
28
+ ```tsx
29
+ 'use client';
30
+ import { useEffect, useRef, useState } from 'react';
31
+ import Heading from 'oneslash-design-system/components/heading';
32
+ import Paragraph from 'oneslash-design-system/components/paragraph';
33
+ import Switch from 'oneslash-design-system/components/switch';
34
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
35
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
36
+
37
+ type Setting = { id: string; label: string; description: string; on: boolean; fails?: boolean };
38
+
39
+ const failedMessage = 'Could not save. Try again.';
40
+
41
+ const emailSettings: Setting[] = [
42
+ { id: 'mentions', label: 'Mentions', description: 'An email when someone mentions you.', on: true },
43
+ { id: 'replies', label: 'Replies', description: 'An email when someone replies to your message.', on: true },
44
+ { id: 'digest', label: 'Weekly digest', description: 'A summary of last week, every Monday.', on: false },
45
+ ];
46
+
47
+ // Stands in for a connection that is down: this one never saves.
48
+ const appSettings: Setting[] = [
49
+ { id: 'slack', label: 'Slack digest', description: 'Post the weekly digest in #general.', on: false, fails: true },
50
+ { id: 'push', label: 'Push on your phone', description: 'Mentions and replies, while the app is closed.', on: true },
51
+ ];
52
+
53
+ const everySetting = [...emailSettings, ...appSettings];
54
+
55
+ export default function OnOffSettingsList() {
56
+ const [values, setValues] = useState<Record<string, boolean>>(() => Object.fromEntries(everySetting.map((s) => [s.id, s.on])));
57
+ const [busy, setBusy] = useState<Record<string, boolean>>({});
58
+ // Opens on a failed save, as if the person just turned Slack digest on.
59
+ const [errors, setErrors] = useState<Record<string, string>>({ slack: failedMessage });
60
+ const timers = useRef<Record<string, ReturnType<typeof setTimeout>>>({});
61
+
62
+ // Stops every request if the example goes away before they end.
63
+ useEffect(() => () => Object.values(timers.current).forEach(clearTimeout), []);
64
+
65
+ // Saves as soon as it changes. Nothing shows when it works. When it fails, the switch goes back and says why.
66
+ function handleChange(setting: Setting, next: boolean) {
67
+ setErrors((current) => ({ ...current, [setting.id]: '' }));
68
+ setBusy((current) => ({ ...current, [setting.id]: true }));
69
+ setValues((current) => ({ ...current, [setting.id]: next }));
70
+ // Stands in for the request to the server.
71
+ timers.current[setting.id] = setTimeout(() => {
72
+ setBusy((current) => ({ ...current, [setting.id]: false }));
73
+ if (setting.fails) {
74
+ setValues((current) => ({ ...current, [setting.id]: !next }));
75
+ setErrors((current) => ({ ...current, [setting.id]: failedMessage }));
76
+ }
77
+ }, 900);
78
+ }
79
+
80
+ function renderSwitch(setting: Setting) {
81
+ return (
82
+ <Switch
83
+ key={setting.id}
84
+ id={`on-off-settings-${setting.id}`}
85
+ label={setting.label}
86
+ description={setting.description}
87
+ checked={values[setting.id]}
88
+ busy={Boolean(busy[setting.id])}
89
+ error={errors[setting.id] || undefined}
90
+ onChange={(next) => handleChange(setting, next)}
91
+ />
92
+ );
93
+ }
94
+
95
+ return (
96
+ <Center width="page">
97
+ <Stack gap="xlarge">
98
+ <Stack gap="small">
99
+ <Heading level={1} size="h5">Notifications</Heading>
100
+ <Paragraph tone="secondary" size="body2" measure="none">Each switch saves as soon as you change it.</Paragraph>
101
+ </Stack>
102
+ <SettingsSection title="Email" description="Sent to dana@acme.example.">
103
+ {emailSettings.map(renderSwitch)}
104
+ </SettingsSection>
105
+ <SettingsSection title="Apps" description="Where else Acme tells you.">
106
+ {appSettings.map(renderSwitch)}
107
+ </SettingsSection>
108
+ </Stack>
109
+ </Center>
110
+ );
111
+ }
112
+ ```
113
+
114
+ ## Native
115
+
116
+ On Apple use a `Toggle` in a grouped `Form`, and on Android a `Switch`. Both save as they change.
@@ -0,0 +1 @@
1
+ export default function OverflowMenuInAHeader(): import("react").JSX.Element;
@@ -0,0 +1,128 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Modal from '../../components/modal';
5
+ import Surface from '../../components/surface';
6
+ import Heading from '../../components/heading';
7
+ import Paragraph from '../../components/paragraph';
8
+ import List from '../../components/list';
9
+ import Button from '../../components/button';
10
+ import IconButton from '../../components/iconButton';
11
+ import Tooltip from '../../components/tooltip';
12
+ import Popover from '../../components/popover';
13
+ import Menu from '../../components/menu';
14
+ import MenuItem from '../../components/menuItem';
15
+ import Line from '../../components/line';
16
+ import { Center, Cluster, Stack } from '../../components/layout';
17
+ var otherReports = ['Budget review', 'Hiring plan', 'Roadmap'];
18
+ export default function OverflowMenuInAHeader() {
19
+ var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
20
+ var _b = useState(false), open = _b[0], setOpen = _b[1];
21
+ var _c = useState(false), confirming = _c[0], setConfirming = _c[1];
22
+ var _d = useState(false), deleting = _d[0], setDeleting = _d[1];
23
+ var _e = useState(false), deleted = _e[0], setDeleted = _e[1];
24
+ var timer = useRef();
25
+ var toastIds = useRef([]);
26
+ var moreButton = useRef(null);
27
+ // Where focus goes after the next render, once the element it goes to is on screen.
28
+ var focusNext = useRef();
29
+ // The clipboard answers later; by then the example may be gone.
30
+ var mounted = useRef(true);
31
+ // On unmount it stops the request and closes every toast it opened.
32
+ useEffect(function () { return function () {
33
+ mounted.current = false;
34
+ clearTimeout(timer.current);
35
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
36
+ toastIds.current = [];
37
+ }; }, []);
38
+ useEffect(function () {
39
+ var move = focusNext.current;
40
+ focusNext.current = undefined;
41
+ move === null || move === void 0 ? void 0 : move();
42
+ });
43
+ function toggle(anchorEl) {
44
+ setAnchor(anchorEl);
45
+ setOpen(function (o) { return !o; });
46
+ }
47
+ // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.
48
+ function duplicate() {
49
+ setOpen(false);
50
+ toastIds.current.push(toast({ type: 'success', message: 'Q3 report duplicated.' }));
51
+ }
52
+ // The menu is gone, so the result shows in a toast. A clipboard that is missing or refuses says to copy by hand.
53
+ function copyLink() {
54
+ setOpen(false);
55
+ var link = 'https://example.com/reports/q3';
56
+ var failed = function () {
57
+ if (!mounted.current)
58
+ return;
59
+ toastIds.current.push(toast({ type: 'error', message: "Copying is blocked here. Select the link and copy it: ".concat(link) }));
60
+ };
61
+ if (!navigator.clipboard)
62
+ return failed();
63
+ navigator.clipboard.writeText(link).then(function () {
64
+ if (!mounted.current)
65
+ return;
66
+ toastIds.current.push(toast({ type: 'success', message: 'Link copied.' }));
67
+ }, failed);
68
+ }
69
+ function askToDelete() {
70
+ setOpen(false);
71
+ setConfirming(true);
72
+ }
73
+ // The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.
74
+ function keepReport() {
75
+ if (deleting)
76
+ return;
77
+ setConfirming(false);
78
+ focusNext.current = function () { var _a; return (_a = moreButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
79
+ }
80
+ function confirmDelete() {
81
+ if (deleting)
82
+ return;
83
+ setDeleting(true);
84
+ // Stands in for the request to the server.
85
+ timer.current = setTimeout(function () {
86
+ setDeleting(false);
87
+ setConfirming(false);
88
+ setDeleted(true);
89
+ toastIds.current.push(toast({ type: 'success', message: 'Q3 report deleted.' }));
90
+ }, 1200);
91
+ }
92
+ return (<Center width="page">
93
+ {/* A real app mounts one Toaster near its root. */}
94
+ <Toaster />
95
+ {deleted ? (
96
+ // A real app goes back to the list of reports here.
97
+ <Stack gap="large">
98
+ <Heading level={1} size="h5">Reports</Heading>
99
+ <Surface padding="large">
100
+ <List items={otherReports} size="body1"/>
101
+ </Surface>
102
+ </Stack>) : (<Stack gap="medium">
103
+ <Cluster justify="between">
104
+ <Heading level={1} size="h5">Q3 report</Heading>
105
+ <Tooltip title="More">
106
+ <IconButton ref={moreButton} color="iconOnly" state={open ? 'selected' : 'enabled'} size="small" iconName="Ellipsis" ariaLabel="More actions for Q3 report" aria-haspopup="menu" aria-expanded={open} onClick={function (e) { return toggle(e.currentTarget); }}/>
107
+ </Tooltip>
108
+ </Cluster>
109
+ <Paragraph tone="secondary" size="body2" measure="none">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>
110
+ </Stack>)}
111
+ <Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
112
+ <Menu navigable aria-label="Actions for Q3 report" width={200}>
113
+ <MenuItem size="small" iconName="Copy" label="Duplicate" onClick={duplicate}/>
114
+ <MenuItem size="small" iconName="Link" label="Copy Link" onClick={copyLink}/>
115
+ <Line />
116
+ {/* Delete is last, and danger. */}
117
+ <MenuItem size="small" color="danger" iconName="Trash2" label="Delete" onClick={askToDelete}/>
118
+ </Menu>
119
+ </Popover>
120
+ {/* The page is not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}
121
+ <Modal isOpen={confirming} size="small" title="Delete Report" onClose={keepReport} actions={<>
122
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepReport}/>
123
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete}/>
124
+ </>}>
125
+ <Paragraph measure="none">This deletes &apos;Q3 report&apos; and its 12 tasks.</Paragraph>
126
+ </Modal>
127
+ </Center>);
128
+ }
@@ -0,0 +1 @@
1
+ export default function OverflowMenuOnARow(): import("react").JSX.Element;