oneslash-design-system 2.14.2 → 2.16.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 +15 -0
- package/dist/DESIGN.md +138 -1
- package/dist/cases/accept-invite/signed-in.d.ts +1 -0
- package/dist/cases/accept-invite/signed-in.jsx +57 -0
- package/dist/cases/accept-invite/signed-out.d.ts +1 -0
- package/dist/cases/accept-invite/signed-out.jsx +33 -0
- package/dist/cases/accept-invite.md +161 -0
- package/dist/cases/agent-asks-before-risky-action.md +29 -0
- package/dist/cases/agent-cancels-when-unanswered.md +27 -0
- package/dist/cases/agent-refuses-clearly.md +31 -0
- package/dist/cases/agent-says-what-it-is.md +29 -0
- package/dist/cases/agent-shows-progress.md +30 -0
- package/dist/cases/agent-shows-sources.md +26 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
- package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
- package/dist/cases/auth-gate-loading.md +70 -0
- package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
- package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
- package/dist/cases/check-your-email/page.d.ts +1 -0
- package/dist/cases/check-your-email/page.jsx +49 -0
- package/dist/cases/check-your-email.md +184 -0
- package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
- package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
- package/dist/cases/confirm-destructive-action.md +211 -0
- package/dist/cases/confirm-dialogs.md +36 -0
- package/dist/cases/create-modal/quick.d.ts +1 -0
- package/dist/cases/create-modal/quick.jsx +80 -0
- package/dist/cases/create-modal/with-settings.d.ts +1 -0
- package/dist/cases/create-modal/with-settings.jsx +99 -0
- package/dist/cases/create-modal.md +244 -0
- package/dist/cases/device-login/popup.d.ts +1 -0
- package/dist/cases/device-login/popup.jsx +14 -0
- package/dist/cases/device-login/provider-first.d.ts +1 -0
- package/dist/cases/device-login/provider-first.jsx +98 -0
- package/dist/cases/device-login.md +171 -0
- package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
- package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
- package/dist/cases/email-confirmed/page.d.ts +1 -0
- package/dist/cases/email-confirmed/page.jsx +21 -0
- package/dist/cases/email-confirmed.md +151 -0
- package/dist/cases/empty-list/region.d.ts +1 -0
- package/dist/cases/empty-list/region.jsx +13 -0
- package/dist/cases/empty-list/section.d.ts +1 -0
- package/dist/cases/empty-list/section.jsx +17 -0
- package/dist/cases/empty-list.md +77 -0
- package/dist/cases/empty-lists.md +35 -0
- package/dist/cases/empty-not-set-up/action.d.ts +1 -0
- package/dist/cases/empty-not-set-up/action.jsx +16 -0
- package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
- package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
- package/dist/cases/empty-not-set-up.md +88 -0
- package/dist/cases/empty-search/clear-search.d.ts +1 -0
- package/dist/cases/empty-search/clear-search.jsx +29 -0
- package/dist/cases/empty-search.md +77 -0
- package/dist/cases/error-page/full-page.d.ts +1 -0
- package/dist/cases/error-page/full-page.jsx +19 -0
- package/dist/cases/error-page/in-shell.d.ts +1 -0
- package/dist/cases/error-page/in-shell.jsx +39 -0
- package/dist/cases/error-page.md +107 -0
- package/dist/cases/feedback-form/modal.d.ts +1 -0
- package/dist/cases/feedback-form/modal.jsx +89 -0
- package/dist/cases/feedback-form.md +139 -0
- package/dist/cases/forgot-password/in-place.d.ts +1 -0
- package/dist/cases/forgot-password/in-place.jsx +155 -0
- package/dist/cases/forgot-password/own-page.d.ts +1 -0
- package/dist/cases/forgot-password/own-page.jsx +99 -0
- package/dist/cases/forgot-password.md +328 -0
- package/dist/cases/form-errors.md +32 -0
- package/dist/cases/import-checklist/modal.d.ts +1 -0
- package/dist/cases/import-checklist/modal.jsx +125 -0
- package/dist/cases/import-checklist.md +188 -0
- package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
- package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
- package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
- package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
- package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
- package/dist/cases/inline-form-feedback/toast.jsx +66 -0
- package/dist/cases/inline-form-feedback.md +237 -0
- package/dist/cases/invite-member/by-email.d.ts +1 -0
- package/dist/cases/invite-member/by-email.jsx +98 -0
- package/dist/cases/invite-member/by-link.d.ts +1 -0
- package/dist/cases/invite-member/by-link.jsx +122 -0
- package/dist/cases/invite-member.md +321 -0
- package/dist/cases/load-failure/inline.d.ts +1 -0
- package/dist/cases/load-failure/inline.jsx +52 -0
- package/dist/cases/load-failure/region.d.ts +1 -0
- package/dist/cases/load-failure/region.jsx +34 -0
- package/dist/cases/load-failure.md +155 -0
- package/dist/cases/log-out-confirm/modal.d.ts +1 -0
- package/dist/cases/log-out-confirm/modal.jsx +57 -0
- package/dist/cases/log-out-confirm.md +106 -0
- package/dist/cases/login-page/centered.d.ts +1 -0
- package/dist/cases/login-page/centered.jsx +72 -0
- package/dist/cases/login-page/email-only.d.ts +1 -0
- package/dist/cases/login-page/email-only.jsx +59 -0
- package/dist/cases/login-page/provider-first.d.ts +1 -0
- package/dist/cases/login-page/provider-first.jsx +66 -0
- package/dist/cases/login-page/split.d.ts +1 -0
- package/dist/cases/login-page/split.jsx +79 -0
- package/dist/cases/login-page.md +373 -0
- package/dist/cases/not-found-page/full-page.d.ts +1 -0
- package/dist/cases/not-found-page/full-page.jsx +16 -0
- package/dist/cases/not-found-page/in-shell.d.ts +1 -0
- package/dist/cases/not-found-page/in-shell.jsx +36 -0
- package/dist/cases/not-found-page.md +98 -0
- package/dist/cases/oauth-consent/simple.d.ts +1 -0
- package/dist/cases/oauth-consent/simple.jsx +73 -0
- package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
- package/dist/cases/oauth-consent/with-scope.jsx +89 -0
- package/dist/cases/oauth-consent.md +233 -0
- package/dist/cases/rename/inline.d.ts +1 -0
- package/dist/cases/rename/inline.jsx +58 -0
- package/dist/cases/rename/modal.d.ts +1 -0
- package/dist/cases/rename/modal.jsx +70 -0
- package/dist/cases/rename.md +205 -0
- package/dist/cases/route-loading/full-screen.d.ts +1 -0
- package/dist/cases/route-loading/full-screen.jsx +8 -0
- package/dist/cases/route-loading/region.d.ts +1 -0
- package/dist/cases/route-loading/region.jsx +26 -0
- package/dist/cases/route-loading.md +84 -0
- package/dist/cases/set-new-password/form.d.ts +1 -0
- package/dist/cases/set-new-password/form.jsx +130 -0
- package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
- package/dist/cases/set-new-password/invalid-link.jsx +50 -0
- package/dist/cases/set-new-password.md +247 -0
- package/dist/cases/sign-up-page/centered.d.ts +1 -0
- package/dist/cases/sign-up-page/centered.jsx +124 -0
- package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
- package/dist/cases/sign-up-page/provider-first.jsx +124 -0
- package/dist/cases/sign-up-page/split.d.ts +1 -0
- package/dist/cases/sign-up-page/split.jsx +134 -0
- package/dist/cases/sign-up-page.md +478 -0
- package/dist/cases/success-feedback.md +35 -0
- package/dist/cases/type-to-confirm/inline.d.ts +1 -0
- package/dist/cases/type-to-confirm/inline.jsx +69 -0
- package/dist/cases/type-to-confirm/modal.d.ts +1 -0
- package/dist/cases/type-to-confirm/modal.jsx +73 -0
- package/dist/cases/type-to-confirm.md +222 -0
- package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
- package/dist/cases/unsaved-changes-guard.md +239 -0
- package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
- package/dist/cases/upgrade-prompt/inline.jsx +52 -0
- package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
- package/dist/cases/upgrade-prompt/modal.jsx +43 -0
- package/dist/cases/upgrade-prompt.md +174 -0
- package/dist/cases.json +2073 -0
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/brandIcon.d.ts +12 -0
- package/dist/components/brandIcon.jsx +24 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/form.d.ts +11 -0
- package/dist/components/form.jsx +22 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/image.d.ts +14 -0
- package/dist/components/image.jsx +6 -0
- package/dist/components/layout.d.ts +18 -1
- package/dist/components/layout.jsx +16 -0
- package/dist/components/line.d.ts +3 -1
- package/dist/components/line.jsx +8 -1
- package/dist/components/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- package/dist/components/radioGroup.d.ts +2 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- package/dist/components/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +11 -5
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/tooltip.jsx +3 -1
- package/dist/designTokens.d.ts +1 -0
- package/dist/designTokens.js +1 -0
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.js +6 -0
- package/dist/internal/modal.d.ts +2 -0
- package/dist/internal/modal.js +21 -0
- package/dist/internal/toaster.d.ts +19 -0
- package/dist/internal/toaster.js +50 -0
- package/dist/native-mapping.json +23 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- package/dist/stories/BrandIcon.stories.d.ts +9 -0
- package/dist/stories/BrandIcon.stories.jsx +19 -0
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +116 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/Form.stories.d.ts +6 -0
- package/dist/stories/Form.stories.jsx +26 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/Image.stories.d.ts +7 -0
- package/dist/stories/Image.stories.jsx +18 -0
- package/dist/stories/Line.stories.d.ts +1 -0
- package/dist/stories/Line.stories.jsx +12 -0
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- package/dist/stories/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +36 -0
- package/dist/stories/PageComponents.stories.d.ts +2 -0
- package/dist/stories/PageComponents.stories.jsx +15 -1
- package/dist/stories/RadioGroup.stories.d.ts +1 -0
- package/dist/stories/RadioGroup.stories.jsx +14 -0
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -0
- package/dist/stories/TabsContainer.stories.d.ts +1 -0
- package/dist/stories/TabsContainer.stories.jsx +12 -0
- package/dist/stories/TextField.stories.d.ts +2 -0
- package/dist/stories/TextField.stories.jsx +22 -0
- package/dist/stories/Toaster.stories.d.ts +6 -0
- package/dist/stories/Toaster.stories.jsx +29 -0
- package/dist/tailwind-preset-auto.js +2 -1
- package/dist/tailwind-preset.js +2 -1
- package/dist/theme-auto.css +1 -0
- package/dist/theme.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/tokens.json +7 -0
- package/package.json +4 -2
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Delete confirm
|
|
2
|
+
|
|
3
|
+
A person asks to delete or remove something, and it cannot be undone.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Commentify's Delete project confirm is not danger-colored and asks a question in its body. Scindo on the web confirms removing a saved card in place, but asks 'Are you sure?' and labels its Buttons 'Confirm' and 'No'.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Follow the rule 'A confirm says exactly what will happen' for the Modal: `size="small"`, 'Cancel' first, then the action with `color="danger"`.
|
|
10
|
+
- Name the thing and what goes with it: "This deletes 'Q3 plan' and its 12 tasks."
|
|
11
|
+
- Turn the row's Buttons into 'Cancel' and a danger 'Remove' in place for the inline confirm. The rest of the row stays as it is.
|
|
12
|
+
- Give each row's Buttons an `aria-label` that starts with the visible label and names the thing, such as 'Remove Dana Lee' and 'Cancel removing Dana Lee'.
|
|
13
|
+
- Name the thing in the label so a screen reader knows which row a Button acts on.
|
|
14
|
+
- Keep one row confirming at a time. Starting a confirm on another row cancels the first.
|
|
15
|
+
- Show a toast that names the thing once it is gone.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not ask for a confirm when the action is easy to undo.
|
|
20
|
+
- Do not remove a row on the first click of its Button.
|
|
21
|
+
- Do not open a Modal for a row in a long list when the inline confirm keeps the place.
|
|
22
|
+
- Do not ask a question in place of the action, such as 'Are you sure?'.
|
|
23
|
+
|
|
24
|
+
## Option: Confirm in a Modal
|
|
25
|
+
|
|
26
|
+
Use when: The default, for any delete or remove that cannot be undone.
|
|
27
|
+
|
|
28
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `Stack`, `Surface`, `Toaster`, `dismissToast`, `toast`
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
'use client';
|
|
32
|
+
import { useEffect, useRef, useState } from 'react';
|
|
33
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
34
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
35
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
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 Button from 'oneslash-design-system/components/button';
|
|
40
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
41
|
+
|
|
42
|
+
const otherProjects = ['Website refresh', 'Hiring plan', 'Office move'];
|
|
43
|
+
|
|
44
|
+
export default function ConfirmDestructiveActionModal() {
|
|
45
|
+
// Opens on the confirm, as if the person just chose Delete Project.
|
|
46
|
+
const [open, setOpen] = useState(true);
|
|
47
|
+
const [deleting, setDeleting] = useState(false);
|
|
48
|
+
const [deleted, setDeleted] = useState(false);
|
|
49
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
50
|
+
const toastIds = useRef<string[]>([]);
|
|
51
|
+
|
|
52
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
53
|
+
useEffect(() => () => {
|
|
54
|
+
clearTimeout(timer.current);
|
|
55
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
56
|
+
toastIds.current = [];
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
60
|
+
function handleClose() {
|
|
61
|
+
if (deleting) return;
|
|
62
|
+
setOpen(false);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleDelete() {
|
|
66
|
+
if (deleting) return;
|
|
67
|
+
setDeleting(true);
|
|
68
|
+
// Stands in for the request to the server.
|
|
69
|
+
timer.current = setTimeout(() => {
|
|
70
|
+
setDeleting(false);
|
|
71
|
+
setOpen(false);
|
|
72
|
+
setDeleted(true);
|
|
73
|
+
toastIds.current.push(toast({ type: 'success', message: "Project 'Q3 plan' deleted." }));
|
|
74
|
+
}, 1200);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Center width="page">
|
|
79
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
80
|
+
<Toaster />
|
|
81
|
+
{deleted ? (
|
|
82
|
+
<Stack gap="large">
|
|
83
|
+
<Heading level={2} size="h5">Projects</Heading>
|
|
84
|
+
<Surface padding="large">
|
|
85
|
+
<List items={otherProjects} size="body1" />
|
|
86
|
+
</Surface>
|
|
87
|
+
</Stack>
|
|
88
|
+
) : (
|
|
89
|
+
<Stack gap="medium">
|
|
90
|
+
<Heading level={2} size="h5">Q3 plan</Heading>
|
|
91
|
+
<Paragraph tone="secondary" size="body2" measure="none">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>
|
|
92
|
+
<Cluster>
|
|
93
|
+
<Button size="small" type="secondary" color="danger" state="enabled" label="Delete Project" onClickButton={() => setOpen(true)} />
|
|
94
|
+
</Cluster>
|
|
95
|
+
</Stack>
|
|
96
|
+
)}
|
|
97
|
+
<Modal
|
|
98
|
+
isOpen={open}
|
|
99
|
+
size="small"
|
|
100
|
+
title="Delete Project"
|
|
101
|
+
onClose={handleClose}
|
|
102
|
+
actions={
|
|
103
|
+
<>
|
|
104
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
105
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={handleDelete} />
|
|
106
|
+
</>
|
|
107
|
+
}
|
|
108
|
+
>
|
|
109
|
+
<Paragraph measure="none">This deletes 'Q3 plan' and its 12 tasks.</Paragraph>
|
|
110
|
+
<Paragraph tone="secondary" size="body2" measure="none">Files attached to the tasks stay in Files.</Paragraph>
|
|
111
|
+
</Modal>
|
|
112
|
+
</Center>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Option: Confirm in the row
|
|
118
|
+
|
|
119
|
+
Use when: The action is on a row inside a dense list, and a Modal would lose the place.
|
|
120
|
+
|
|
121
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `Toaster`, `dismissToast`, `toast`
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
'use client';
|
|
125
|
+
import { useEffect, useRef, useState } from 'react';
|
|
126
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
127
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
128
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
129
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
130
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
131
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
132
|
+
import Button from 'oneslash-design-system/components/button';
|
|
133
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
134
|
+
|
|
135
|
+
const people = [
|
|
136
|
+
{ id: 'dana', name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
|
|
137
|
+
{ id: 'omar', name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
|
|
138
|
+
{ id: 'mei', name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
|
|
139
|
+
{ id: 'luis', name: 'Luis Ortega', email: 'luis@example.com', role: 'Guest' },
|
|
140
|
+
{ id: 'ada', name: 'Ada Brooks', email: 'ada@example.com', role: 'Member' },
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
export default function ConfirmDestructiveActionInline() {
|
|
144
|
+
const [members, setMembers] = useState(people);
|
|
145
|
+
// Opens with one row confirming, as if the person just chose Remove on it.
|
|
146
|
+
const [confirming, setConfirming] = useState<string | null>('omar');
|
|
147
|
+
const [removing, setRemoving] = useState(false);
|
|
148
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
149
|
+
const toastIds = useRef<string[]>([]);
|
|
150
|
+
|
|
151
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
152
|
+
useEffect(() => () => {
|
|
153
|
+
clearTimeout(timer.current);
|
|
154
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
155
|
+
toastIds.current = [];
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
function handleRemove(id: string, name: string) {
|
|
159
|
+
if (removing) return;
|
|
160
|
+
setRemoving(true);
|
|
161
|
+
// Stands in for the request to the server.
|
|
162
|
+
timer.current = setTimeout(() => {
|
|
163
|
+
setRemoving(false);
|
|
164
|
+
setConfirming(null);
|
|
165
|
+
setMembers((list) => list.filter((m) => m.id !== id));
|
|
166
|
+
toastIds.current.push(toast({ type: 'success', message: `${name} removed from Acme Design.` }));
|
|
167
|
+
}, 1200);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<Center width="page">
|
|
172
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
173
|
+
<Toaster />
|
|
174
|
+
<Stack gap="large">
|
|
175
|
+
<Stack gap="small">
|
|
176
|
+
<Heading level={2} size="h5">Members</Heading>
|
|
177
|
+
<Paragraph tone="secondary" size="body2" measure="none">People who can open Acme Design.</Paragraph>
|
|
178
|
+
</Stack>
|
|
179
|
+
<TableContainer>
|
|
180
|
+
{members.map((m) => (
|
|
181
|
+
<TableRow key={m.id}>
|
|
182
|
+
<TableCell>{m.name}</TableCell>
|
|
183
|
+
<TableCell>{m.email}</TableCell>
|
|
184
|
+
<TableCell width="100px">{m.role}</TableCell>
|
|
185
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
186
|
+
<TableCell width="168px">
|
|
187
|
+
{confirming === m.id ? (
|
|
188
|
+
<Cluster gap="small">
|
|
189
|
+
<Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel removing ${m.name}`} onClickButton={() => setConfirming(null)} />
|
|
190
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={`Remove ${m.name}`} loading={removing} onClickButton={() => handleRemove(m.id, m.name)} />
|
|
191
|
+
</Cluster>
|
|
192
|
+
) : (
|
|
193
|
+
<Cluster gap="small">
|
|
194
|
+
<Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Remove" aria-label={`Remove ${m.name}`} onClickButton={() => setConfirming(m.id)} />
|
|
195
|
+
</Cluster>
|
|
196
|
+
)}
|
|
197
|
+
</TableCell>
|
|
198
|
+
</TableRow>
|
|
199
|
+
))}
|
|
200
|
+
</TableContainer>
|
|
201
|
+
</Stack>
|
|
202
|
+
</Center>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Native
|
|
208
|
+
|
|
209
|
+
On Apple use a system `confirmationDialog` or `.alert`, with the action in the `.destructive` role and 'Cancel' in the `.cancel` role.
|
|
210
|
+
|
|
211
|
+
Seen in: Commentify, Scindo.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# A confirm says exactly what will happen
|
|
2
|
+
|
|
3
|
+
An action a person takes themselves needs their yes before it happens. An action the agent wants to take follows the rule 'An agent asks before a risky action', a card in the conversation, not this one.
|
|
4
|
+
|
|
5
|
+
## Answer
|
|
6
|
+
|
|
7
|
+
A confirm is a Modal with `size="small"`. Its title names the action in Title Case, such as 'Delete Project'. The body says in one or two sentences what will happen and what is kept. Two Buttons sit in the Modal's `actions`. 'Cancel' comes first, a `<Button type="tertiary" size="small">`. Then comes the action, a `<Button type="primary" size="small">` labelled in Title Case with the same verb as the title. When the action destroys or removes something, the action Button also has `color="danger"`. One case differs: 'Unsaved changes'. Its guard may have three Buttons, 'Cancel', "Don't Save" and 'Save', in that order. When it has two, its safe Button reads 'Keep Editing'. Escape and a click outside the Modal mean Cancel. While the request runs, the action Button is `loading` and keeps its label, and 'Cancel' is `state="disabled"`. The Modal stays open. It still calls `onClose` on Escape or a click outside, and the page ignores that call until the request ends. If the request fails, the Modal stays open and shows an inline error Alert at the top of its body, as the rule 'A form error shows next to the problem' says. When the action works, the Modal closes. If the thing is still on screen, the change shows where it is. If the thing is gone, a toast names it, as the rule 'Success shows where the person is looking' says.
|
|
8
|
+
|
|
9
|
+
**Not built yet:** No Commentify confirm Modal uses `color="danger"`, and two of them label Cancel 'No'. Scindo on the web makes Cancel a secondary Button in some confirms and a tertiary one in others. It leaves its Delete Task and Remove Member confirms uncolored. Scindo on the web revokes an API key, and Commentify revokes an agent client, with no confirm.
|
|
10
|
+
|
|
11
|
+
## Why
|
|
12
|
+
|
|
13
|
+
A confirm is the last chance to stop a mistake. It has to say exactly what will happen, and the safe choice has to be easy to find.
|
|
14
|
+
|
|
15
|
+
## Do
|
|
16
|
+
|
|
17
|
+
- Name the thing in the body: "This deletes 'Q3 plan' and its 12 tasks."
|
|
18
|
+
- Say what is kept: 'Files in the repository are not changed.'
|
|
19
|
+
- Give the title and the action the same verb, in Title Case: 'Delete Project' has a 'Delete' Button.
|
|
20
|
+
- Disable 'Cancel' and ignore `onClose` while the request runs.
|
|
21
|
+
- Close the Modal when the action works. Show the change where the thing is, or a toast that names it if the thing is gone.
|
|
22
|
+
|
|
23
|
+
## Don't
|
|
24
|
+
|
|
25
|
+
- Do not label Cancel 'No' or 'Close'.
|
|
26
|
+
- Do not label the action 'Yes, Delete', 'Confirm' or 'OK'.
|
|
27
|
+
- Do not title the Modal 'Confirm Deletion' or 'Sure?'.
|
|
28
|
+
- Do not change the action's label while it is loading, such as to 'Deleting…'.
|
|
29
|
+
- Do not replace the Modal body with a spinner, or close the Modal, while the request runs.
|
|
30
|
+
- Do not ask for a confirm when the action is easy to undo.
|
|
31
|
+
|
|
32
|
+
## Native
|
|
33
|
+
|
|
34
|
+
On Apple use a system `confirmationDialog` or `.alert`, with the action in the `.destructive` role when it destroys or removes something. Never build a sheet by hand for a confirm.
|
|
35
|
+
|
|
36
|
+
Seen in: Commentify, Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CreateModalQuick(): import("react").JSX.Element;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import Modal from '../../components/modal';
|
|
13
|
+
import Surface from '../../components/surface';
|
|
14
|
+
import Heading from '../../components/heading';
|
|
15
|
+
import List from '../../components/list';
|
|
16
|
+
import Form from '../../components/form';
|
|
17
|
+
import TextField from '../../components/textField';
|
|
18
|
+
import Button from '../../components/button';
|
|
19
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
20
|
+
export default function CreateModalQuick() {
|
|
21
|
+
var _a = useState(['Website refresh', 'Hiring plan', 'Office move']), projects = _a[0], setProjects = _a[1];
|
|
22
|
+
// Opens on the Modal, as if the person just chose Create Project.
|
|
23
|
+
var _b = useState(true), open = _b[0], setOpen = _b[1];
|
|
24
|
+
var _c = useState('Q4 budget'), name = _c[0], setName = _c[1];
|
|
25
|
+
var _d = useState(''), nameError = _d[0], setNameError = _d[1];
|
|
26
|
+
var _e = useState(false), creating = _e[0], setCreating = _e[1];
|
|
27
|
+
var timer = useRef();
|
|
28
|
+
// Stops the request if the example goes away before it ends.
|
|
29
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
30
|
+
var next = name.trim();
|
|
31
|
+
function handleOpen() {
|
|
32
|
+
setName('');
|
|
33
|
+
setNameError('');
|
|
34
|
+
setOpen(true);
|
|
35
|
+
}
|
|
36
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
37
|
+
function handleClose() {
|
|
38
|
+
if (creating)
|
|
39
|
+
return;
|
|
40
|
+
setOpen(false);
|
|
41
|
+
}
|
|
42
|
+
function handleCreate() {
|
|
43
|
+
if (creating || next === '')
|
|
44
|
+
return;
|
|
45
|
+
setNameError('');
|
|
46
|
+
setCreating(true);
|
|
47
|
+
// Stands in for the request to the server.
|
|
48
|
+
timer.current = setTimeout(function () {
|
|
49
|
+
setCreating(false);
|
|
50
|
+
// The server already has these names. Type one to see the request fail.
|
|
51
|
+
if (projects.some(function (p) { return p.toLowerCase() === next.toLowerCase(); })) {
|
|
52
|
+
setNameError("A project named '".concat(next, "' already exists. Choose another name."));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setProjects(function (list) { return __spreadArray([next], list, true); });
|
|
56
|
+
setOpen(false);
|
|
57
|
+
}, 1200);
|
|
58
|
+
}
|
|
59
|
+
return (<Center width="page">
|
|
60
|
+
<Stack gap="large">
|
|
61
|
+
<Cluster>
|
|
62
|
+
<Heading level={1} size="h5">Projects</Heading>
|
|
63
|
+
<Button size="small" type="primary" state="enabled" label="Create Project" decoIcon="Plus" onClickButton={handleOpen}/>
|
|
64
|
+
</Cluster>
|
|
65
|
+
{/* The new project shows at the top of the list, so no toast is needed. */}
|
|
66
|
+
<Surface padding="large">
|
|
67
|
+
<List items={projects} size="body1"/>
|
|
68
|
+
</Surface>
|
|
69
|
+
</Stack>
|
|
70
|
+
<Modal isOpen={open} size="small" initialFocus="body" title="Create Project" onClose={handleClose} actions={<>
|
|
71
|
+
<Button size="small" type="tertiary" state={creating ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
72
|
+
<Button size="small" type="primary" state={next === '' ? 'disabled' : 'enabled'} label="Create" loading={creating} onClickButton={handleCreate}/>
|
|
73
|
+
</>}>
|
|
74
|
+
{/* The Form lets Enter in the field create too. */}
|
|
75
|
+
<Form aria-label="Create project" onSubmit={handleCreate}>
|
|
76
|
+
<TextField id="create-modal-name" label="Project name" placeholder="Q4 budget" value={name} disabled={creating} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
|
|
77
|
+
</Form>
|
|
78
|
+
</Modal>
|
|
79
|
+
</Center>);
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CreateModalWithSettings(): import("react").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import Modal from '../../components/modal';
|
|
13
|
+
import Surface from '../../components/surface';
|
|
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 TextField from '../../components/textField';
|
|
19
|
+
import RadioGroup from '../../components/radioGroup';
|
|
20
|
+
import Checkbox from '../../components/checkBox';
|
|
21
|
+
import Button from '../../components/button';
|
|
22
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
23
|
+
var visibilityOptions = [
|
|
24
|
+
{ value: 'workspace', label: 'Everyone in Acme Design', secondLabel: 'Anyone in the workspace can find and open it.' },
|
|
25
|
+
{ value: 'private', label: 'Only people you invite', secondLabel: 'It stays hidden until you add people.' },
|
|
26
|
+
];
|
|
27
|
+
export default function CreateModalWithSettings() {
|
|
28
|
+
var _a = useState(['Website refresh', 'Hiring plan', 'Office move']), projects = _a[0], setProjects = _a[1];
|
|
29
|
+
// Opens on the Modal, as if the person just chose Create Project.
|
|
30
|
+
var _b = useState(true), open = _b[0], setOpen = _b[1];
|
|
31
|
+
var _c = useState('Q4 budget'), name = _c[0], setName = _c[1];
|
|
32
|
+
// Safe defaults, so the name is the only thing the person has to give.
|
|
33
|
+
var _d = useState('workspace'), visibility = _d[0], setVisibility = _d[1];
|
|
34
|
+
var _e = useState(true), starterTasks = _e[0], setStarterTasks = _e[1];
|
|
35
|
+
var _f = useState(''), nameError = _f[0], setNameError = _f[1];
|
|
36
|
+
var _g = useState(false), creating = _g[0], setCreating = _g[1];
|
|
37
|
+
var timer = useRef();
|
|
38
|
+
// Stops the request if the example goes away before it ends.
|
|
39
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
40
|
+
var next = name.trim();
|
|
41
|
+
function handleOpen() {
|
|
42
|
+
setName('');
|
|
43
|
+
setVisibility('workspace');
|
|
44
|
+
setStarterTasks(true);
|
|
45
|
+
setNameError('');
|
|
46
|
+
setOpen(true);
|
|
47
|
+
}
|
|
48
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
49
|
+
function handleClose() {
|
|
50
|
+
if (creating)
|
|
51
|
+
return;
|
|
52
|
+
setOpen(false);
|
|
53
|
+
}
|
|
54
|
+
function handleCreate() {
|
|
55
|
+
if (creating || next === '')
|
|
56
|
+
return;
|
|
57
|
+
setNameError('');
|
|
58
|
+
setCreating(true);
|
|
59
|
+
// Stands in for the request to the server.
|
|
60
|
+
timer.current = setTimeout(function () {
|
|
61
|
+
setCreating(false);
|
|
62
|
+
// The server already has these names. Type one to see the request fail.
|
|
63
|
+
if (projects.some(function (p) { return p.toLowerCase() === next.toLowerCase(); })) {
|
|
64
|
+
setNameError("A project named '".concat(next, "' already exists. Choose another name."));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setProjects(function (list) { return __spreadArray([next], list, true); });
|
|
68
|
+
setOpen(false);
|
|
69
|
+
}, 1200);
|
|
70
|
+
}
|
|
71
|
+
return (<Center width="page">
|
|
72
|
+
<Stack gap="large">
|
|
73
|
+
<Cluster>
|
|
74
|
+
<Heading level={1} size="h5">Projects</Heading>
|
|
75
|
+
<Button size="small" type="primary" state="enabled" label="Create Project" decoIcon="Plus" onClickButton={handleOpen}/>
|
|
76
|
+
</Cluster>
|
|
77
|
+
{/* The new project shows at the top of the list, so no toast is needed. */}
|
|
78
|
+
<Surface padding="large">
|
|
79
|
+
<List items={projects} size="body1"/>
|
|
80
|
+
</Surface>
|
|
81
|
+
</Stack>
|
|
82
|
+
<Modal isOpen={open} size="small" initialFocus="body" title="Create Project" onClose={handleClose} actions={<>
|
|
83
|
+
<Button size="small" type="tertiary" state={creating ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
84
|
+
<Button size="small" type="primary" state={next === '' ? 'disabled' : 'enabled'} label="Create" loading={creating} onClickButton={handleCreate}/>
|
|
85
|
+
</>}>
|
|
86
|
+
{/* The Form lets Enter in the name field create too. */}
|
|
87
|
+
<Form aria-label="Create project" onSubmit={handleCreate}>
|
|
88
|
+
<TextField id="create-modal-settings-name" label="Project name" placeholder="Q4 budget" value={name} disabled={creating} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
|
|
89
|
+
<Stack gap="small">
|
|
90
|
+
{/* The line above names the choice on screen, and `aria-label` names it for a screen reader.
|
|
91
|
+
RadioGroup has no disabled state, so it stays live while the request runs. */}
|
|
92
|
+
<Paragraph tone="secondary" size="body2" measure="none">Who can see it</Paragraph>
|
|
93
|
+
<RadioGroup aria-label="Who can see it" options={visibilityOptions} selectedValue={visibility} onChange={setVisibility}/>
|
|
94
|
+
</Stack>
|
|
95
|
+
<Checkbox label="Add starter tasks" secondLabel="A short list to plan the first week. You can delete them." checked={starterTasks} disabled={creating} onChange={setStarterTasks}/>
|
|
96
|
+
</Form>
|
|
97
|
+
</Modal>
|
|
98
|
+
</Center>);
|
|
99
|
+
}
|