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.
- package/README.md +2 -2
- package/dist/DESIGN.md +56 -17
- package/dist/cases/accept-invite/signed-in.jsx +1 -1
- package/dist/cases/accept-invite/signed-out.jsx +1 -1
- package/dist/cases/accept-invite.md +3 -7
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- package/dist/cases/agent-options/cards.d.ts +1 -0
- package/dist/cases/agent-options/cards.jsx +91 -0
- package/dist/cases/agent-options.md +164 -0
- package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
- package/dist/cases/agent-pending-reply/steps.jsx +149 -0
- package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
- package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
- package/dist/cases/agent-pending-reply.md +428 -0
- package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
- package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
- package/dist/cases/agent-plan-proposal.md +652 -0
- package/dist/cases/agent-question/choices.d.ts +1 -0
- package/dist/cases/agent-question/choices.jsx +132 -0
- package/dist/cases/agent-question/free-text.d.ts +1 -0
- package/dist/cases/agent-question/free-text.jsx +81 -0
- package/dist/cases/agent-question.md +334 -0
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +2 -4
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- package/dist/cases/artifact-card/card.d.ts +1 -0
- package/dist/cases/artifact-card/card.jsx +45 -0
- package/dist/cases/artifact-card.md +99 -0
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -0
- package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
- package/dist/cases/composer-limit/notice.d.ts +1 -0
- package/dist/cases/composer-limit/notice.jsx +84 -0
- package/dist/cases/composer-limit.md +282 -0
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- package/dist/cases/conversation-starters/chips.d.ts +1 -0
- package/dist/cases/conversation-starters/chips.jsx +69 -0
- package/dist/cases/conversation-starters/none.d.ts +1 -0
- package/dist/cases/conversation-starters/none.jsx +45 -0
- package/dist/cases/conversation-starters.md +204 -0
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page.md +0 -4
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -0
- package/dist/cases/mention-list/in-composer.d.ts +1 -0
- package/dist/cases/mention-list/in-composer.jsx +169 -0
- package/dist/cases/mention-list.md +248 -0
- package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
- package/dist/cases/message-actions/menu.d.ts +1 -0
- package/dist/cases/message-actions/menu.jsx +258 -0
- package/dist/cases/message-actions.md +647 -0
- package/dist/cases/message-attachments/in-composer.d.ts +1 -0
- package/dist/cases/message-attachments/in-composer.jsx +134 -0
- package/dist/cases/message-attachments/in-message.d.ts +1 -0
- package/dist/cases/message-attachments/in-message.jsx +46 -0
- package/dist/cases/message-attachments.md +306 -0
- package/dist/cases/message-composer/plain.d.ts +1 -0
- package/dist/cases/message-composer/plain.jsx +57 -0
- package/dist/cases/message-composer/with-tools.d.ts +1 -0
- package/dist/cases/message-composer/with-tools.jsx +182 -0
- package/dist/cases/message-composer.md +352 -0
- package/dist/cases/message-edit/in-place.d.ts +1 -0
- package/dist/cases/message-edit/in-place.jsx +99 -0
- package/dist/cases/message-edit.md +175 -0
- package/dist/cases/message-reactions/chips.d.ts +1 -0
- package/dist/cases/message-reactions/chips.jsx +118 -0
- package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
- package/dist/cases/message-reactions/quick-pick.jsx +155 -0
- package/dist/cases/message-reactions.md +367 -0
- package/dist/cases/message-row/grouped.d.ts +1 -0
- package/dist/cases/message-row/grouped.jsx +56 -0
- package/dist/cases/message-row/person-and-agent.d.ts +1 -0
- package/dist/cases/message-row/person-and-agent.jsx +41 -0
- package/dist/cases/message-row.md +185 -0
- package/dist/cases/not-found-page.md +0 -4
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
- package/dist/cases/reply-feedback/thumbs.jsx +191 -0
- package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
- package/dist/cases/reply-feedback/with-reason.jsx +221 -0
- package/dist/cases/reply-feedback.md +548 -0
- package/dist/cases/reply-sources/cards.d.ts +1 -0
- package/dist/cases/reply-sources/cards.jsx +83 -0
- package/dist/cases/reply-sources/tag-only.d.ts +1 -0
- package/dist/cases/reply-sources/tag-only.jsx +45 -0
- package/dist/cases/reply-sources.md +243 -0
- package/dist/cases/route-loading.md +0 -2
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/sign-up-page.md +1 -5
- package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
- package/dist/cases/slash-command-list/in-composer.jsx +162 -0
- package/dist/cases/slash-command-list.md +243 -0
- package/dist/cases/success-feedback.md +1 -5
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/type-to-confirm.md +0 -4
- package/dist/cases/typing-and-status/line.d.ts +1 -0
- package/dist/cases/typing-and-status/line.jsx +50 -0
- package/dist/cases/typing-and-status.md +92 -0
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +2331 -294
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +14 -9
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/iconButton.d.ts +3 -3
- package/dist/components/iconButton.jsx +9 -7
- package/dist/components/layout.d.ts +7 -1
- package/dist/components/layout.jsx +5 -2
- package/dist/components/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +12 -2
- package/dist/components/menuItem.jsx +6 -5
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- package/dist/components/paragraph.d.ts +3 -1
- package/dist/components/paragraph.jsx +2 -2
- package/dist/components/popover.d.ts +7 -1
- package/dist/components/popover.jsx +35 -9
- package/dist/components/radioGroup.d.ts +12 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +31 -0
- package/dist/components/settingsSection.jsx +58 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- package/dist/components/sourceCard.d.ts +23 -0
- package/dist/components/sourceCard.jsx +56 -0
- package/dist/components/stepList.d.ts +17 -0
- package/dist/components/stepList.jsx +79 -0
- package/dist/components/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +6 -21
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/internal/autoGrow.d.ts +11 -0
- package/dist/internal/autoGrow.js +28 -0
- package/dist/internal/composer.d.ts +16 -0
- package/dist/internal/composer.js +18 -0
- package/dist/internal/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +62 -1
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +17 -1
- package/dist/stories/Cases.generated.stories.d.ts +53 -0
- package/dist/stories/Cases.generated.stories.jsx +106 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- package/dist/stories/Menu.stories.d.ts +4 -0
- package/dist/stories/Menu.stories.jsx +46 -1
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/Message.stories.d.ts +10 -0
- package/dist/stories/Message.stories.jsx +77 -0
- package/dist/stories/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +2 -0
- package/dist/stories/RadioGroup.stories.jsx +40 -1
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +11 -0
- package/dist/stories/SettingsSection.stories.jsx +64 -0
- package/dist/stories/SourceCard.stories.d.ts +8 -0
- package/dist/stories/SourceCard.stories.jsx +33 -0
- package/dist/stories/StepList.stories.d.ts +8 -0
- package/dist/stories/StepList.stories.jsx +35 -0
- package/dist/stories/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +8 -3
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import Heading from '../../components/heading';
|
|
15
|
+
import Paragraph from '../../components/paragraph';
|
|
16
|
+
import List from '../../components/list';
|
|
17
|
+
import Form from '../../components/form';
|
|
18
|
+
import FormField from '../../components/formField';
|
|
19
|
+
import TextField from '../../components/textField';
|
|
20
|
+
import Switch from '../../components/switch';
|
|
21
|
+
import Button from '../../components/button';
|
|
22
|
+
import TabsContainer from '../../components/tabsContainer';
|
|
23
|
+
import Tab from '../../components/tab';
|
|
24
|
+
import SettingsSection, { SettingsColumns } from '../../components/settingsSection';
|
|
25
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
26
|
+
// 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`.
|
|
27
|
+
var areas = [
|
|
28
|
+
{ id: 'profile', label: 'Profile' },
|
|
29
|
+
{ id: 'notifications', label: 'Notifications' },
|
|
30
|
+
{ id: 'billing', label: 'Billing' },
|
|
31
|
+
];
|
|
32
|
+
var invoices = ['January 2025, $40.00', 'December 2024, $40.00', 'November 2024, $40.00'];
|
|
33
|
+
export default function SettingsPageTopTabs() {
|
|
34
|
+
var _a = useState('profile'), area = _a[0], setArea = _a[1];
|
|
35
|
+
var _b = useState('Dana Lee'), savedName = _b[0], setSavedName = _b[1];
|
|
36
|
+
var _c = useState('Dana Lee'), name = _c[0], setName = _c[1];
|
|
37
|
+
var _d = useState(''), nameError = _d[0], setNameError = _d[1];
|
|
38
|
+
var _e = useState(false), saving = _e[0], setSaving = _e[1];
|
|
39
|
+
var _f = useState(false), saved = _f[0], setSaved = _f[1];
|
|
40
|
+
var _g = useState({ mentions: true, digest: false }), values = _g[0], setValues = _g[1];
|
|
41
|
+
var _h = useState({ mentions: false, digest: false }), busy = _h[0], setBusy = _h[1];
|
|
42
|
+
// A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open area.
|
|
43
|
+
var router = { push: function (url) { return setArea(url.split('/').pop()); } };
|
|
44
|
+
var timers = useRef([]);
|
|
45
|
+
// Cleared before a new 'Saved' starts, so an old timer cannot end it early.
|
|
46
|
+
var savedTimer = useRef();
|
|
47
|
+
// Stops every request and the 'Saved' if the example goes away before they end.
|
|
48
|
+
useEffect(function () { return function () {
|
|
49
|
+
timers.current.forEach(clearTimeout);
|
|
50
|
+
clearTimeout(savedTimer.current);
|
|
51
|
+
}; }, []);
|
|
52
|
+
// A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.
|
|
53
|
+
function handleSave() {
|
|
54
|
+
if (saving)
|
|
55
|
+
return;
|
|
56
|
+
if (!name.trim()) {
|
|
57
|
+
setNameError('Enter your name.');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setNameError('');
|
|
61
|
+
setSaving(true);
|
|
62
|
+
// Stands in for the request to the server.
|
|
63
|
+
timers.current.push(setTimeout(function () {
|
|
64
|
+
setSavedName(name.trim());
|
|
65
|
+
setName(name.trim());
|
|
66
|
+
setSaving(false);
|
|
67
|
+
setSaved(true);
|
|
68
|
+
clearTimeout(savedTimer.current);
|
|
69
|
+
savedTimer.current = setTimeout(function () { return setSaved(false); }, 2000);
|
|
70
|
+
}, 1200));
|
|
71
|
+
}
|
|
72
|
+
// A switch on its own saves as soon as it changes, and shows nothing when it works.
|
|
73
|
+
function handleSwitch(key, next) {
|
|
74
|
+
setBusy(function (current) {
|
|
75
|
+
var _a;
|
|
76
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = true, _a)));
|
|
77
|
+
});
|
|
78
|
+
setValues(function (current) {
|
|
79
|
+
var _a;
|
|
80
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = next, _a)));
|
|
81
|
+
});
|
|
82
|
+
timers.current.push(setTimeout(function () { return setBusy(function (current) {
|
|
83
|
+
var _a;
|
|
84
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = false, _a)));
|
|
85
|
+
}); }, 900));
|
|
86
|
+
}
|
|
87
|
+
var profile = (<SettingsColumns>
|
|
88
|
+
<SettingsSection id="settings-page-tabs-name" title="Name" description="How people see you in messages and on tasks.">
|
|
89
|
+
<Form aria-label="Name" gap="medium" onSubmit={handleSave}>
|
|
90
|
+
<FormField id="settings-page-tabs-name-field" label="Name" error={nameError}>
|
|
91
|
+
{function (f) { return <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={function (e) { setName(e.target.value); setNameError(''); setSaved(false); }}/>; }}
|
|
92
|
+
</FormField>
|
|
93
|
+
<Cluster>
|
|
94
|
+
<Button size="medium" type="primary" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={saving}/>
|
|
95
|
+
</Cluster>
|
|
96
|
+
</Form>
|
|
97
|
+
</SettingsSection>
|
|
98
|
+
<SettingsSection id="settings-page-tabs-email" title="Email" description="Where Acme writes to you.">
|
|
99
|
+
<FormField id="settings-page-tabs-email-field" label="Email" help="Only support can change this. Write to help@acme.example.">
|
|
100
|
+
{function (f) { return <TextField id={f.id} aria-describedby={f['aria-describedby']} value="dana@acme.example" readOnly onChange={function () { }}/>; }}
|
|
101
|
+
</FormField>
|
|
102
|
+
</SettingsSection>
|
|
103
|
+
</SettingsColumns>);
|
|
104
|
+
var notifications = (<SettingsColumns>
|
|
105
|
+
<SettingsSection id="settings-page-tabs-email-alerts" title="Email" description="Sent to dana@acme.example.">
|
|
106
|
+
<Switch id="settings-page-tabs-mentions" label="Mentions" description="An email when someone mentions you." checked={values.mentions} busy={busy.mentions} onChange={function (next) { return handleSwitch('mentions', next); }}/>
|
|
107
|
+
<Switch id="settings-page-tabs-digest" label="Weekly digest" description="A summary of last week, every Monday." checked={values.digest} busy={busy.digest} onChange={function (next) { return handleSwitch('digest', next); }}/>
|
|
108
|
+
</SettingsSection>
|
|
109
|
+
</SettingsColumns>);
|
|
110
|
+
var billing = (<SettingsColumns>
|
|
111
|
+
<SettingsSection id="settings-page-tabs-plan" title="Plan" description="Team plan, 5 seats.">
|
|
112
|
+
<Paragraph size="body2" measure="none">Renews on January 15. Only owners can change the plan.</Paragraph>
|
|
113
|
+
</SettingsSection>
|
|
114
|
+
<SettingsSection id="settings-page-tabs-invoices" title="Invoices" description="The last three months.">
|
|
115
|
+
<List items={invoices} size="body2"/>
|
|
116
|
+
</SettingsSection>
|
|
117
|
+
</SettingsColumns>);
|
|
118
|
+
return (<Center width="page">
|
|
119
|
+
<Stack gap="xlarge">
|
|
120
|
+
<Heading level={1} size="h5">Settings</Heading>
|
|
121
|
+
<TabsContainer>
|
|
122
|
+
{areas.map(function (a) { return (<Tab key={a.id} label={a.label} href={"/settings/".concat(a.id)} router={router} isSelected={area === a.id} onClickTab={function () { return setArea(a.id); }}/>); })}
|
|
123
|
+
</TabsContainer>
|
|
124
|
+
{area === 'profile' && profile}
|
|
125
|
+
{area === 'notifications' && notifications}
|
|
126
|
+
{area === 'billing' && billing}
|
|
127
|
+
</Stack>
|
|
128
|
+
</Center>);
|
|
129
|
+
}
|
|
@@ -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,
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SlashCommandListInComposer(): import("react").JSX.Element;
|