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,204 @@
|
|
|
1
|
+
# Conversation starters
|
|
2
|
+
|
|
3
|
+
A thread has no messages yet, and the person may not know what to write first.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Show the empty thread as the rule 'An empty list says what will fill it' says. Use `EmptyBox` with `size="large"`, the `text` 'No messages yet', and a `secondText` that says what to do.
|
|
8
|
+
- Pass the starters as the `action`: a `Cluster` of three or four clickable `Tag`s, each a short thing to ask in the person's words.
|
|
9
|
+
- Pass `toggle={false}` to each starter `Tag`, so it is a plain button and not a toggle.
|
|
10
|
+
- Use `Tag`, not Button: a starter is a phrase the person might say, and a Button label is in Title Case.
|
|
11
|
+
- Fill the Composer with the starter and focus it, with the caret at the end. Do not send it: the person reads it and can change it first.
|
|
12
|
+
- Say who reads the message in the placeholder: 'Message Acme Agent'.
|
|
13
|
+
- Hide the starters once the thread has a message.
|
|
14
|
+
- Write the starters for the place: in a task, ask about the plan; in a channel, ask about what the team discussed.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not send a starter on a click.
|
|
19
|
+
- Do not show starters in a thread between people. Say what to do in `secondText` instead.
|
|
20
|
+
- Do not offer more than four starters.
|
|
21
|
+
- Do not write starters in the system's words, such as 'Run summary'.
|
|
22
|
+
|
|
23
|
+
## Option: Things to ask
|
|
24
|
+
|
|
25
|
+
Use when: A conversation with the agent: three or four things to ask it.
|
|
26
|
+
|
|
27
|
+
Uses: `Center`, `Cluster`, `Composer`, `EmptyBox`, `Heading`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
'use client';
|
|
31
|
+
import { useEffect, useRef, useState } from 'react';
|
|
32
|
+
import Message from 'oneslash-design-system/components/message';
|
|
33
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
34
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
35
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
36
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
37
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
38
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
39
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
40
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
41
|
+
|
|
42
|
+
// A real app reads this from the session.
|
|
43
|
+
const me = 'Dana Lee';
|
|
44
|
+
const agentName = 'Acme Agent';
|
|
45
|
+
|
|
46
|
+
// Things to ask, in the person's words.
|
|
47
|
+
const starters = [
|
|
48
|
+
'Summarize the launch plan',
|
|
49
|
+
'Draft the launch email',
|
|
50
|
+
'List what is still open',
|
|
51
|
+
'Check the pricing page for mistakes',
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
type Row = { id: string; from: string; at: Date; text: string };
|
|
55
|
+
|
|
56
|
+
export default function ConversationStartersChips() {
|
|
57
|
+
const [thread, setThread] = useState<Row[]>([]);
|
|
58
|
+
const [text, setText] = useState('');
|
|
59
|
+
// Set when a starter fills the field; the effect below focuses it with the caret at the end.
|
|
60
|
+
const [filled, setFilled] = useState(0);
|
|
61
|
+
const field = useRef<HTMLTextAreaElement>(null);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!filled || !field.current) return;
|
|
65
|
+
const end = field.current.value.length;
|
|
66
|
+
field.current.focus();
|
|
67
|
+
field.current.setSelectionRange(end, end);
|
|
68
|
+
}, [filled]);
|
|
69
|
+
|
|
70
|
+
// Fills the field and does not send: the person can change it first.
|
|
71
|
+
function fillWith(starter: string) {
|
|
72
|
+
setText(starter);
|
|
73
|
+
setFilled((n) => n + 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function send() {
|
|
77
|
+
// A real app sends the message to the agent here and shows it at once.
|
|
78
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
|
|
79
|
+
setText('');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Center width="page">
|
|
84
|
+
<Stack gap="large">
|
|
85
|
+
<Heading level={1} size="h5">{`Ask ${agentName}`}</Heading>
|
|
86
|
+
{thread.length === 0 ? (
|
|
87
|
+
<EmptyBox
|
|
88
|
+
size="large"
|
|
89
|
+
icon="MessageCircle"
|
|
90
|
+
text="No messages yet"
|
|
91
|
+
secondText={`Ask ${agentName} about the launch, or start with one of these.`}
|
|
92
|
+
action={
|
|
93
|
+
<Cluster gap="small">
|
|
94
|
+
{starters.map((s) => (
|
|
95
|
+
<Tag key={s} variant="contained" size="small" label={s} toggle={false} onClick={() => fillWith(s)} />
|
|
96
|
+
))}
|
|
97
|
+
</Cluster>
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
// A real app gives the list that holds the rows role="log".
|
|
102
|
+
<Stack gap="small">
|
|
103
|
+
{thread.map((m) => (
|
|
104
|
+
<Message
|
|
105
|
+
key={m.id}
|
|
106
|
+
aria-label={m.from}
|
|
107
|
+
avatar={<UserImage userHandle={m.from} decorative />}
|
|
108
|
+
name={m.from}
|
|
109
|
+
meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
|
|
110
|
+
>
|
|
111
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
112
|
+
</Message>
|
|
113
|
+
))}
|
|
114
|
+
</Stack>
|
|
115
|
+
)}
|
|
116
|
+
<Composer
|
|
117
|
+
ref={field}
|
|
118
|
+
id="conversation-starters-chips-message"
|
|
119
|
+
aria-label="Message"
|
|
120
|
+
placeholder={`Message ${agentName}`}
|
|
121
|
+
value={text}
|
|
122
|
+
onChange={setText}
|
|
123
|
+
onSubmit={send}
|
|
124
|
+
/>
|
|
125
|
+
</Stack>
|
|
126
|
+
</Center>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Option: No starters
|
|
132
|
+
|
|
133
|
+
Use when: A thread between people, where the agent is not the one asked.
|
|
134
|
+
|
|
135
|
+
Uses: `Center`, `Composer`, `EmptyBox`, `Heading`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
'use client';
|
|
139
|
+
import { useState } from 'react';
|
|
140
|
+
import Message from 'oneslash-design-system/components/message';
|
|
141
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
142
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
143
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
144
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
145
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
146
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
147
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
148
|
+
|
|
149
|
+
// A real app reads this from the session.
|
|
150
|
+
const me = 'Dana Lee';
|
|
151
|
+
|
|
152
|
+
type Row = { id: string; from: string; at: Date; text: string };
|
|
153
|
+
|
|
154
|
+
export default function ConversationStartersNone() {
|
|
155
|
+
const [thread, setThread] = useState<Row[]>([]);
|
|
156
|
+
const [text, setText] = useState('');
|
|
157
|
+
|
|
158
|
+
function send() {
|
|
159
|
+
// A real app sends the message to the server here and shows it at once.
|
|
160
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
|
|
161
|
+
setText('');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Center width="page">
|
|
166
|
+
<Stack gap="large">
|
|
167
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
168
|
+
{thread.length === 0 ? (
|
|
169
|
+
// A thread between people: no starters, and secondText says what to do.
|
|
170
|
+
<EmptyBox
|
|
171
|
+
size="large"
|
|
172
|
+
icon="MessageCircle"
|
|
173
|
+
text="No messages yet"
|
|
174
|
+
secondText="Send the first message to the team in Launch plan."
|
|
175
|
+
/>
|
|
176
|
+
) : (
|
|
177
|
+
// A real app gives the list that holds the rows role="log".
|
|
178
|
+
<Stack gap="small">
|
|
179
|
+
{thread.map((m) => (
|
|
180
|
+
<Message
|
|
181
|
+
key={m.id}
|
|
182
|
+
aria-label={m.from}
|
|
183
|
+
avatar={<UserImage userHandle={m.from} decorative />}
|
|
184
|
+
name={m.from}
|
|
185
|
+
meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
|
|
186
|
+
>
|
|
187
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
188
|
+
</Message>
|
|
189
|
+
))}
|
|
190
|
+
</Stack>
|
|
191
|
+
)}
|
|
192
|
+
<Composer
|
|
193
|
+
id="conversation-starters-none-message"
|
|
194
|
+
aria-label="Message"
|
|
195
|
+
placeholder="Message the team"
|
|
196
|
+
value={text}
|
|
197
|
+
onChange={setText}
|
|
198
|
+
onSubmit={send}
|
|
199
|
+
/>
|
|
200
|
+
</Stack>
|
|
201
|
+
</Center>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A person creates something new, such as a project or a task, and it needs a name before it exists.
|
|
4
4
|
|
|
5
|
-
**Not built yet:** Scindo on the web replaces the fields with a spinner while it creates a workspace or a task, and makes Cancel a secondary Button. Scindo's Apple app labels the Button 'Creating...' while it runs.
|
|
6
|
-
|
|
7
5
|
## Do
|
|
8
6
|
|
|
9
7
|
- Title the Modal 'Create' and the thing, such as 'Create Project', and give its action the same verb: 'Create'.
|
|
@@ -240,5 +238,3 @@ export default function CreateModalWithSettings() {
|
|
|
240
238
|
## Native
|
|
241
239
|
|
|
242
240
|
On Apple use a sheet with a `Form`. Put 'Cancel' in the `.cancellationAction` placement and 'Create' in `.confirmationAction`, and create on `.onSubmit` from the name field.
|
|
243
|
-
|
|
244
|
-
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DangerZoneCollapsed(): import("react").JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import TextField from '../../components/textField';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import SettingsSection from '../../components/settingsSection';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
// An account has no name to type, so the person types a fixed word.
|
|
10
|
+
var word = 'DELETE';
|
|
11
|
+
export default function DangerZoneCollapsed() {
|
|
12
|
+
var _a = useState(false), shown = _a[0], setShown = _a[1];
|
|
13
|
+
var _b = useState(false), confirming = _b[0], setConfirming = _b[1];
|
|
14
|
+
var _c = useState(''), typed = _c[0], setTyped = _c[1];
|
|
15
|
+
var _d = useState(false), deleting = _d[0], setDeleting = _d[1];
|
|
16
|
+
var _e = useState(false), deleted = _e[0], setDeleted = _e[1];
|
|
17
|
+
var timer = useRef();
|
|
18
|
+
// Stops the request if the example goes away before it ends.
|
|
19
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
20
|
+
// An exact match, with case. Pasting the word is fine.
|
|
21
|
+
var matches = typed === word;
|
|
22
|
+
function handleToggle() {
|
|
23
|
+
if (deleting)
|
|
24
|
+
return;
|
|
25
|
+
setShown(!shown);
|
|
26
|
+
setConfirming(false);
|
|
27
|
+
setTyped('');
|
|
28
|
+
}
|
|
29
|
+
function handleCancel() {
|
|
30
|
+
setConfirming(false);
|
|
31
|
+
setTyped('');
|
|
32
|
+
}
|
|
33
|
+
function handleDelete() {
|
|
34
|
+
if (deleting || !matches)
|
|
35
|
+
return;
|
|
36
|
+
setDeleting(true);
|
|
37
|
+
// Stands in for the request to the server.
|
|
38
|
+
timer.current = setTimeout(function () {
|
|
39
|
+
setDeleting(false);
|
|
40
|
+
setDeleted(true);
|
|
41
|
+
}, 1200);
|
|
42
|
+
}
|
|
43
|
+
// The account is gone, so the page that showed it is gone too.
|
|
44
|
+
if (deleted) {
|
|
45
|
+
return (<Center fill>
|
|
46
|
+
<Heading level={1} size="h5">Your account is deleted</Heading>
|
|
47
|
+
<Paragraph tone="secondary" measure="none">We sent a note to dana@acme.example to say so.</Paragraph>
|
|
48
|
+
</Center>);
|
|
49
|
+
}
|
|
50
|
+
return (<Center width="page">
|
|
51
|
+
<Stack gap="xlarge">
|
|
52
|
+
<Heading level={1} size="h5">Account</Heading>
|
|
53
|
+
<SettingsSection title="Profile" description="Dana Lee, dana@acme.example.">
|
|
54
|
+
<Paragraph size="body2" measure="none">Your name and picture are in Profile Settings.</Paragraph>
|
|
55
|
+
</SettingsSection>
|
|
56
|
+
<SettingsSection tone="danger" title="Danger zone" description="These actions cannot be undone.">
|
|
57
|
+
<Cluster>
|
|
58
|
+
<Button size="small" type="textOnly" state={deleting ? 'disabled' : 'enabled'} label={shown ? 'Hide Danger Zone' : 'Show Danger Zone'} aria-expanded={shown} onClickButton={handleToggle}/>
|
|
59
|
+
</Cluster>
|
|
60
|
+
{shown && (<Stack gap="medium">
|
|
61
|
+
<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 'Deleted user'.</Paragraph>
|
|
62
|
+
{confirming ? (<>
|
|
63
|
+
<TextField id="danger-zone-collapsed-word" label={"Type ".concat(word, " to confirm")} value={typed} disabled={deleting} onChange={function (e) { return setTyped(e.target.value); }}/>
|
|
64
|
+
<Cluster gap="small">
|
|
65
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel}/>
|
|
66
|
+
<Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Account" loading={deleting} onClickButton={handleDelete}/>
|
|
67
|
+
</Cluster>
|
|
68
|
+
</>) : (<Cluster>
|
|
69
|
+
<Button size="small" type="secondary" color="danger" state="enabled" label="Delete Account" onClickButton={function () { return setConfirming(true); }}/>
|
|
70
|
+
</Cluster>)}
|
|
71
|
+
</Stack>)}
|
|
72
|
+
</SettingsSection>
|
|
73
|
+
</Stack>
|
|
74
|
+
</Center>);
|
|
75
|
+
}
|
|
@@ -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 'Deleted user'.</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.
|