oneslash-design-system 2.17.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 (185) hide show
  1. package/README.md +2 -2
  2. package/dist/DESIGN.md +30 -14
  3. package/dist/cases/accept-invite.md +1 -5
  4. package/dist/cases/account-menu/menu.d.ts +1 -0
  5. package/dist/cases/account-menu/menu.jsx +99 -0
  6. package/dist/cases/account-menu.md +164 -0
  7. package/dist/cases/agent-asks-before-risky-action.md +0 -4
  8. package/dist/cases/agent-cancels-when-unanswered.md +0 -4
  9. package/dist/cases/agent-options.md +0 -4
  10. package/dist/cases/agent-pending-reply.md +0 -4
  11. package/dist/cases/agent-plan-proposal.md +0 -4
  12. package/dist/cases/agent-question.md +0 -4
  13. package/dist/cases/agent-refuses-clearly.md +0 -4
  14. package/dist/cases/agent-says-what-it-is.md +0 -2
  15. package/dist/cases/agent-settings/form.d.ts +1 -0
  16. package/dist/cases/agent-settings/form.jsx +164 -0
  17. package/dist/cases/agent-settings.md +259 -0
  18. package/dist/cases/agent-shows-progress.md +0 -2
  19. package/dist/cases/agent-shows-sources.md +0 -2
  20. package/dist/cases/api-keys/list.d.ts +1 -0
  21. package/dist/cases/api-keys/list.jsx +162 -0
  22. package/dist/cases/api-keys.md +229 -0
  23. package/dist/cases/artifact-card.md +0 -4
  24. package/dist/cases/auth-gate-loading.md +0 -4
  25. package/dist/cases/check-your-email.md +0 -4
  26. package/dist/cases/collapsible-search/popover.d.ts +1 -0
  27. package/dist/cases/collapsible-search/popover.jsx +74 -0
  28. package/dist/cases/collapsible-search.md +143 -0
  29. package/dist/cases/composer-limit.md +0 -4
  30. package/dist/cases/confirm-destructive-action.md +0 -4
  31. package/dist/cases/confirm-dialogs.md +0 -4
  32. package/dist/cases/conversation-starters.md +0 -4
  33. package/dist/cases/create-modal.md +0 -4
  34. package/dist/cases/danger-zone/collapsed.d.ts +1 -0
  35. package/dist/cases/danger-zone/collapsed.jsx +75 -0
  36. package/dist/cases/danger-zone/shown.d.ts +1 -0
  37. package/dist/cases/danger-zone/shown.jsx +95 -0
  38. package/dist/cases/danger-zone.md +263 -0
  39. package/dist/cases/device-login.md +0 -4
  40. package/dist/cases/email-confirmed.md +0 -4
  41. package/dist/cases/empty-list.md +0 -4
  42. package/dist/cases/empty-lists.md +0 -4
  43. package/dist/cases/empty-not-set-up.md +0 -4
  44. package/dist/cases/empty-search.md +0 -4
  45. package/dist/cases/error-page.md +0 -4
  46. package/dist/cases/feedback-form.md +0 -4
  47. package/dist/cases/filter-menu/presets.d.ts +1 -0
  48. package/dist/cases/filter-menu/presets.jsx +53 -0
  49. package/dist/cases/filter-menu/with-clear.d.ts +1 -0
  50. package/dist/cases/filter-menu/with-clear.jsx +56 -0
  51. package/dist/cases/filter-menu.md +204 -0
  52. package/dist/cases/forgot-password.md +0 -4
  53. package/dist/cases/form-errors.md +0 -4
  54. package/dist/cases/import-checklist.md +0 -4
  55. package/dist/cases/inline-form-feedback.md +0 -4
  56. package/dist/cases/integrations-list/nested.d.ts +1 -0
  57. package/dist/cases/integrations-list/nested.jsx +164 -0
  58. package/dist/cases/integrations-list/rows.d.ts +1 -0
  59. package/dist/cases/integrations-list/rows.jsx +134 -0
  60. package/dist/cases/integrations-list.md +379 -0
  61. package/dist/cases/invite-member.md +0 -4
  62. package/dist/cases/load-failure.md +0 -4
  63. package/dist/cases/log-out-confirm.md +0 -4
  64. package/dist/cases/login-page.md +0 -4
  65. package/dist/cases/members-list/rows.d.ts +1 -0
  66. package/dist/cases/members-list/rows.jsx +318 -0
  67. package/dist/cases/members-list/table.d.ts +1 -0
  68. package/dist/cases/members-list/table.jsx +351 -0
  69. package/dist/cases/members-list.md +799 -0
  70. package/dist/cases/mention-list.md +0 -4
  71. package/dist/cases/message-actions.md +0 -4
  72. package/dist/cases/message-attachments.md +0 -4
  73. package/dist/cases/message-composer.md +0 -4
  74. package/dist/cases/message-edit.md +0 -4
  75. package/dist/cases/message-reactions.md +0 -4
  76. package/dist/cases/message-row.md +0 -4
  77. package/dist/cases/not-found-page.md +0 -4
  78. package/dist/cases/notification-menu/menu.d.ts +1 -0
  79. package/dist/cases/notification-menu/menu.jsx +74 -0
  80. package/dist/cases/notification-menu.md +135 -0
  81. package/dist/cases/oauth-consent.md +0 -4
  82. package/dist/cases/on-off-settings/list.d.ts +1 -0
  83. package/dist/cases/on-off-settings/list.jsx +97 -0
  84. package/dist/cases/on-off-settings.md +116 -0
  85. package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
  86. package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
  87. package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
  88. package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
  89. package/dist/cases/overflow-menu.md +410 -0
  90. package/dist/cases/profile-form/form.d.ts +1 -0
  91. package/dist/cases/profile-form/form.jsx +153 -0
  92. package/dist/cases/profile-form.md +236 -0
  93. package/dist/cases/quick-switcher/modal.d.ts +1 -0
  94. package/dist/cases/quick-switcher/modal.jsx +114 -0
  95. package/dist/cases/quick-switcher.md +205 -0
  96. package/dist/cases/range-switch/segmented.d.ts +1 -0
  97. package/dist/cases/range-switch/segmented.jsx +30 -0
  98. package/dist/cases/range-switch.md +67 -0
  99. package/dist/cases/rename.md +0 -4
  100. package/dist/cases/reply-feedback.md +0 -4
  101. package/dist/cases/reply-sources.md +0 -4
  102. package/dist/cases/route-loading.md +0 -2
  103. package/dist/cases/scope-picker/menu.d.ts +1 -0
  104. package/dist/cases/scope-picker/menu.jsx +47 -0
  105. package/dist/cases/scope-picker.md +97 -0
  106. package/dist/cases/set-new-password.md +0 -4
  107. package/dist/cases/settings-page/side-nav.d.ts +1 -0
  108. package/dist/cases/settings-page/side-nav.jsx +171 -0
  109. package/dist/cases/settings-page/top-tabs.d.ts +1 -0
  110. package/dist/cases/settings-page/top-tabs.jsx +129 -0
  111. package/dist/cases/settings-page.md +378 -0
  112. package/dist/cases/settings-save.md +35 -0
  113. package/dist/cases/sign-up-page.md +1 -5
  114. package/dist/cases/slash-command-list.md +0 -4
  115. package/dist/cases/success-feedback.md +0 -4
  116. package/dist/cases/tag-filter/tags.d.ts +1 -0
  117. package/dist/cases/tag-filter/tags.jsx +226 -0
  118. package/dist/cases/tag-filter.md +298 -0
  119. package/dist/cases/type-to-confirm.md +0 -4
  120. package/dist/cases/typing-and-status.md +0 -4
  121. package/dist/cases/unsaved-changes-guard.md +0 -4
  122. package/dist/cases/upgrade-prompt.md +0 -4
  123. package/dist/cases.json +1038 -263
  124. package/dist/components/alert.d.ts +3 -1
  125. package/dist/components/alert.jsx +2 -2
  126. package/dist/components/button.jsx +5 -2
  127. package/dist/components/checkBox.d.ts +5 -1
  128. package/dist/components/checkBox.jsx +2 -2
  129. package/dist/components/copyField.d.ts +20 -0
  130. package/dist/components/copyField.jsx +99 -0
  131. package/dist/components/formField.d.ts +34 -0
  132. package/dist/components/formField.jsx +28 -0
  133. package/dist/components/heading.d.ts +3 -1
  134. package/dist/components/heading.jsx +2 -2
  135. package/dist/components/menu.jsx +2 -2
  136. package/dist/components/menuItem.d.ts +4 -2
  137. package/dist/components/menuItem.jsx +3 -3
  138. package/dist/components/navigation.d.ts +9 -1
  139. package/dist/components/navigation.jsx +15 -3
  140. package/dist/components/radioGroup.d.ts +5 -1
  141. package/dist/components/radioGroup.jsx +2 -2
  142. package/dist/components/segmentedControl.d.ts +22 -0
  143. package/dist/components/segmentedControl.jsx +54 -0
  144. package/dist/components/select.d.ts +5 -1
  145. package/dist/components/select.jsx +2 -2
  146. package/dist/components/settingsSection.d.ts +31 -0
  147. package/dist/components/settingsSection.jsx +58 -0
  148. package/dist/components/slidingIndicator.d.ts +50 -0
  149. package/dist/components/slidingIndicator.jsx +102 -0
  150. package/dist/components/switch.d.ts +25 -0
  151. package/dist/components/switch.jsx +55 -0
  152. package/dist/components/tab.jsx +5 -11
  153. package/dist/components/tabsContainer.jsx +5 -67
  154. package/dist/components/textField.d.ts +12 -2
  155. package/dist/components/textField.jsx +11 -4
  156. package/dist/components/textarea.d.ts +5 -1
  157. package/dist/components/textarea.jsx +3 -3
  158. package/dist/components/useHotkey.d.ts +7 -0
  159. package/dist/components/useHotkey.js +24 -0
  160. package/dist/index.d.ts +6 -0
  161. package/dist/index.js +6 -0
  162. package/dist/internal/copyField.d.ts +5 -0
  163. package/dist/internal/copyField.js +61 -0
  164. package/dist/internal/hotkey.d.ts +16 -0
  165. package/dist/internal/hotkey.js +20 -0
  166. package/dist/internal/switch.d.ts +5 -0
  167. package/dist/internal/switch.js +9 -0
  168. package/dist/native-mapping.json +30 -0
  169. package/dist/stories/Cases.generated.stories.d.ts +23 -0
  170. package/dist/stories/Cases.generated.stories.jsx +46 -0
  171. package/dist/stories/CopyField.stories.d.ts +11 -0
  172. package/dist/stories/CopyField.stories.jsx +65 -0
  173. package/dist/stories/FormField.stories.d.ts +6 -0
  174. package/dist/stories/FormField.stories.jsx +44 -0
  175. package/dist/stories/Navigation.stories.d.ts +1 -0
  176. package/dist/stories/Navigation.stories.jsx +17 -1
  177. package/dist/stories/SegmentedControl.stories.d.ts +8 -0
  178. package/dist/stories/SegmentedControl.stories.jsx +33 -0
  179. package/dist/stories/SettingsSection.stories.d.ts +11 -0
  180. package/dist/stories/SettingsSection.stories.jsx +64 -0
  181. package/dist/stories/Switch.stories.d.ts +14 -0
  182. package/dist/stories/Switch.stories.jsx +87 -0
  183. package/dist/stories/TextField.stories.d.ts +1 -0
  184. package/dist/stories/TextField.stories.jsx +13 -0
  185. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ export default function DangerZoneShown(): import("react").JSX.Element;
@@ -0,0 +1,95 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Modal from '../../components/modal';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import TextField from '../../components/textField';
7
+ import Button from '../../components/button';
8
+ import SettingsSection from '../../components/settingsSection';
9
+ import { Center, Cluster, Stack } from '../../components/layout';
10
+ // A workspace has a name, so the person types it.
11
+ var workspaceName = 'Acme';
12
+ export default function DangerZoneShown() {
13
+ var _a = useState(false), leaving = _a[0], setLeaving = _a[1];
14
+ var _b = useState(false), leaveOpen = _b[0], setLeaveOpen = _b[1];
15
+ var _c = useState(false), left = _c[0], setLeft = _c[1];
16
+ var _d = useState(false), confirming = _d[0], setConfirming = _d[1];
17
+ var _e = useState(''), typed = _e[0], setTyped = _e[1];
18
+ var _f = useState(false), deleting = _f[0], setDeleting = _f[1];
19
+ var _g = useState(false), deleted = _g[0], setDeleted = _g[1];
20
+ var timer = useRef();
21
+ // Stops the request if the example goes away before it ends.
22
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
23
+ // An exact match, with case. Pasting the name is fine.
24
+ var matches = typed === workspaceName;
25
+ // Escape, a click outside and Cancel all close it, except while the request runs.
26
+ function handleLeaveClose() {
27
+ if (leaving)
28
+ return;
29
+ setLeaveOpen(false);
30
+ }
31
+ function handleLeave() {
32
+ if (leaving)
33
+ return;
34
+ setLeaving(true);
35
+ // Stands in for the request to the server.
36
+ timer.current = setTimeout(function () {
37
+ setLeaving(false);
38
+ setLeaveOpen(false);
39
+ setLeft(true);
40
+ }, 1200);
41
+ }
42
+ function handleCancelDelete() {
43
+ setConfirming(false);
44
+ setTyped('');
45
+ }
46
+ function handleDelete() {
47
+ if (deleting || !matches)
48
+ return;
49
+ setDeleting(true);
50
+ timer.current = setTimeout(function () {
51
+ setDeleting(false);
52
+ setDeleted(true);
53
+ }, 1200);
54
+ }
55
+ // The workspace is gone, or the person is out of it, so the page that showed it is gone too.
56
+ if (left || deleted) {
57
+ return (<Center fill>
58
+ <Heading level={1} size="h5">{deleted ? "".concat(workspaceName, " is deleted") : "You left ".concat(workspaceName)}</Heading>
59
+ <Paragraph tone="secondary" measure="none">{deleted ? 'Everyone in it was told.' : 'An owner can invite you again.'}</Paragraph>
60
+ </Center>);
61
+ }
62
+ return (<Center width="page">
63
+ <Stack gap="xlarge">
64
+ <Stack gap="small">
65
+ <Heading level={1} size="h5">Danger zone</Heading>
66
+ <Paragraph tone="secondary" size="body2" measure="none">Leave or delete the Acme workspace.</Paragraph>
67
+ </Stack>
68
+ <SettingsSection tone="danger" title="Leave workspace" description="You lose access to Acme.">
69
+ <Paragraph size="body2" measure="none">Your messages and tasks stay in Acme. An owner can invite you again.</Paragraph>
70
+ <Cluster>
71
+ <Button size="small" type="secondary" state="enabled" label="Leave Workspace" onClickButton={function () { return setLeaveOpen(true); }}/>
72
+ </Cluster>
73
+ </SettingsSection>
74
+ <SettingsSection tone="danger" title="Delete workspace" description="This cannot be undone.">
75
+ <Paragraph size="body2" measure="none">This deletes Acme, its 128 messages, 42 tasks and 9 documents. Every member keeps their own account, and files exported earlier stay where they are.</Paragraph>
76
+ {confirming ? (<>
77
+ <TextField id="danger-zone-shown-name" label={"Type ".concat(workspaceName, " to confirm")} value={typed} disabled={deleting} onChange={function (e) { return setTyped(e.target.value); }}/>
78
+ <Cluster gap="small">
79
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancelDelete}/>
80
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Workspace" loading={deleting} onClickButton={handleDelete}/>
81
+ </Cluster>
82
+ </>) : (<Cluster>
83
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Workspace" onClickButton={function () { return setConfirming(true); }}/>
84
+ </Cluster>)}
85
+ </SettingsSection>
86
+ </Stack>
87
+ <Modal isOpen={leaveOpen} size="small" title="Leave Workspace" onClose={handleLeaveClose} actions={<>
88
+ <Button size="small" type="tertiary" state={leaving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleLeaveClose}/>
89
+ <Button size="small" type="primary" state="enabled" label="Leave" loading={leaving} onClickButton={handleLeave}/>
90
+ </>}>
91
+ <Paragraph measure="none">You will lose access to Acme.</Paragraph>
92
+ <Paragraph tone="secondary" size="body2" measure="none">Your messages and tasks stay in Acme. An owner can invite you again.</Paragraph>
93
+ </Modal>
94
+ </Center>);
95
+ }
@@ -0,0 +1,263 @@
1
+ # Danger zone
2
+
3
+ A settings page offers actions that are hard or impossible to undo, such as deleting an account or a workspace, or leaving one.
4
+
5
+ ## Do
6
+
7
+ - Put the actions in a `SettingsSection tone="danger"` titled 'Danger zone', or titled with the action, such as 'Delete workspace'. It is the last section on the page.
8
+ - Hide them behind a 'Show Danger Zone' Button when the page has more above it. Give the Button `aria-expanded`, and change its label to 'Hide Danger Zone' while they show. This label says what a press does next. It is not a status, so it may change.
9
+ - Say what is deleted and what is kept, above the action: 'Messages and tasks you shared stay with your team.'
10
+ - Delete an account or a workspace as the case 'Type to confirm' says: the field shows in place, 'Cancel' comes first, and the danger Button stays disabled until the text matches exactly.
11
+ - Type a fixed word such as DELETE for an account. Type the name for a workspace: 'Type Acme to confirm'.
12
+ - Leave a workspace with a plain confirm in a small Modal, as the rule 'A confirm says exactly what will happen' says. Name the action with the title's verb: the title is 'Leave Workspace' and the Button is 'Leave'.
13
+ - Give 'Leave' the plain primary color. Leaving destroys nothing: the workspace and its work stay.
14
+ - Show a page that says it is done when the account or workspace is gone, in place of the toast in the rule 'A confirm says exactly what will happen'. The page that showed it is gone too, and the person may be logged out.
15
+ - Mark the section with the danger color on the title and the hairline. `SettingsSection` does both.
16
+
17
+ ## Don't
18
+
19
+ - Do not put a danger zone above the settings that people use every day.
20
+ - Do not delete on the first click. Ask the person to type, or to confirm.
21
+ - Do not ask someone to type for leaving a workspace. A plain confirm is enough.
22
+ - Do not change the Button's label while it is loading, such as to 'Deleting…'.
23
+ - Do not hide what is kept. Say it before the person confirms.
24
+ - Do not use a native `details` element. Use a Button with `aria-expanded`.
25
+
26
+ ## Option: Hidden until asked for
27
+
28
+ Use when: The page has more above it, and most visits have no use for these actions.
29
+
30
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `SettingsSection`, `Stack`, `TextField`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { useEffect, useRef, useState } from 'react';
35
+ import Heading from 'oneslash-design-system/components/heading';
36
+ import Paragraph from 'oneslash-design-system/components/paragraph';
37
+ import TextField from 'oneslash-design-system/components/textField';
38
+ import Button from 'oneslash-design-system/components/button';
39
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
40
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
41
+
42
+ // An account has no name to type, so the person types a fixed word.
43
+ const word = 'DELETE';
44
+
45
+ export default function DangerZoneCollapsed() {
46
+ const [shown, setShown] = useState(false);
47
+ const [confirming, setConfirming] = useState(false);
48
+ const [typed, setTyped] = useState('');
49
+ const [deleting, setDeleting] = useState(false);
50
+ const [deleted, setDeleted] = useState(false);
51
+ const timer = useRef<ReturnType<typeof setTimeout>>();
52
+
53
+ // Stops the request if the example goes away before it ends.
54
+ useEffect(() => () => clearTimeout(timer.current), []);
55
+
56
+ // An exact match, with case. Pasting the word is fine.
57
+ const matches = typed === word;
58
+
59
+ function handleToggle() {
60
+ if (deleting) return;
61
+ setShown(!shown);
62
+ setConfirming(false);
63
+ setTyped('');
64
+ }
65
+
66
+ function handleCancel() {
67
+ setConfirming(false);
68
+ setTyped('');
69
+ }
70
+
71
+ function handleDelete() {
72
+ if (deleting || !matches) return;
73
+ setDeleting(true);
74
+ // Stands in for the request to the server.
75
+ timer.current = setTimeout(() => {
76
+ setDeleting(false);
77
+ setDeleted(true);
78
+ }, 1200);
79
+ }
80
+
81
+ // The account is gone, so the page that showed it is gone too.
82
+ if (deleted) {
83
+ return (
84
+ <Center fill>
85
+ <Heading level={1} size="h5">Your account is deleted</Heading>
86
+ <Paragraph tone="secondary" measure="none">We sent a note to dana@acme.example to say so.</Paragraph>
87
+ </Center>
88
+ );
89
+ }
90
+
91
+ return (
92
+ <Center width="page">
93
+ <Stack gap="xlarge">
94
+ <Heading level={1} size="h5">Account</Heading>
95
+ <SettingsSection title="Profile" description="Dana Lee, dana@acme.example.">
96
+ <Paragraph size="body2" measure="none">Your name and picture are in Profile Settings.</Paragraph>
97
+ </SettingsSection>
98
+ <SettingsSection tone="danger" title="Danger zone" description="These actions cannot be undone.">
99
+ <Cluster>
100
+ <Button
101
+ size="small"
102
+ type="textOnly"
103
+ state={deleting ? 'disabled' : 'enabled'}
104
+ label={shown ? 'Hide Danger Zone' : 'Show Danger Zone'}
105
+ aria-expanded={shown}
106
+ onClickButton={handleToggle}
107
+ />
108
+ </Cluster>
109
+ {shown && (
110
+ <Stack gap="medium">
111
+ <Paragraph size="body2" measure="none">This deletes your account and your private documents. Messages and tasks you shared stay with your team and show as &apos;Deleted user&apos;.</Paragraph>
112
+ {confirming ? (
113
+ <>
114
+ <TextField id="danger-zone-collapsed-word" label={`Type ${word} to confirm`} value={typed} disabled={deleting} onChange={(e) => setTyped(e.target.value)} />
115
+ <Cluster gap="small">
116
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel} />
117
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Account" loading={deleting} onClickButton={handleDelete} />
118
+ </Cluster>
119
+ </>
120
+ ) : (
121
+ <Cluster>
122
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Account" onClickButton={() => setConfirming(true)} />
123
+ </Cluster>
124
+ )}
125
+ </Stack>
126
+ )}
127
+ </SettingsSection>
128
+ </Stack>
129
+ </Center>
130
+ );
131
+ }
132
+ ```
133
+
134
+ ## Option: Shown on its own page
135
+
136
+ Use when: The page is about the one thing to delete or leave, such as a workspace.
137
+
138
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `TextField`
139
+
140
+ ```tsx
141
+ 'use client';
142
+ import { useEffect, useRef, useState } from 'react';
143
+ import Modal from 'oneslash-design-system/components/modal';
144
+ import Heading from 'oneslash-design-system/components/heading';
145
+ import Paragraph from 'oneslash-design-system/components/paragraph';
146
+ import TextField from 'oneslash-design-system/components/textField';
147
+ import Button from 'oneslash-design-system/components/button';
148
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
149
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
150
+
151
+ // A workspace has a name, so the person types it.
152
+ const workspaceName = 'Acme';
153
+
154
+ export default function DangerZoneShown() {
155
+ const [leaving, setLeaving] = useState(false);
156
+ const [leaveOpen, setLeaveOpen] = useState(false);
157
+ const [left, setLeft] = useState(false);
158
+ const [confirming, setConfirming] = useState(false);
159
+ const [typed, setTyped] = useState('');
160
+ const [deleting, setDeleting] = useState(false);
161
+ const [deleted, setDeleted] = useState(false);
162
+ const timer = useRef<ReturnType<typeof setTimeout>>();
163
+
164
+ // Stops the request if the example goes away before it ends.
165
+ useEffect(() => () => clearTimeout(timer.current), []);
166
+
167
+ // An exact match, with case. Pasting the name is fine.
168
+ const matches = typed === workspaceName;
169
+
170
+ // Escape, a click outside and Cancel all close it, except while the request runs.
171
+ function handleLeaveClose() {
172
+ if (leaving) return;
173
+ setLeaveOpen(false);
174
+ }
175
+
176
+ function handleLeave() {
177
+ if (leaving) return;
178
+ setLeaving(true);
179
+ // Stands in for the request to the server.
180
+ timer.current = setTimeout(() => {
181
+ setLeaving(false);
182
+ setLeaveOpen(false);
183
+ setLeft(true);
184
+ }, 1200);
185
+ }
186
+
187
+ function handleCancelDelete() {
188
+ setConfirming(false);
189
+ setTyped('');
190
+ }
191
+
192
+ function handleDelete() {
193
+ if (deleting || !matches) return;
194
+ setDeleting(true);
195
+ timer.current = setTimeout(() => {
196
+ setDeleting(false);
197
+ setDeleted(true);
198
+ }, 1200);
199
+ }
200
+
201
+ // The workspace is gone, or the person is out of it, so the page that showed it is gone too.
202
+ if (left || deleted) {
203
+ return (
204
+ <Center fill>
205
+ <Heading level={1} size="h5">{deleted ? `${workspaceName} is deleted` : `You left ${workspaceName}`}</Heading>
206
+ <Paragraph tone="secondary" measure="none">{deleted ? 'Everyone in it was told.' : 'An owner can invite you again.'}</Paragraph>
207
+ </Center>
208
+ );
209
+ }
210
+
211
+ return (
212
+ <Center width="page">
213
+ <Stack gap="xlarge">
214
+ <Stack gap="small">
215
+ <Heading level={1} size="h5">Danger zone</Heading>
216
+ <Paragraph tone="secondary" size="body2" measure="none">Leave or delete the Acme workspace.</Paragraph>
217
+ </Stack>
218
+ <SettingsSection tone="danger" title="Leave workspace" description="You lose access to Acme.">
219
+ <Paragraph size="body2" measure="none">Your messages and tasks stay in Acme. An owner can invite you again.</Paragraph>
220
+ <Cluster>
221
+ <Button size="small" type="secondary" state="enabled" label="Leave Workspace" onClickButton={() => setLeaveOpen(true)} />
222
+ </Cluster>
223
+ </SettingsSection>
224
+ <SettingsSection tone="danger" title="Delete workspace" description="This cannot be undone.">
225
+ <Paragraph size="body2" measure="none">This deletes Acme, its 128 messages, 42 tasks and 9 documents. Every member keeps their own account, and files exported earlier stay where they are.</Paragraph>
226
+ {confirming ? (
227
+ <>
228
+ <TextField id="danger-zone-shown-name" label={`Type ${workspaceName} to confirm`} value={typed} disabled={deleting} onChange={(e) => setTyped(e.target.value)} />
229
+ <Cluster gap="small">
230
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancelDelete} />
231
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Workspace" loading={deleting} onClickButton={handleDelete} />
232
+ </Cluster>
233
+ </>
234
+ ) : (
235
+ <Cluster>
236
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Workspace" onClickButton={() => setConfirming(true)} />
237
+ </Cluster>
238
+ )}
239
+ </SettingsSection>
240
+ </Stack>
241
+ <Modal
242
+ isOpen={leaveOpen}
243
+ size="small"
244
+ title="Leave Workspace"
245
+ onClose={handleLeaveClose}
246
+ actions={
247
+ <>
248
+ <Button size="small" type="tertiary" state={leaving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleLeaveClose} />
249
+ <Button size="small" type="primary" state="enabled" label="Leave" loading={leaving} onClickButton={handleLeave} />
250
+ </>
251
+ }
252
+ >
253
+ <Paragraph measure="none">You will lose access to Acme.</Paragraph>
254
+ <Paragraph tone="secondary" size="body2" measure="none">Your messages and tasks stay in Acme. An owner can invite you again.</Paragraph>
255
+ </Modal>
256
+ </Center>
257
+ );
258
+ }
259
+ ```
260
+
261
+ ## Native
262
+
263
+ On Apple put the actions in their own `Section` of the settings `Form`, with the Delete Button in the `.destructive` role. Delete asks in an `.alert` with a `TextField`, as the case 'Type to confirm' says.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A CLI, an editor or another app opened the browser so the person can log in, and the login must reach that app.
4
4
 
5
- **Not built yet:** Scindo's CLI login shows 'Login successful!' as soon as its request to the CLI gets any reply. It sends that request in a way that leaves the page unable to read the CLI's reply, so it cannot tell whether the CLI took the login. Its provider Buttons read 'GitHub' and 'Google'. Commentify's popup shows nothing while it finishes.
6
-
7
5
  ## Do
8
6
 
9
7
  - Say in one line what the login connects: 'This connects Acme CLI on your computer to your account.'
@@ -167,5 +165,3 @@ export default function DeviceLoginPopup() {
167
165
  );
168
166
  }
169
167
  ```
170
-
171
- Seen in: Commentify, Scindo.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person opened the link that confirms their email.
4
4
 
5
- **Not built yet:** Scindo on the web shows its success Alert above the login form with a close button. Commentify has no confirmed page and no Alert for it: the link goes straight to the dashboard.
6
-
7
5
  ## Do
8
6
 
9
7
  - Name the page 'Email confirmed' in a `Heading` with `level={1}`.
@@ -147,5 +145,3 @@ export default function EmailConfirmedAlertOnLogin() {
147
145
  );
148
146
  }
149
147
  ```
150
-
151
- Seen in: Commentify, Scindo.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A list has loaded, and there is nothing in it yet.
4
4
 
5
- **Not built yet:** Commentify writes most of its empty lists in Title Case, such as 'No Comments Available', and gives them no `secondText`.
6
-
7
5
  ## Do
8
6
 
9
7
  - Use `size="large"` when the list is the whole pane, and `size="small"` inside a section.
@@ -73,5 +71,3 @@ export default function EmptyListSection() {
73
71
  ## Native
74
72
 
75
73
  On Apple use `ContentUnavailableView`, with the same words.
76
-
77
- Seen in: Commentify, Scindo.
@@ -6,8 +6,6 @@ A list, table or pane has nothing to show.
6
6
 
7
7
  Use `EmptyBox`, never a bare line of text. Its `size` is `large` when the list fills the whole region and `small` inside a section. The `text` says what is empty, in the person's words and in sentence case: 'No saved comments'. The `secondText` says what will appear here or what to do. When the person can fix it, pass the Button as `action`. The action Button is primary when it fills the list or tries again, and secondary when it is 'Clear Search'. An empty search shows the words searched for and a 'Clear Search' Button. A failed load is not an empty list: say that loading failed and offer a 'Try Again' Button. `EmptyBox` may hold that message, with 'Try Again' as its `action`, but never the empty text.
8
8
 
9
- **Not built yet:** Scindo on the web uses `EmptyBox` in three places and bare text elsewhere, such as 'No API keys yet.' Commentify uses `EmptyBox` in most lists and bare text in a few. Commentify admin and jinhwankim.com show bare text. No product passes an `action` yet.
10
-
11
9
  ## Why
12
10
 
13
11
  An empty space looks like something is broken. Saying what is missing and what will fill it tells the person nothing is wrong and what to do next.
@@ -31,5 +29,3 @@ An empty space looks like something is broken. Saying what is missing and what w
31
29
  ## Native
32
30
 
33
31
  On Apple use `ContentUnavailableView`, with the same words.
34
-
35
- Seen in: Commentify, Commentify admin, Scindo, jinhwankim.com.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A pane is empty because something it needs is not set up yet, such as a connected account.
4
4
 
5
- **Not built yet:** Commentify puts its 'Open Settings' Button under `EmptyBox`, not in its `action`, and writes the text in Title Case: 'No App, Team, or User Connected'.
6
-
7
5
  ## Do
8
6
 
9
7
  - Say what is missing: 'No calendar connected'.
@@ -84,5 +82,3 @@ export default function EmptyNotSetUpPointer() {
84
82
  ## Native
85
83
 
86
84
  On Apple use `ContentUnavailableView`, with the Button in its `actions`.
87
-
88
- Seen in: Commentify, Scindo.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A search or a filter finds nothing.
4
4
 
5
- **Not built yet:** Scindo on the web shows a bare line, 'No results found', with no words and no way to clear them. Scindo on Apple shows 'No results found' in a `ContentUnavailableView`, without the words. Commentify shows the words in an `EmptyBox`, with no Clear Search Button.
6
-
7
5
  ## Do
8
6
 
9
7
  - Use `icon="Search"`, so it reads as a search and not an empty list.
@@ -73,5 +71,3 @@ export default function EmptySearchClearSearch() {
73
71
  ## Native
74
72
 
75
73
  On Apple use `ContentUnavailableView.search(text:)`.
76
-
77
- Seen in: Commentify, Scindo.
@@ -2,8 +2,6 @@
2
2
 
3
3
  Something broke while showing a page, and the app cannot show it.
4
4
 
5
- **Not built yet:** Scindo on the web shows the error's own message and its id. Commentify shows one line and 'Try again', with no heading and no way home. jinhwankim.com shows an `EmptyBox` with no Button.
6
-
7
5
  ## Do
8
6
 
9
7
  - Name the page in a `Heading` with `level={1}`: 'Something went wrong'.
@@ -103,5 +101,3 @@ export default function ErrorPageInShell() {
103
101
  );
104
102
  }
105
103
  ```
106
-
107
- Seen in: Commentify, Scindo, jinhwankim.com.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person sends feedback about the product from inside it.
4
4
 
5
- **Not built yet:** Scindo's feedback form labels the Button 'Sending...' while it runs, shows no error when sending fails, and replaces the form with a thank-you that closes after 1.5 seconds. It labels its fields with captions written by hand.
6
-
7
5
  ## Do
8
6
 
9
7
  - Title the Modal 'Send Feedback' and label its action 'Send', after 'Cancel'.
@@ -135,5 +133,3 @@ export default function FeedbackFormModal() {
135
133
  );
136
134
  }
137
135
  ```
138
-
139
- Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function FilterMenuPresets(): import("react").JSX.Element;
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Paragraph from '../../components/paragraph';
5
+ import IconButton from '../../components/iconButton';
6
+ import Tooltip from '../../components/tooltip';
7
+ import Popover from '../../components/popover';
8
+ import Menu from '../../components/menu';
9
+ import MenuItem from '../../components/menuItem';
10
+ import { Center, Cluster, Stack } from '../../components/layout';
11
+ // A real app counts these on the server. `label` is the menu item, in Title Case. `current` names the
12
+ // choice in the button's name, its tooltip and the line, in sentence case.
13
+ var filters = [
14
+ { value: 'day', label: 'Last 24 Hours', current: 'Last 24 hours', count: 4 },
15
+ { value: 'week', label: 'Last 7 Days', current: 'Last 7 days', count: 18 },
16
+ { value: 'month', label: 'Last 30 Days', current: 'Last 30 days', count: 64 },
17
+ { value: 'quarter', label: 'Last 90 Days', current: 'Last 90 days', count: 171 },
18
+ { value: 'all', label: 'All Time', current: 'All time', count: 240 },
19
+ ];
20
+ export default function FilterMenuPresets() {
21
+ var _a;
22
+ var _b = useState('week'), value = _b[0], setValue = _b[1];
23
+ var _c = useState(null), anchor = _c[0], setAnchor = _c[1];
24
+ var _d = useState(false), open = _d[0], setOpen = _d[1];
25
+ var current = (_a = filters.find(function (f) { return f.value === value; })) !== null && _a !== void 0 ? _a : filters[1];
26
+ // The trigger toggles the menu. Popover's returnFocus gives focus back to it on close.
27
+ function toggle(anchorEl) {
28
+ setAnchor(anchorEl);
29
+ setOpen(function (o) { return !o; });
30
+ }
31
+ function choose(next) {
32
+ setValue(next);
33
+ setOpen(false);
34
+ }
35
+ return (<Center width="page">
36
+ <Stack gap="large">
37
+ <Cluster justify="between">
38
+ <Heading level={1} size="h5">Comments</Heading>
39
+ {/* The tooltip names the current filter, and so does the button's name. A filter that is on
40
+ shows in a filled button; 'All Time' filters nothing, so the button is plain. */}
41
+ <Tooltip title={current.current}>
42
+ <IconButton color={value === 'all' ? 'iconOnly' : 'secondary'} state={open ? 'selected' : 'enabled'} size="small" iconName="ListFilter" ariaLabel={"Filter by date: ".concat(current.current)} aria-haspopup="menu" aria-expanded={open} onClick={function (e) { return toggle(e.currentTarget); }}/>
43
+ </Tooltip>
44
+ </Cluster>
45
+ <Paragraph tone="secondary" size="body2" measure="none">{current.count} comments, {current.current.toLowerCase()}.</Paragraph>
46
+ </Stack>
47
+ <Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
48
+ <Menu navigable aria-label="Filter by date" width={200}>
49
+ {filters.map(function (f) { return (<MenuItem key={f.value} size="small" label={f.label} isSelected={f.value === value} role="menuitemradio" onClick={function () { return choose(f.value); }}/>); })}
50
+ </Menu>
51
+ </Popover>
52
+ </Center>);
53
+ }
@@ -0,0 +1 @@
1
+ export default function FilterMenuWithClear(): import("react").JSX.Element;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Paragraph from '../../components/paragraph';
5
+ import IconButton from '../../components/iconButton';
6
+ import Tooltip from '../../components/tooltip';
7
+ import Popover from '../../components/popover';
8
+ import Menu from '../../components/menu';
9
+ import MenuItem from '../../components/menuItem';
10
+ import Line from '../../components/line';
11
+ import { Center, Cluster, Stack } from '../../components/layout';
12
+ // A real app reads these from the server. `label` is the menu item, in Title Case. `current` names the
13
+ // choice in the button's name, its tooltip and the line, in sentence case.
14
+ var filters = [
15
+ { value: 'mentions', label: 'Mentions', current: 'Mentions', count: 3 },
16
+ { value: 'unread', label: 'Unread', current: 'Unread', count: 5 },
17
+ { value: 'assigned', label: 'Assigned to Me', current: 'Assigned to me', count: 2 },
18
+ ];
19
+ var total = 12;
20
+ export default function FilterMenuWithClear() {
21
+ // null means the filter is off.
22
+ var _a = useState('unread'), value = _a[0], setValue = _a[1];
23
+ var _b = useState(null), anchor = _b[0], setAnchor = _b[1];
24
+ var _c = useState(false), open = _c[0], setOpen = _c[1];
25
+ var current = filters.find(function (f) { return f.value === value; });
26
+ function toggle(anchorEl) {
27
+ setAnchor(anchorEl);
28
+ setOpen(function (o) { return !o; });
29
+ }
30
+ function choose(next) {
31
+ setValue(next);
32
+ setOpen(false);
33
+ }
34
+ return (<Center width="page">
35
+ <Stack gap="large">
36
+ <Cluster justify="between">
37
+ <Heading level={1} size="h5">Inbox</Heading>
38
+ {/* A filter that is on shows in a filled button. When it is off the button is plain. */}
39
+ <Tooltip title={current ? current.current : 'Filter messages'}>
40
+ <IconButton color={current ? 'secondary' : 'iconOnly'} state={open ? 'selected' : 'enabled'} size="small" iconName="ListFilter" ariaLabel={current ? "Filter messages: ".concat(current.current) : 'Filter messages'} aria-haspopup="menu" aria-expanded={open} onClick={function (e) { return toggle(e.currentTarget); }}/>
41
+ </Tooltip>
42
+ </Cluster>
43
+ <Paragraph tone="secondary" size="body2" measure="none">
44
+ {current ? "".concat(current.count, " of ").concat(total, " messages, ").concat(current.current.toLowerCase(), ".") : "All ".concat(total, " messages.")}
45
+ </Paragraph>
46
+ </Stack>
47
+ <Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
48
+ <Menu navigable aria-label="Filter messages" width={200}>
49
+ {filters.map(function (f) { return (<MenuItem key={f.value} size="small" label={f.label} isSelected={f.value === value} role="menuitemradio" onClick={function () { return choose(f.value); }}/>); })}
50
+ {/* Clear is last, and shows only while a filter is on. */}
51
+ {current && <Line />}
52
+ {current && <MenuItem size="small" iconName="X" label="Clear Filter" onClick={function () { return choose(null); }}/>}
53
+ </Menu>
54
+ </Popover>
55
+ </Center>);
56
+ }