oneslash-design-system 2.15.0 → 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.
Files changed (195) hide show
  1. package/README.md +6 -1
  2. package/dist/DESIGN.md +75 -71
  3. package/dist/cases/accept-invite/signed-in.d.ts +1 -0
  4. package/dist/cases/accept-invite/signed-in.jsx +57 -0
  5. package/dist/cases/accept-invite/signed-out.d.ts +1 -0
  6. package/dist/cases/accept-invite/signed-out.jsx +33 -0
  7. package/dist/cases/accept-invite.md +161 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +1 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +1 -1
  10. package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
  11. package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
  12. package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
  13. package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
  14. package/dist/cases/auth-gate-loading.md +70 -0
  15. package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
  16. package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
  17. package/dist/cases/check-your-email/page.d.ts +1 -0
  18. package/dist/cases/check-your-email/page.jsx +49 -0
  19. package/dist/cases/check-your-email.md +184 -0
  20. package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
  21. package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
  22. package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
  23. package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
  24. package/dist/cases/confirm-destructive-action.md +211 -0
  25. package/dist/cases/confirm-dialogs.md +36 -0
  26. package/dist/cases/create-modal/quick.d.ts +1 -0
  27. package/dist/cases/create-modal/quick.jsx +80 -0
  28. package/dist/cases/create-modal/with-settings.d.ts +1 -0
  29. package/dist/cases/create-modal/with-settings.jsx +99 -0
  30. package/dist/cases/create-modal.md +244 -0
  31. package/dist/cases/device-login/popup.d.ts +1 -0
  32. package/dist/cases/device-login/popup.jsx +14 -0
  33. package/dist/cases/device-login/provider-first.d.ts +1 -0
  34. package/dist/cases/device-login/provider-first.jsx +98 -0
  35. package/dist/cases/device-login.md +171 -0
  36. package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
  37. package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
  38. package/dist/cases/email-confirmed/page.d.ts +1 -0
  39. package/dist/cases/email-confirmed/page.jsx +21 -0
  40. package/dist/cases/email-confirmed.md +151 -0
  41. package/dist/cases/empty-list/region.d.ts +1 -0
  42. package/dist/cases/empty-list/region.jsx +13 -0
  43. package/dist/cases/empty-list/section.d.ts +1 -0
  44. package/dist/cases/empty-list/section.jsx +17 -0
  45. package/dist/cases/empty-list.md +77 -0
  46. package/dist/cases/empty-lists.md +35 -0
  47. package/dist/cases/empty-not-set-up/action.d.ts +1 -0
  48. package/dist/cases/empty-not-set-up/action.jsx +16 -0
  49. package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
  50. package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
  51. package/dist/cases/empty-not-set-up.md +88 -0
  52. package/dist/cases/empty-search/clear-search.d.ts +1 -0
  53. package/dist/cases/empty-search/clear-search.jsx +29 -0
  54. package/dist/cases/empty-search.md +77 -0
  55. package/dist/cases/error-page/full-page.d.ts +1 -0
  56. package/dist/cases/error-page/full-page.jsx +19 -0
  57. package/dist/cases/error-page/in-shell.d.ts +1 -0
  58. package/dist/cases/error-page/in-shell.jsx +39 -0
  59. package/dist/cases/error-page.md +107 -0
  60. package/dist/cases/feedback-form/modal.d.ts +1 -0
  61. package/dist/cases/feedback-form/modal.jsx +89 -0
  62. package/dist/cases/feedback-form.md +139 -0
  63. package/dist/cases/forgot-password/in-place.d.ts +1 -0
  64. package/dist/cases/forgot-password/in-place.jsx +155 -0
  65. package/dist/cases/forgot-password/own-page.d.ts +1 -0
  66. package/dist/cases/forgot-password/own-page.jsx +99 -0
  67. package/dist/cases/forgot-password.md +328 -0
  68. package/dist/cases/form-errors.md +32 -0
  69. package/dist/cases/import-checklist/modal.d.ts +1 -0
  70. package/dist/cases/import-checklist/modal.jsx +125 -0
  71. package/dist/cases/import-checklist.md +188 -0
  72. package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
  73. package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
  74. package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
  75. package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
  76. package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
  77. package/dist/cases/inline-form-feedback/toast.jsx +66 -0
  78. package/dist/cases/inline-form-feedback.md +237 -0
  79. package/dist/cases/invite-member/by-email.d.ts +1 -0
  80. package/dist/cases/invite-member/by-email.jsx +98 -0
  81. package/dist/cases/invite-member/by-link.d.ts +1 -0
  82. package/dist/cases/invite-member/by-link.jsx +122 -0
  83. package/dist/cases/invite-member.md +321 -0
  84. package/dist/cases/load-failure/inline.d.ts +1 -0
  85. package/dist/cases/load-failure/inline.jsx +52 -0
  86. package/dist/cases/load-failure/region.d.ts +1 -0
  87. package/dist/cases/load-failure/region.jsx +34 -0
  88. package/dist/cases/load-failure.md +155 -0
  89. package/dist/cases/log-out-confirm/modal.d.ts +1 -0
  90. package/dist/cases/log-out-confirm/modal.jsx +57 -0
  91. package/dist/cases/log-out-confirm.md +106 -0
  92. package/dist/cases/login-page/centered.jsx +10 -7
  93. package/dist/cases/login-page/email-only.jsx +11 -8
  94. package/dist/cases/login-page/provider-first.jsx +12 -9
  95. package/dist/cases/login-page/split.jsx +11 -8
  96. package/dist/cases/login-page.md +58 -41
  97. package/dist/cases/not-found-page/full-page.d.ts +1 -0
  98. package/dist/cases/not-found-page/full-page.jsx +16 -0
  99. package/dist/cases/not-found-page/in-shell.d.ts +1 -0
  100. package/dist/cases/not-found-page/in-shell.jsx +36 -0
  101. package/dist/cases/not-found-page.md +98 -0
  102. package/dist/cases/oauth-consent/simple.d.ts +1 -0
  103. package/dist/cases/oauth-consent/simple.jsx +73 -0
  104. package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
  105. package/dist/cases/oauth-consent/with-scope.jsx +89 -0
  106. package/dist/cases/oauth-consent.md +233 -0
  107. package/dist/cases/rename/inline.d.ts +1 -0
  108. package/dist/cases/rename/inline.jsx +58 -0
  109. package/dist/cases/rename/modal.d.ts +1 -0
  110. package/dist/cases/rename/modal.jsx +70 -0
  111. package/dist/cases/rename.md +205 -0
  112. package/dist/cases/route-loading/full-screen.d.ts +1 -0
  113. package/dist/cases/route-loading/full-screen.jsx +8 -0
  114. package/dist/cases/route-loading/region.d.ts +1 -0
  115. package/dist/cases/route-loading/region.jsx +26 -0
  116. package/dist/cases/route-loading.md +84 -0
  117. package/dist/cases/set-new-password/form.d.ts +1 -0
  118. package/dist/cases/set-new-password/form.jsx +130 -0
  119. package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
  120. package/dist/cases/set-new-password/invalid-link.jsx +50 -0
  121. package/dist/cases/set-new-password.md +247 -0
  122. package/dist/cases/sign-up-page/centered.d.ts +1 -0
  123. package/dist/cases/sign-up-page/centered.jsx +124 -0
  124. package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
  125. package/dist/cases/sign-up-page/provider-first.jsx +124 -0
  126. package/dist/cases/sign-up-page/split.d.ts +1 -0
  127. package/dist/cases/sign-up-page/split.jsx +134 -0
  128. package/dist/cases/sign-up-page.md +478 -0
  129. package/dist/cases/success-feedback.md +35 -0
  130. package/dist/cases/type-to-confirm/inline.d.ts +1 -0
  131. package/dist/cases/type-to-confirm/inline.jsx +69 -0
  132. package/dist/cases/type-to-confirm/modal.d.ts +1 -0
  133. package/dist/cases/type-to-confirm/modal.jsx +73 -0
  134. package/dist/cases/type-to-confirm.md +222 -0
  135. package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
  136. package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
  137. package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
  138. package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
  139. package/dist/cases/unsaved-changes-guard.md +239 -0
  140. package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
  141. package/dist/cases/upgrade-prompt/inline.jsx +52 -0
  142. package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
  143. package/dist/cases/upgrade-prompt/modal.jsx +43 -0
  144. package/dist/cases/upgrade-prompt.md +174 -0
  145. package/dist/cases.json +1856 -39
  146. package/dist/components/alert.d.ts +3 -1
  147. package/dist/components/alert.jsx +6 -4
  148. package/dist/components/emptyBox.d.ts +6 -1
  149. package/dist/components/emptyBox.jsx +4 -2
  150. package/dist/components/heading.d.ts +2 -2
  151. package/dist/components/loadingScreen.d.ts +5 -1
  152. package/dist/components/loadingScreen.jsx +4 -2
  153. package/dist/components/modal.d.ts +2 -1
  154. package/dist/components/modal.jsx +20 -8
  155. package/dist/components/radioGroup.d.ts +2 -1
  156. package/dist/components/radioGroup.jsx +2 -2
  157. package/dist/components/select.d.ts +2 -1
  158. package/dist/components/select.jsx +4 -2
  159. package/dist/components/tab.jsx +3 -2
  160. package/dist/components/tabsContainer.d.ts +4 -1
  161. package/dist/components/tabsContainer.jsx +7 -3
  162. package/dist/components/textField.d.ts +5 -1
  163. package/dist/components/textField.jsx +7 -3
  164. package/dist/components/toaster.d.ts +12 -0
  165. package/dist/components/toaster.jsx +103 -0
  166. package/dist/internal/alert.d.ts +4 -0
  167. package/dist/internal/alert.js +6 -0
  168. package/dist/internal/modal.d.ts +2 -0
  169. package/dist/internal/modal.js +21 -0
  170. package/dist/internal/toaster.d.ts +19 -0
  171. package/dist/internal/toaster.js +50 -0
  172. package/dist/native-mapping.json +6 -0
  173. package/dist/stories/Alert.stories.d.ts +1 -0
  174. package/dist/stories/Alert.stories.jsx +16 -0
  175. package/dist/stories/Cases.generated.stories.d.ts +52 -0
  176. package/dist/stories/Cases.generated.stories.jsx +104 -0
  177. package/dist/stories/EmptyBox.stories.d.ts +2 -0
  178. package/dist/stories/EmptyBox.stories.jsx +16 -0
  179. package/dist/stories/Heading.stories.d.ts +6 -0
  180. package/dist/stories/Heading.stories.jsx +10 -0
  181. package/dist/stories/LoadingScreen.stories.d.ts +1 -0
  182. package/dist/stories/LoadingScreen.stories.jsx +8 -0
  183. package/dist/stories/Modal.stories.d.ts +2 -0
  184. package/dist/stories/Modal.stories.jsx +36 -0
  185. package/dist/stories/RadioGroup.stories.d.ts +1 -0
  186. package/dist/stories/RadioGroup.stories.jsx +14 -0
  187. package/dist/stories/Select.stories.d.ts +1 -0
  188. package/dist/stories/Select.stories.jsx +14 -0
  189. package/dist/stories/TabsContainer.stories.d.ts +1 -0
  190. package/dist/stories/TabsContainer.stories.jsx +12 -0
  191. package/dist/stories/TextField.stories.d.ts +2 -0
  192. package/dist/stories/TextField.stories.jsx +22 -0
  193. package/dist/stories/Toaster.stories.d.ts +6 -0
  194. package/dist/stories/Toaster.stories.jsx +29 -0
  195. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import TabsContainer from '../../components/tabsContainer';
5
+ import Tab from '../../components/tab';
6
+ import Form from '../../components/form';
7
+ import Alert from '../../components/alert';
8
+ import TextField from '../../components/textField';
9
+ import Button from '../../components/button';
10
+ import Line from '../../components/line';
11
+ import BrandIcon from '../../components/brandIcon';
12
+ import { Center } from '../../components/layout';
13
+ // The product's mark. A real app passes its own file.
14
+ var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
15
+ // A real app passes the router from its framework, such as Next's useRouter().
16
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
17
+ // A small check: some text, an @, then some text.
18
+ function looksLikeEmail(value) {
19
+ return /^[^@\s]+@[^@\s]+$/.test(value);
20
+ }
21
+ export default function CheckYourEmailAlertOnLogin() {
22
+ // Opens as the login page does right after sign-up. The words are the same whether or not the address
23
+ // already had an account, so the page never says which.
24
+ var _a = useState('We sent a link to ada@example.com. Open it to continue, or log in below.'), notice = _a[0], setNotice = _a[1];
25
+ var _b = useState('ada@example.com'), email = _b[0], setEmail = _b[1];
26
+ var _c = useState(''), password = _c[0], setPassword = _c[1];
27
+ var _d = useState(''), error = _d[0], setError = _d[1];
28
+ var _e = useState(''), emailError = _e[0], setEmailError = _e[1];
29
+ var _f = useState(''), passwordError = _f[0], setPasswordError = _f[1];
30
+ var _g = useState(false), loading = _g[0], setLoading = _g[1];
31
+ var timer = useRef();
32
+ // Stops the request if the example goes away before it ends.
33
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
34
+ function handleSubmit() {
35
+ if (loading)
36
+ return;
37
+ setNotice('');
38
+ setError('');
39
+ setEmailError('');
40
+ setPasswordError('');
41
+ if (!email.trim()) {
42
+ setEmailError('Enter your email.');
43
+ return;
44
+ }
45
+ if (!looksLikeEmail(email.trim())) {
46
+ setEmailError('Enter an email address, like name@example.com.');
47
+ return;
48
+ }
49
+ if (!password) {
50
+ setPasswordError('Enter your password.');
51
+ return;
52
+ }
53
+ setLoading(true);
54
+ // Stands in for the request to the server.
55
+ timer.current = setTimeout(function () {
56
+ setLoading(false);
57
+ setError('That email and password do not match.');
58
+ }, 1200);
59
+ }
60
+ return (<Center fill>
61
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
62
+ <TabsContainer fill>
63
+ <Tab label="Log In" isSelected onClickTab={function () { }}/>
64
+ <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={function () { }}/>
65
+ </TabsContainer>
66
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
67
+ {/* It says what to do next, so it stays until the person submits the form: no close button, and it does not close on its own. */}
68
+ {notice && <Alert type="success" variant="inline" message={notice} autoDismiss={false}/>}
69
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
70
+ <TextField id="check-your-email-login-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
71
+ <TextField id="check-your-email-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
72
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
73
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot Password?"/>
74
+ </Form>
75
+ <Line label="or"/>
76
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
77
+ </Center>);
78
+ }
@@ -0,0 +1 @@
1
+ export default function CheckYourEmailPage(): import("react").JSX.Element;
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Mail } from 'lucide-react';
4
+ import Icon from '../../components/icon';
5
+ import Heading from '../../components/heading';
6
+ import Paragraph from '../../components/paragraph';
7
+ import Button from '../../components/button';
8
+ import { Center, Stack } from '../../components/layout';
9
+ // A real app passes the router from its framework, such as Next's useRouter().
10
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
11
+ // A real app passes the address the person signed up with.
12
+ var address = 'ada@example.com';
13
+ export default function CheckYourEmailPage() {
14
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
15
+ var _b = useState(false), sent = _b[0], setSent = _b[1];
16
+ var timer = useRef();
17
+ // Stops the request if the example goes away before it ends.
18
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
19
+ // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.
20
+ useEffect(function () {
21
+ if (!sent)
22
+ return;
23
+ var timer = setTimeout(function () { return setSent(false); }, 2000);
24
+ return function () { return clearTimeout(timer); };
25
+ }, [sent]);
26
+ function handleSendAgain() {
27
+ // One click sends one email: clicks while it sends or reads 'Sent' do nothing.
28
+ if (loading || sent)
29
+ return;
30
+ setLoading(true);
31
+ // Stands in for the request to the server.
32
+ // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'
33
+ timer.current = setTimeout(function () {
34
+ setLoading(false);
35
+ setSent(true);
36
+ }, 1200);
37
+ }
38
+ return (<Center fill>
39
+ <Icon icon={Mail} size="large" color="secondary"/>
40
+ <Stack gap="medium">
41
+ <Heading level={1} size="h5">Check your email</Heading>
42
+ <Paragraph tone="secondary" measure="none">We sent a link to {address}. Open it to continue.</Paragraph>
43
+ </Stack>
44
+ <Stack gap="large">
45
+ <Button size="medium" type="secondary" state="enabled" label={sent ? 'Sent' : 'Send Again'} loading={loading} onClickButton={handleSendAgain}/>
46
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
47
+ </Stack>
48
+ </Center>);
49
+ }
@@ -0,0 +1,184 @@
1
+ # Check your email
2
+
3
+ A person signed up, and the product sent a link to confirm their email.
4
+
5
+ **Not built yet:** Neither Commentify nor Scindo can send the email again from the check-your-email screen. Both show their success Alert above the login form with a close button, and it starts 'Account created.', even for an address that already had an account.
6
+
7
+ ## Do
8
+
9
+ - Name the page 'Check your email' in a `Heading` with `level={1}`, with a `Mail` icon above it.
10
+ - Say in one line which address the link went to, in words that are true whether or not it already had an account: 'We sent a link to ada@example.com. Open it to continue.'
11
+ - Offer 'Send Again' and a text-only 'Back to Login'.
12
+ - Show `loading` on 'Send Again' while it sends, then 'Sent' for 2 seconds.
13
+ - Ignore 'Send Again' while it sends and while it reads 'Sent', so one click sends one email. Let the server limit how often it sends.
14
+ - Put the success Alert above the login form with no close button and `autoDismiss={false}`: it says what to do next, so it stays until the person submits the form.
15
+
16
+ ## Don't
17
+
18
+ - Do not leave the sign-up form on screen once the link is sent.
19
+ - Do not say that an account was created, or that one already exists.
20
+ - Do not make the person close the success Alert, and do not let it close on its own before they have read it.
21
+ - Do not change 'Send Again' to 'Sending…' while it sends.
22
+
23
+ ## Option: Page in place of the form
24
+
25
+ Use when: The person must leave for their inbox before they can go on.
26
+
27
+ Uses: `Button`, `Center`, `Heading`, `Icon`, `Paragraph`, `Stack`
28
+
29
+ ```tsx
30
+ 'use client';
31
+ import { useEffect, useRef, useState } from 'react';
32
+ import { Mail } from 'lucide-react';
33
+ import Icon from 'oneslash-design-system/components/icon';
34
+ import Heading from 'oneslash-design-system/components/heading';
35
+ import Paragraph from 'oneslash-design-system/components/paragraph';
36
+ import Button from 'oneslash-design-system/components/button';
37
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
38
+
39
+ // A real app passes the router from its framework, such as Next's useRouter().
40
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
41
+
42
+ // A real app passes the address the person signed up with.
43
+ const address = 'ada@example.com';
44
+
45
+ export default function CheckYourEmailPage() {
46
+ const [loading, setLoading] = useState(false);
47
+ const [sent, setSent] = useState(false);
48
+ const timer = useRef<ReturnType<typeof setTimeout>>();
49
+
50
+ // Stops the request if the example goes away before it ends.
51
+ useEffect(() => () => clearTimeout(timer.current), []);
52
+
53
+ // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.
54
+ useEffect(() => {
55
+ if (!sent) return;
56
+ const timer = setTimeout(() => setSent(false), 2000);
57
+ return () => clearTimeout(timer);
58
+ }, [sent]);
59
+
60
+ function handleSendAgain() {
61
+ // One click sends one email: clicks while it sends or reads 'Sent' do nothing.
62
+ if (loading || sent) return;
63
+ setLoading(true);
64
+ // Stands in for the request to the server.
65
+ // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'
66
+ timer.current = setTimeout(() => {
67
+ setLoading(false);
68
+ setSent(true);
69
+ }, 1200);
70
+ }
71
+
72
+ return (
73
+ <Center fill>
74
+ <Icon icon={Mail} size="large" color="secondary" />
75
+ <Stack gap="medium">
76
+ <Heading level={1} size="h5">Check your email</Heading>
77
+ <Paragraph tone="secondary" measure="none">We sent a link to {address}. Open it to continue.</Paragraph>
78
+ </Stack>
79
+ <Stack gap="large">
80
+ <Button size="medium" type="secondary" state="enabled" label={sent ? 'Sent' : 'Send Again'} loading={loading} onClickButton={handleSendAgain} />
81
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={() => router.push('/login')} />
82
+ </Stack>
83
+ </Center>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ## Option: Alert above the login form
89
+
90
+ Use when: The product lets a person log in before they confirm their email.
91
+
92
+ Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Image`, `Line`, `Tab`, `TabsContainer`, `TextField`
93
+
94
+ ```tsx
95
+ 'use client';
96
+ import { useEffect, useRef, useState } from 'react';
97
+ import Image from 'oneslash-design-system/components/image';
98
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
99
+ import Tab from 'oneslash-design-system/components/tab';
100
+ import Form from 'oneslash-design-system/components/form';
101
+ import Alert from 'oneslash-design-system/components/alert';
102
+ import TextField from 'oneslash-design-system/components/textField';
103
+ import Button from 'oneslash-design-system/components/button';
104
+ import Line from 'oneslash-design-system/components/line';
105
+ import BrandIcon from 'oneslash-design-system/components/brandIcon';
106
+ import { Center } from 'oneslash-design-system/components/layout';
107
+
108
+ // The product's mark. A real app passes its own file.
109
+ const productMark =
110
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
111
+
112
+ // A real app passes the router from its framework, such as Next's useRouter().
113
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
114
+
115
+ // A small check: some text, an @, then some text.
116
+ function looksLikeEmail(value: string) {
117
+ return /^[^@\s]+@[^@\s]+$/.test(value);
118
+ }
119
+
120
+ export default function CheckYourEmailAlertOnLogin() {
121
+ // Opens as the login page does right after sign-up. The words are the same whether or not the address
122
+ // already had an account, so the page never says which.
123
+ const [notice, setNotice] = useState('We sent a link to ada@example.com. Open it to continue, or log in below.');
124
+ const [email, setEmail] = useState('ada@example.com');
125
+ const [password, setPassword] = useState('');
126
+ const [error, setError] = useState('');
127
+ const [emailError, setEmailError] = useState('');
128
+ const [passwordError, setPasswordError] = useState('');
129
+ const [loading, setLoading] = useState(false);
130
+ const timer = useRef<ReturnType<typeof setTimeout>>();
131
+
132
+ // Stops the request if the example goes away before it ends.
133
+ useEffect(() => () => clearTimeout(timer.current), []);
134
+
135
+ function handleSubmit() {
136
+ if (loading) return;
137
+ setNotice('');
138
+ setError('');
139
+ setEmailError('');
140
+ setPasswordError('');
141
+ if (!email.trim()) {
142
+ setEmailError('Enter your email.');
143
+ return;
144
+ }
145
+ if (!looksLikeEmail(email.trim())) {
146
+ setEmailError('Enter an email address, like name@example.com.');
147
+ return;
148
+ }
149
+ if (!password) {
150
+ setPasswordError('Enter your password.');
151
+ return;
152
+ }
153
+ setLoading(true);
154
+ // Stands in for the request to the server.
155
+ timer.current = setTimeout(() => {
156
+ setLoading(false);
157
+ setError('That email and password do not match.');
158
+ }, 1200);
159
+ }
160
+
161
+ return (
162
+ <Center fill>
163
+ <Image src={productMark} alt="Acme" width={40} height={40} />
164
+ <TabsContainer fill>
165
+ <Tab label="Log In" isSelected onClickTab={() => {}} />
166
+ <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={() => {}} />
167
+ </TabsContainer>
168
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
169
+ {/* It says what to do next, so it stays until the person submits the form: no close button, and it does not close on its own. */}
170
+ {notice && <Alert type="success" variant="inline" message={notice} autoDismiss={false} />}
171
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
172
+ <TextField id="check-your-email-login-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
173
+ <TextField id="check-your-email-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
174
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
175
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot Password?" />
176
+ </Form>
177
+ <Line label="or" />
178
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
179
+ </Center>
180
+ );
181
+ }
182
+ ```
183
+
184
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function ConfirmDestructiveActionInline(): import("react").JSX.Element;
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import TableContainer from '../../components/tableContainer';
7
+ import TableRow from '../../components/tableRow';
8
+ import TableCell from '../../components/tableCell';
9
+ import Button from '../../components/button';
10
+ import { Center, Cluster, Stack } from '../../components/layout';
11
+ var people = [
12
+ { id: 'dana', name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
13
+ { id: 'omar', name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
14
+ { id: 'mei', name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
15
+ { id: 'luis', name: 'Luis Ortega', email: 'luis@example.com', role: 'Guest' },
16
+ { id: 'ada', name: 'Ada Brooks', email: 'ada@example.com', role: 'Member' },
17
+ ];
18
+ export default function ConfirmDestructiveActionInline() {
19
+ var _a = useState(people), members = _a[0], setMembers = _a[1];
20
+ // Opens with one row confirming, as if the person just chose Remove on it.
21
+ var _b = useState('omar'), confirming = _b[0], setConfirming = _b[1];
22
+ var _c = useState(false), removing = _c[0], setRemoving = _c[1];
23
+ var timer = useRef();
24
+ var toastIds = useRef([]);
25
+ // On unmount it stops the request and closes every toast it opened.
26
+ useEffect(function () { return function () {
27
+ clearTimeout(timer.current);
28
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
29
+ toastIds.current = [];
30
+ }; }, []);
31
+ function handleRemove(id, name) {
32
+ if (removing)
33
+ return;
34
+ setRemoving(true);
35
+ // Stands in for the request to the server.
36
+ timer.current = setTimeout(function () {
37
+ setRemoving(false);
38
+ setConfirming(null);
39
+ setMembers(function (list) { return list.filter(function (m) { return m.id !== id; }); });
40
+ toastIds.current.push(toast({ type: 'success', message: "".concat(name, " removed from Acme Design.") }));
41
+ }, 1200);
42
+ }
43
+ return (<Center width="page">
44
+ {/* A real app mounts one Toaster near its root. */}
45
+ <Toaster />
46
+ <Stack gap="large">
47
+ <Stack gap="small">
48
+ <Heading level={2} size="h5">Members</Heading>
49
+ <Paragraph tone="secondary" size="body2" measure="none">People who can open Acme Design.</Paragraph>
50
+ </Stack>
51
+ <TableContainer>
52
+ {members.map(function (m) { return (<TableRow key={m.id}>
53
+ <TableCell>{m.name}</TableCell>
54
+ <TableCell>{m.email}</TableCell>
55
+ <TableCell width="100px">{m.role}</TableCell>
56
+ {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
57
+ <TableCell width="168px">
58
+ {confirming === m.id ? (<Cluster gap="small">
59
+ <Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel removing ".concat(m.name)} onClickButton={function () { return setConfirming(null); }}/>
60
+ <Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={"Remove ".concat(m.name)} loading={removing} onClickButton={function () { return handleRemove(m.id, m.name); }}/>
61
+ </Cluster>) : (<Cluster gap="small">
62
+ <Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Remove" aria-label={"Remove ".concat(m.name)} onClickButton={function () { return setConfirming(m.id); }}/>
63
+ </Cluster>)}
64
+ </TableCell>
65
+ </TableRow>); })}
66
+ </TableContainer>
67
+ </Stack>
68
+ </Center>);
69
+ }
@@ -0,0 +1 @@
1
+ export default function ConfirmDestructiveActionModal(): import("react").JSX.Element;
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Modal from '../../components/modal';
5
+ import Surface from '../../components/surface';
6
+ import Heading from '../../components/heading';
7
+ import Paragraph from '../../components/paragraph';
8
+ import List from '../../components/list';
9
+ import Button from '../../components/button';
10
+ import { Center, Cluster, Stack } from '../../components/layout';
11
+ var otherProjects = ['Website refresh', 'Hiring plan', 'Office move'];
12
+ export default function ConfirmDestructiveActionModal() {
13
+ // Opens on the confirm, as if the person just chose Delete Project.
14
+ var _a = useState(true), open = _a[0], setOpen = _a[1];
15
+ var _b = useState(false), deleting = _b[0], setDeleting = _b[1];
16
+ var _c = useState(false), deleted = _c[0], setDeleted = _c[1];
17
+ var timer = useRef();
18
+ var toastIds = useRef([]);
19
+ // On unmount it stops the request and closes every toast it opened.
20
+ useEffect(function () { return function () {
21
+ clearTimeout(timer.current);
22
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
23
+ toastIds.current = [];
24
+ }; }, []);
25
+ // Escape, a click outside and Cancel all close it, except while the request runs.
26
+ function handleClose() {
27
+ if (deleting)
28
+ return;
29
+ setOpen(false);
30
+ }
31
+ function handleDelete() {
32
+ if (deleting)
33
+ return;
34
+ setDeleting(true);
35
+ // Stands in for the request to the server.
36
+ timer.current = setTimeout(function () {
37
+ setDeleting(false);
38
+ setOpen(false);
39
+ setDeleted(true);
40
+ toastIds.current.push(toast({ type: 'success', message: "Project 'Q3 plan' deleted." }));
41
+ }, 1200);
42
+ }
43
+ return (<Center width="page">
44
+ {/* A real app mounts one Toaster near its root. */}
45
+ <Toaster />
46
+ {deleted ? (<Stack gap="large">
47
+ <Heading level={2} size="h5">Projects</Heading>
48
+ <Surface padding="large">
49
+ <List items={otherProjects} size="body1"/>
50
+ </Surface>
51
+ </Stack>) : (<Stack gap="medium">
52
+ <Heading level={2} size="h5">Q3 plan</Heading>
53
+ <Paragraph tone="secondary" size="body2" measure="none">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>
54
+ <Cluster>
55
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Project" onClickButton={function () { return setOpen(true); }}/>
56
+ </Cluster>
57
+ </Stack>)}
58
+ <Modal isOpen={open} size="small" title="Delete Project" onClose={handleClose} actions={<>
59
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
60
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={handleDelete}/>
61
+ </>}>
62
+ <Paragraph measure="none">This deletes &apos;Q3 plan&apos; and its 12 tasks.</Paragraph>
63
+ <Paragraph tone="secondary" size="body2" measure="none">Files attached to the tasks stay in Files.</Paragraph>
64
+ </Modal>
65
+ </Center>);
66
+ }