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,378 @@
1
+ # Settings page
2
+
3
+ A person opens the settings of the product and looks for one area, such as Profile or Billing.
4
+
5
+ ## Do
6
+
7
+ - Title the page 'Settings' with a level 1 `Heading`.
8
+ - Follow the rule 'A setting saves in place, or with one Save Button' in every area.
9
+ - Put each area's controls in `SettingsSection`s. Put them in `SettingsColumns` when an area has several: one column on a phone, two from `md`.
10
+ - Give each `Tab` an `href` and the app's `router`, so the selected Tab follows the page.
11
+ - Keep the tabs to four areas or fewer, each named with one short word, such as 'Profile' or 'Billing', so the tabs fit on a phone without scrolling.
12
+ - Group the areas in a `Navigation` with `aria-label="Settings"` when there are more. Give each `NavigationGroup` a `label`, such as 'Account' and 'Workspace'.
13
+ - Make each nav item a `MenuItem` with an `href`. Mark the open one with `isSelected` and `aria-current="page"`.
14
+ - Put 'Log Out' last in the nav, and ask first as the case 'Log-out confirm' says.
15
+ - Use `SettingsLayout` for the side nav. From `md` the nav sits beside the area. On a phone the nav is the page, and choosing an item opens that area alone.
16
+ - Show a 'Back to Settings' Button above the area on a phone, and nothing at `md` and up. It goes back to the nav.
17
+ - Show a setting a person cannot change as read-only, with one line that says who can: 'Only owners can change this.'
18
+
19
+ ## Don't
20
+
21
+ - Do not use tabs for more than four areas. They run off a phone screen.
22
+ - Do not show the nav and the area together on a phone.
23
+ - Do not leave a phone with no way back to the nav.
24
+ - Do not put a Save Button for the whole page. Each group saves by itself.
25
+ - Do not call it 'Preferences' in one place and 'Settings' in another.
26
+
27
+ ## Option: Tabs across the top
28
+
29
+ Use when: Four areas or fewer, with short names that fit on a phone.
30
+
31
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `List`, `Paragraph`, `SettingsColumns`, `SettingsSection`, `Stack`, `Switch`, `Tab`, `TabsContainer`, `TextField`
32
+
33
+ ```tsx
34
+ 'use client';
35
+ import { useEffect, useRef, useState } from 'react';
36
+ import Heading from 'oneslash-design-system/components/heading';
37
+ import Paragraph from 'oneslash-design-system/components/paragraph';
38
+ import List from 'oneslash-design-system/components/list';
39
+ import Form from 'oneslash-design-system/components/form';
40
+ import FormField from 'oneslash-design-system/components/formField';
41
+ import TextField from 'oneslash-design-system/components/textField';
42
+ import Switch from 'oneslash-design-system/components/switch';
43
+ import Button from 'oneslash-design-system/components/button';
44
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
45
+ import Tab from 'oneslash-design-system/components/tab';
46
+ import SettingsSection, { SettingsColumns } from 'oneslash-design-system/components/settingsSection';
47
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
48
+
49
+ type Area = 'profile' | 'notifications' | 'billing';
50
+
51
+ // Four areas or fewer, each named with one short word, so the tabs fit on a phone. Each tab is a page of its own in a real app, so it has an `href`.
52
+ const areas: { id: Area; label: string }[] = [
53
+ { id: 'profile', label: 'Profile' },
54
+ { id: 'notifications', label: 'Notifications' },
55
+ { id: 'billing', label: 'Billing' },
56
+ ];
57
+
58
+ const invoices = ['January 2025, $40.00', 'December 2024, $40.00', 'November 2024, $40.00'];
59
+
60
+ export default function SettingsPageTopTabs() {
61
+ const [area, setArea] = useState<Area>('profile');
62
+ const [savedName, setSavedName] = useState('Dana Lee');
63
+ const [name, setName] = useState('Dana Lee');
64
+ const [nameError, setNameError] = useState('');
65
+ const [saving, setSaving] = useState(false);
66
+ const [saved, setSaved] = useState(false);
67
+ const [values, setValues] = useState({ mentions: true, digest: false });
68
+ const [busy, setBusy] = useState({ mentions: false, digest: false });
69
+ // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open area.
70
+ const router = { push: (url: string) => setArea(url.split('/').pop() as Area) };
71
+ const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
72
+ // Cleared before a new 'Saved' starts, so an old timer cannot end it early.
73
+ const savedTimer = useRef<ReturnType<typeof setTimeout>>();
74
+
75
+ // Stops every request and the 'Saved' if the example goes away before they end.
76
+ useEffect(() => () => {
77
+ timers.current.forEach(clearTimeout);
78
+ clearTimeout(savedTimer.current);
79
+ }, []);
80
+
81
+ // A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.
82
+ function handleSave() {
83
+ if (saving) return;
84
+ if (!name.trim()) {
85
+ setNameError('Enter your name.');
86
+ return;
87
+ }
88
+ setNameError('');
89
+ setSaving(true);
90
+ // Stands in for the request to the server.
91
+ timers.current.push(setTimeout(() => {
92
+ setSavedName(name.trim());
93
+ setName(name.trim());
94
+ setSaving(false);
95
+ setSaved(true);
96
+ clearTimeout(savedTimer.current);
97
+ savedTimer.current = setTimeout(() => setSaved(false), 2000);
98
+ }, 1200));
99
+ }
100
+
101
+ // A switch on its own saves as soon as it changes, and shows nothing when it works.
102
+ function handleSwitch(key: 'mentions' | 'digest', next: boolean) {
103
+ setBusy((current) => ({ ...current, [key]: true }));
104
+ setValues((current) => ({ ...current, [key]: next }));
105
+ timers.current.push(setTimeout(() => setBusy((current) => ({ ...current, [key]: false })), 900));
106
+ }
107
+
108
+ const profile = (
109
+ <SettingsColumns>
110
+ <SettingsSection id="settings-page-tabs-name" title="Name" description="How people see you in messages and on tasks.">
111
+ <Form aria-label="Name" gap="medium" onSubmit={handleSave}>
112
+ <FormField id="settings-page-tabs-name-field" label="Name" error={nameError}>
113
+ {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={(e) => { setName(e.target.value); setNameError(''); setSaved(false); }} />}
114
+ </FormField>
115
+ <Cluster>
116
+ <Button size="medium" type="primary" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={saving} />
117
+ </Cluster>
118
+ </Form>
119
+ </SettingsSection>
120
+ <SettingsSection id="settings-page-tabs-email" title="Email" description="Where Acme writes to you.">
121
+ <FormField id="settings-page-tabs-email-field" label="Email" help="Only support can change this. Write to help@acme.example.">
122
+ {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} value="dana@acme.example" readOnly onChange={() => {}} />}
123
+ </FormField>
124
+ </SettingsSection>
125
+ </SettingsColumns>
126
+ );
127
+
128
+ const notifications = (
129
+ <SettingsColumns>
130
+ <SettingsSection id="settings-page-tabs-email-alerts" title="Email" description="Sent to dana@acme.example.">
131
+ <Switch id="settings-page-tabs-mentions" label="Mentions" description="An email when someone mentions you." checked={values.mentions} busy={busy.mentions} onChange={(next) => handleSwitch('mentions', next)} />
132
+ <Switch id="settings-page-tabs-digest" label="Weekly digest" description="A summary of last week, every Monday." checked={values.digest} busy={busy.digest} onChange={(next) => handleSwitch('digest', next)} />
133
+ </SettingsSection>
134
+ </SettingsColumns>
135
+ );
136
+
137
+ const billing = (
138
+ <SettingsColumns>
139
+ <SettingsSection id="settings-page-tabs-plan" title="Plan" description="Team plan, 5 seats.">
140
+ <Paragraph size="body2" measure="none">Renews on January 15. Only owners can change the plan.</Paragraph>
141
+ </SettingsSection>
142
+ <SettingsSection id="settings-page-tabs-invoices" title="Invoices" description="The last three months.">
143
+ <List items={invoices} size="body2" />
144
+ </SettingsSection>
145
+ </SettingsColumns>
146
+ );
147
+
148
+ return (
149
+ <Center width="page">
150
+ <Stack gap="xlarge">
151
+ <Heading level={1} size="h5">Settings</Heading>
152
+ <TabsContainer>
153
+ {areas.map((a) => (
154
+ <Tab key={a.id} label={a.label} href={`/settings/${a.id}`} router={router} isSelected={area === a.id} onClickTab={() => setArea(a.id)} />
155
+ ))}
156
+ </TabsContainer>
157
+ {area === 'profile' && profile}
158
+ {area === 'notifications' && notifications}
159
+ {area === 'billing' && billing}
160
+ </Stack>
161
+ </Center>
162
+ );
163
+ }
164
+ ```
165
+
166
+ ## Option: Side navigation in groups
167
+
168
+ Use when: There are more areas, and they fall into groups.
169
+
170
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `MenuItem`, `Modal`, `Navigation`, `NavigationGroup`, `Paragraph`, `SettingsLayout`, `SettingsSection`, `Stack`, `Switch`, `TextField`
171
+
172
+ ```tsx
173
+ 'use client';
174
+ import { useEffect, useRef, useState } from 'react';
175
+ import Modal from 'oneslash-design-system/components/modal';
176
+ import Heading from 'oneslash-design-system/components/heading';
177
+ import Paragraph from 'oneslash-design-system/components/paragraph';
178
+ import Form from 'oneslash-design-system/components/form';
179
+ import FormField from 'oneslash-design-system/components/formField';
180
+ import TextField from 'oneslash-design-system/components/textField';
181
+ import Switch from 'oneslash-design-system/components/switch';
182
+ import Button from 'oneslash-design-system/components/button';
183
+ import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
184
+ import MenuItem from 'oneslash-design-system/components/menuItem';
185
+ import SettingsSection, { SettingsLayout } from 'oneslash-design-system/components/settingsSection';
186
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
187
+
188
+ type Area = { id: string; label: string; icon: string; group: string; description: string };
189
+
190
+ // Areas in groups, as the side nav lists them. Each is a page of its own in a real app, so it has an `href`.
191
+ const areas: Area[] = [
192
+ { id: 'profile', label: 'Profile', icon: 'User', group: 'Account', description: 'How people see you in Acme.' },
193
+ { id: 'notifications', label: 'Notifications', icon: 'Bell', group: 'Account', description: 'Choose what reaches you.' },
194
+ { id: 'general', label: 'General', icon: 'Settings', group: 'Workspace', description: 'The name and defaults of the Acme workspace.' },
195
+ { id: 'members', label: 'Members', icon: 'Users', group: 'Workspace', description: 'Who is in Acme, and what they can do.' },
196
+ { id: 'billing', label: 'Billing', icon: 'CreditCard', group: 'Workspace', description: 'Your plan and invoices.' },
197
+ { id: 'api-keys', label: 'API Keys', icon: 'Key', group: 'Developers', description: 'Keys for tools that use Acme.' },
198
+ { id: 'webhooks', label: 'Webhooks', icon: 'Webhook', group: 'Developers', description: 'Send Acme events to other tools.' },
199
+ ];
200
+
201
+ const groups = ['Account', 'Workspace', 'Developers'];
202
+
203
+ export default function SettingsPageSideNav() {
204
+ const [areaId, setAreaId] = useState('profile');
205
+ // On a phone the nav is the page: it shows until the person opens an area, and 'Back to Settings' returns to it.
206
+ const [opened, setOpened] = useState(false);
207
+ const [savedName, setSavedName] = useState('Dana Lee');
208
+ const [name, setName] = useState('Dana Lee');
209
+ const [nameError, setNameError] = useState('');
210
+ const [saving, setSaving] = useState(false);
211
+ const [saved, setSaved] = useState(false);
212
+ const [values, setValues] = useState({ mentions: true, digest: false });
213
+ const [busy, setBusy] = useState({ mentions: false, digest: false });
214
+ const [confirmingLogOut, setConfirmingLogOut] = useState(false);
215
+ const [loggingOut, setLoggingOut] = useState(false);
216
+ const [loggedOut, setLoggedOut] = useState(false);
217
+ const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
218
+ // Cleared before a new 'Saved' starts, so an old timer cannot end it early.
219
+ const savedTimer = useRef<ReturnType<typeof setTimeout>>();
220
+
221
+ // Stops every request and the 'Saved' if the example goes away before they end.
222
+ useEffect(() => () => {
223
+ timers.current.forEach(clearTimeout);
224
+ clearTimeout(savedTimer.current);
225
+ }, []);
226
+
227
+ const area = areas.find((a) => a.id === areaId) ?? areas[0];
228
+
229
+ function handleOpen(id: string) {
230
+ setAreaId(id);
231
+ setOpened(true);
232
+ }
233
+
234
+ // Escape, a click outside and Cancel all close it, except while the request runs.
235
+ function handleLogOutClose() {
236
+ if (loggingOut) return;
237
+ setConfirmingLogOut(false);
238
+ }
239
+
240
+ function handleLogOut() {
241
+ if (loggingOut) return;
242
+ setLoggingOut(true);
243
+ timers.current.push(setTimeout(() => {
244
+ setLoggingOut(false);
245
+ setConfirmingLogOut(false);
246
+ setLoggedOut(true);
247
+ }, 1200));
248
+ }
249
+
250
+ // A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.
251
+ function handleSave() {
252
+ if (saving) return;
253
+ if (!name.trim()) {
254
+ setNameError('Enter your name.');
255
+ return;
256
+ }
257
+ setNameError('');
258
+ setSaving(true);
259
+ // Stands in for the request to the server.
260
+ timers.current.push(setTimeout(() => {
261
+ setSavedName(name.trim());
262
+ setName(name.trim());
263
+ setSaving(false);
264
+ setSaved(true);
265
+ clearTimeout(savedTimer.current);
266
+ savedTimer.current = setTimeout(() => setSaved(false), 2000);
267
+ }, 1200));
268
+ }
269
+
270
+ // A switch on its own saves as soon as it changes, and shows nothing when it works.
271
+ function handleSwitch(key: 'mentions' | 'digest', next: boolean) {
272
+ setBusy((current) => ({ ...current, [key]: true }));
273
+ setValues((current) => ({ ...current, [key]: next }));
274
+ timers.current.push(setTimeout(() => setBusy((current) => ({ ...current, [key]: false })), 900));
275
+ }
276
+
277
+ const profile = (
278
+ <SettingsSection id="settings-page-nav-name" title="Name" description="How people see you in messages and on tasks.">
279
+ <Form aria-label="Name" gap="medium" onSubmit={handleSave}>
280
+ <FormField id="settings-page-nav-name-field" label="Name" error={nameError}>
281
+ {(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={(e) => { setName(e.target.value); setNameError(''); setSaved(false); }} />}
282
+ </FormField>
283
+ <Cluster>
284
+ <Button size="medium" type="primary" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={saving} />
285
+ </Cluster>
286
+ </Form>
287
+ </SettingsSection>
288
+ );
289
+
290
+ const notifications = (
291
+ <SettingsSection id="settings-page-nav-email" title="Email" description="Sent to dana@acme.example.">
292
+ <Switch id="settings-page-nav-mentions" label="Mentions" description="An email when someone mentions you." checked={values.mentions} busy={busy.mentions} onChange={(next) => handleSwitch('mentions', next)} />
293
+ <Switch id="settings-page-nav-digest" label="Weekly digest" description="A summary of last week, every Monday." checked={values.digest} busy={busy.digest} onChange={(next) => handleSwitch('digest', next)} />
294
+ </SettingsSection>
295
+ );
296
+
297
+ // A real app goes to its login page here. The example shows a short logged-out page instead.
298
+ if (loggedOut) {
299
+ return (
300
+ <Center fill>
301
+ <Heading level={1} size="h5">You are logged out</Heading>
302
+ <Cluster>
303
+ <Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={() => setLoggedOut(false)} />
304
+ </Cluster>
305
+ </Center>
306
+ );
307
+ }
308
+
309
+ const nav = (
310
+ <Navigation aria-label="Settings">
311
+ {groups.map((group) => (
312
+ <NavigationGroup key={group} label={group}>
313
+ {areas.filter((a) => a.group === group).map((a) => (
314
+ <MenuItem
315
+ key={a.id}
316
+ size="small"
317
+ label={a.label}
318
+ iconName={a.icon}
319
+ href={`/settings/${a.id}`}
320
+ isSelected={a.id === area.id}
321
+ aria-current={a.id === area.id ? 'page' : undefined}
322
+ onClick={(event: { preventDefault: () => void }) => {
323
+ // A real app lets the link go to its page. The example keeps the choice in state.
324
+ event.preventDefault();
325
+ handleOpen(a.id);
326
+ }}
327
+ />
328
+ ))}
329
+ </NavigationGroup>
330
+ ))}
331
+ <NavigationGroup label="Session">
332
+ <MenuItem size="small" label="Log Out" iconName="LogOut" role="button" onClick={() => setConfirmingLogOut(true)} />
333
+ </NavigationGroup>
334
+ </Navigation>
335
+ );
336
+
337
+ return (
338
+ <Center width="page">
339
+ <Stack gap="xlarge">
340
+ <Heading level={1} size="h5">Settings</Heading>
341
+ <SettingsLayout
342
+ nav={nav}
343
+ showContent={opened}
344
+ back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Settings" onClickButton={() => setOpened(false)} />}
345
+ >
346
+ <Stack gap="small">
347
+ <Heading level={2} size="h6">{area.label}</Heading>
348
+ <Paragraph tone="secondary" size="body2" measure="none">{area.description}</Paragraph>
349
+ </Stack>
350
+ {area.id === 'profile' && profile}
351
+ {area.id === 'notifications' && notifications}
352
+ {area.id !== 'profile' && area.id !== 'notifications' && (
353
+ <Paragraph size="body2" measure="none">Nothing to show for {area.label} in this example.</Paragraph>
354
+ )}
355
+ </SettingsLayout>
356
+ </Stack>
357
+ <Modal
358
+ isOpen={confirmingLogOut}
359
+ size="small"
360
+ title="Log Out"
361
+ onClose={handleLogOutClose}
362
+ actions={
363
+ <>
364
+ <Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleLogOutClose} />
365
+ <Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={handleLogOut} />
366
+ </>
367
+ }
368
+ >
369
+ <Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
370
+ </Modal>
371
+ </Center>
372
+ );
373
+ }
374
+ ```
375
+
376
+ ## Native
377
+
378
+ On macOS use a `Settings` scene with one tab per area, or a `NavigationSplitView` with a sidebar `List` in `Section`s. On iPhone the list is the first screen and an item pushes its area. On Android use a list of areas that opens each one on its own screen.
@@ -0,0 +1,35 @@
1
+ # A setting saves in place, or with one Save Button
2
+
3
+ A person changes a setting.
4
+
5
+ ## Answer
6
+
7
+ A control that stands alone saves as soon as it changes: a `Switch`, a choice in a `RadioGroup` or a `Select`, or a picture the person chooses. It shows nothing on success, because the control already shows the new value. While the request runs it is busy: a `Switch` takes `busy`, and a `RadioGroup` or `Select` is disabled. If the save fails, the control goes back to its old value and says why next to itself: in a Switch's `error`, in the error line of its `FormField`, or in an inline error `Alert` under a control with no visible label, such as a role in a row. A group of fields that belong together, such as a name, a profile, instructions or a budget, has one Save Button for the whole group. The Button is `loading` while it saves, keeps its label, then reads 'Saved' for 2 seconds. It is disabled while nothing has changed. A group that fails to save follows the rule 'A form error shows next to the problem'. Leaving with unsaved changes follows the case 'Unsaved changes'. Never mix both in one group: a Switch beside a Save Button leaves the person unsure which one is saved. Never show a toast for a setting saved in place. The one exception is a setting chosen from a menu: the menu closes, so a failed save shows in a toast and the control goes back to its old value. A person who cannot change a setting sees it read-only, with one line that says who can change it.
8
+
9
+ ## Why
10
+
11
+ A control that saves by itself needs no button, and a group needs one place to say it is saved. Mixing the two makes people guess what is saved and what is not.
12
+
13
+ ## Do
14
+
15
+ - Save a `Switch`, a `RadioGroup` or a `Select` that stands alone as soon as it changes.
16
+ - Set the Switch `busy`, or disable the `RadioGroup` or `Select`, while the request runs, and show nothing when it works.
17
+ - Put the old value back when a save fails, and say why next to the control: 'Could not save. Try again.'
18
+ - Give a group of fields that belong together one Save Button.
19
+ - Show `loading` on the Save Button while it saves, keep its label, then show 'Saved' for 2 seconds.
20
+ - Keep the Save Button `state="disabled"` while nothing has changed.
21
+ - Show a failed group save as the rule 'A form error shows next to the problem' says.
22
+ - Follow the case 'Unsaved changes' when the person leaves a group with changes.
23
+ - Show a setting the person cannot change as read-only, with one line that says who can: 'Only owners can change this.'
24
+
25
+ ## Don't
26
+
27
+ - Do not mix a control that saves on change and a Save Button in one group.
28
+ - Do not show a toast for a setting saved in place, except a failed save of a setting chosen from a menu.
29
+ - Do not change the Button's label while it is loading, such as to 'Saving…'.
30
+ - Do not leave a failed save without a message.
31
+ - Do not use a `Checkbox` for an on/off setting that saves on change. Use a `Switch`.
32
+
33
+ ## Native
34
+
35
+ On Apple use the system `Toggle` and `Picker` that save as they change, and a `Form` with one Save Button for a group of fields. On Android use a `Switch`.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person who has no account yet opens the product and wants one.
4
4
 
5
- **Not built yet:** Commentify and Scindo on the web replace the form with a spinner while creating the account. Neither says a password rule on its sign-up page. Their reset pages accept 6 characters and say 'Password must be at least 6 characters.' only after it is broken. Commentify asks for the first and last name in two fields.
6
-
7
5
  ## Do
8
6
 
9
7
  - Ask only for what the account needs: name, email and password.
@@ -473,6 +471,4 @@ export default function SignUpProviderFirst() {
473
471
 
474
472
  ## Native
475
473
 
476
- On Apple, Scindo opens the web sign-up page with a `Link`. A sign-up built in the app uses `SignInWithAppleButton` for Apple, a grouped form for the fields, and system buttons.
477
-
478
- Seen in: Commentify, Scindo.
474
+ On Apple, the app opens the web sign-up page with a `Link`. A sign-up built in the app uses `SignInWithAppleButton` for Apple, a grouped form for the fields, and system buttons.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person types / at the start of the message box to run a command.
4
4
 
5
- **Not built yet:** Scindo on the web builds its list from buttons, so a screen reader in the field does not hear which command is highlighted. Both Scindo apps run a command with no argument as soon as it is picked.
6
-
7
5
  ## Do
8
6
 
9
7
  - Open the list when the text starts with /. A bare / opens it, each letter after it narrows it, and a space closes it.
@@ -243,5 +241,3 @@ export default function SlashCommandListInComposer() {
243
241
  ## Native
244
242
 
245
243
  On Apple the list shows above the field with the command, what it does and, when it takes an argument, its usage. Escape closes the list on a Mac.
246
-
247
- Seen in: Scindo.
@@ -6,8 +6,6 @@ Something the person did has worked.
6
6
 
7
7
  The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When Copy is a menu item, the menu closes, so a toast says 'Message copied.' instead. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.
8
8
 
9
- **Not built yet:** Scindo on the web has no toast. It shows success in five ways: a 'Saved' Button label, a green caption, an inline Alert, a thank-you that replaces a dialog and a 'Copied' label. The timed ones clear after 1.5, 2, 3 or 4 seconds. Commentify shows toasts through `Alert`, one at a time, and many of them say 'successfully'.
10
-
11
9
  ## Why
12
10
 
13
11
  Feedback belongs where the person is looking. A change they can see needs only a word on the Button, and a result they cannot see needs a short message that names it.
@@ -31,5 +29,3 @@ Feedback belongs where the person is looking. A change they can see needs only a
31
29
  ## Native
32
30
 
33
31
  On Apple there is no toast. Show the result in place.
34
-
35
- Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function TagFilterTags(): import("react").JSX.Element;