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.
Files changed (232) hide show
  1. package/README.md +15 -0
  2. package/dist/DESIGN.md +138 -1
  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 +29 -0
  9. package/dist/cases/agent-cancels-when-unanswered.md +27 -0
  10. package/dist/cases/agent-refuses-clearly.md +31 -0
  11. package/dist/cases/agent-says-what-it-is.md +29 -0
  12. package/dist/cases/agent-shows-progress.md +30 -0
  13. package/dist/cases/agent-shows-sources.md +26 -0
  14. package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
  15. package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
  16. package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
  17. package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
  18. package/dist/cases/auth-gate-loading.md +70 -0
  19. package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
  20. package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
  21. package/dist/cases/check-your-email/page.d.ts +1 -0
  22. package/dist/cases/check-your-email/page.jsx +49 -0
  23. package/dist/cases/check-your-email.md +184 -0
  24. package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
  25. package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
  26. package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
  27. package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
  28. package/dist/cases/confirm-destructive-action.md +211 -0
  29. package/dist/cases/confirm-dialogs.md +36 -0
  30. package/dist/cases/create-modal/quick.d.ts +1 -0
  31. package/dist/cases/create-modal/quick.jsx +80 -0
  32. package/dist/cases/create-modal/with-settings.d.ts +1 -0
  33. package/dist/cases/create-modal/with-settings.jsx +99 -0
  34. package/dist/cases/create-modal.md +244 -0
  35. package/dist/cases/device-login/popup.d.ts +1 -0
  36. package/dist/cases/device-login/popup.jsx +14 -0
  37. package/dist/cases/device-login/provider-first.d.ts +1 -0
  38. package/dist/cases/device-login/provider-first.jsx +98 -0
  39. package/dist/cases/device-login.md +171 -0
  40. package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
  41. package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
  42. package/dist/cases/email-confirmed/page.d.ts +1 -0
  43. package/dist/cases/email-confirmed/page.jsx +21 -0
  44. package/dist/cases/email-confirmed.md +151 -0
  45. package/dist/cases/empty-list/region.d.ts +1 -0
  46. package/dist/cases/empty-list/region.jsx +13 -0
  47. package/dist/cases/empty-list/section.d.ts +1 -0
  48. package/dist/cases/empty-list/section.jsx +17 -0
  49. package/dist/cases/empty-list.md +77 -0
  50. package/dist/cases/empty-lists.md +35 -0
  51. package/dist/cases/empty-not-set-up/action.d.ts +1 -0
  52. package/dist/cases/empty-not-set-up/action.jsx +16 -0
  53. package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
  54. package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
  55. package/dist/cases/empty-not-set-up.md +88 -0
  56. package/dist/cases/empty-search/clear-search.d.ts +1 -0
  57. package/dist/cases/empty-search/clear-search.jsx +29 -0
  58. package/dist/cases/empty-search.md +77 -0
  59. package/dist/cases/error-page/full-page.d.ts +1 -0
  60. package/dist/cases/error-page/full-page.jsx +19 -0
  61. package/dist/cases/error-page/in-shell.d.ts +1 -0
  62. package/dist/cases/error-page/in-shell.jsx +39 -0
  63. package/dist/cases/error-page.md +107 -0
  64. package/dist/cases/feedback-form/modal.d.ts +1 -0
  65. package/dist/cases/feedback-form/modal.jsx +89 -0
  66. package/dist/cases/feedback-form.md +139 -0
  67. package/dist/cases/forgot-password/in-place.d.ts +1 -0
  68. package/dist/cases/forgot-password/in-place.jsx +155 -0
  69. package/dist/cases/forgot-password/own-page.d.ts +1 -0
  70. package/dist/cases/forgot-password/own-page.jsx +99 -0
  71. package/dist/cases/forgot-password.md +328 -0
  72. package/dist/cases/form-errors.md +32 -0
  73. package/dist/cases/import-checklist/modal.d.ts +1 -0
  74. package/dist/cases/import-checklist/modal.jsx +125 -0
  75. package/dist/cases/import-checklist.md +188 -0
  76. package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
  77. package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
  78. package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
  79. package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
  80. package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
  81. package/dist/cases/inline-form-feedback/toast.jsx +66 -0
  82. package/dist/cases/inline-form-feedback.md +237 -0
  83. package/dist/cases/invite-member/by-email.d.ts +1 -0
  84. package/dist/cases/invite-member/by-email.jsx +98 -0
  85. package/dist/cases/invite-member/by-link.d.ts +1 -0
  86. package/dist/cases/invite-member/by-link.jsx +122 -0
  87. package/dist/cases/invite-member.md +321 -0
  88. package/dist/cases/load-failure/inline.d.ts +1 -0
  89. package/dist/cases/load-failure/inline.jsx +52 -0
  90. package/dist/cases/load-failure/region.d.ts +1 -0
  91. package/dist/cases/load-failure/region.jsx +34 -0
  92. package/dist/cases/load-failure.md +155 -0
  93. package/dist/cases/log-out-confirm/modal.d.ts +1 -0
  94. package/dist/cases/log-out-confirm/modal.jsx +57 -0
  95. package/dist/cases/log-out-confirm.md +106 -0
  96. package/dist/cases/login-page/centered.d.ts +1 -0
  97. package/dist/cases/login-page/centered.jsx +72 -0
  98. package/dist/cases/login-page/email-only.d.ts +1 -0
  99. package/dist/cases/login-page/email-only.jsx +59 -0
  100. package/dist/cases/login-page/provider-first.d.ts +1 -0
  101. package/dist/cases/login-page/provider-first.jsx +66 -0
  102. package/dist/cases/login-page/split.d.ts +1 -0
  103. package/dist/cases/login-page/split.jsx +79 -0
  104. package/dist/cases/login-page.md +373 -0
  105. package/dist/cases/not-found-page/full-page.d.ts +1 -0
  106. package/dist/cases/not-found-page/full-page.jsx +16 -0
  107. package/dist/cases/not-found-page/in-shell.d.ts +1 -0
  108. package/dist/cases/not-found-page/in-shell.jsx +36 -0
  109. package/dist/cases/not-found-page.md +98 -0
  110. package/dist/cases/oauth-consent/simple.d.ts +1 -0
  111. package/dist/cases/oauth-consent/simple.jsx +73 -0
  112. package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
  113. package/dist/cases/oauth-consent/with-scope.jsx +89 -0
  114. package/dist/cases/oauth-consent.md +233 -0
  115. package/dist/cases/rename/inline.d.ts +1 -0
  116. package/dist/cases/rename/inline.jsx +58 -0
  117. package/dist/cases/rename/modal.d.ts +1 -0
  118. package/dist/cases/rename/modal.jsx +70 -0
  119. package/dist/cases/rename.md +205 -0
  120. package/dist/cases/route-loading/full-screen.d.ts +1 -0
  121. package/dist/cases/route-loading/full-screen.jsx +8 -0
  122. package/dist/cases/route-loading/region.d.ts +1 -0
  123. package/dist/cases/route-loading/region.jsx +26 -0
  124. package/dist/cases/route-loading.md +84 -0
  125. package/dist/cases/set-new-password/form.d.ts +1 -0
  126. package/dist/cases/set-new-password/form.jsx +130 -0
  127. package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
  128. package/dist/cases/set-new-password/invalid-link.jsx +50 -0
  129. package/dist/cases/set-new-password.md +247 -0
  130. package/dist/cases/sign-up-page/centered.d.ts +1 -0
  131. package/dist/cases/sign-up-page/centered.jsx +124 -0
  132. package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
  133. package/dist/cases/sign-up-page/provider-first.jsx +124 -0
  134. package/dist/cases/sign-up-page/split.d.ts +1 -0
  135. package/dist/cases/sign-up-page/split.jsx +134 -0
  136. package/dist/cases/sign-up-page.md +478 -0
  137. package/dist/cases/success-feedback.md +35 -0
  138. package/dist/cases/type-to-confirm/inline.d.ts +1 -0
  139. package/dist/cases/type-to-confirm/inline.jsx +69 -0
  140. package/dist/cases/type-to-confirm/modal.d.ts +1 -0
  141. package/dist/cases/type-to-confirm/modal.jsx +73 -0
  142. package/dist/cases/type-to-confirm.md +222 -0
  143. package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
  144. package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
  145. package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
  146. package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
  147. package/dist/cases/unsaved-changes-guard.md +239 -0
  148. package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
  149. package/dist/cases/upgrade-prompt/inline.jsx +52 -0
  150. package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
  151. package/dist/cases/upgrade-prompt/modal.jsx +43 -0
  152. package/dist/cases/upgrade-prompt.md +174 -0
  153. package/dist/cases.json +2073 -0
  154. package/dist/components/alert.d.ts +3 -1
  155. package/dist/components/alert.jsx +6 -4
  156. package/dist/components/brandIcon.d.ts +12 -0
  157. package/dist/components/brandIcon.jsx +24 -0
  158. package/dist/components/emptyBox.d.ts +6 -1
  159. package/dist/components/emptyBox.jsx +4 -2
  160. package/dist/components/form.d.ts +11 -0
  161. package/dist/components/form.jsx +22 -0
  162. package/dist/components/heading.d.ts +2 -2
  163. package/dist/components/image.d.ts +14 -0
  164. package/dist/components/image.jsx +6 -0
  165. package/dist/components/layout.d.ts +18 -1
  166. package/dist/components/layout.jsx +16 -0
  167. package/dist/components/line.d.ts +3 -1
  168. package/dist/components/line.jsx +8 -1
  169. package/dist/components/loadingScreen.d.ts +5 -1
  170. package/dist/components/loadingScreen.jsx +4 -2
  171. package/dist/components/modal.d.ts +2 -1
  172. package/dist/components/modal.jsx +20 -8
  173. package/dist/components/radioGroup.d.ts +2 -1
  174. package/dist/components/radioGroup.jsx +2 -2
  175. package/dist/components/select.d.ts +2 -1
  176. package/dist/components/select.jsx +4 -2
  177. package/dist/components/tab.jsx +3 -2
  178. package/dist/components/tabsContainer.d.ts +4 -1
  179. package/dist/components/tabsContainer.jsx +11 -5
  180. package/dist/components/textField.d.ts +5 -1
  181. package/dist/components/textField.jsx +7 -3
  182. package/dist/components/toaster.d.ts +12 -0
  183. package/dist/components/toaster.jsx +103 -0
  184. package/dist/components/tooltip.jsx +3 -1
  185. package/dist/designTokens.d.ts +1 -0
  186. package/dist/designTokens.js +1 -0
  187. package/dist/internal/alert.d.ts +4 -0
  188. package/dist/internal/alert.js +6 -0
  189. package/dist/internal/modal.d.ts +2 -0
  190. package/dist/internal/modal.js +21 -0
  191. package/dist/internal/toaster.d.ts +19 -0
  192. package/dist/internal/toaster.js +50 -0
  193. package/dist/native-mapping.json +23 -1
  194. package/dist/stories/Alert.stories.d.ts +1 -0
  195. package/dist/stories/Alert.stories.jsx +16 -0
  196. package/dist/stories/BrandIcon.stories.d.ts +9 -0
  197. package/dist/stories/BrandIcon.stories.jsx +19 -0
  198. package/dist/stories/Cases.generated.stories.d.ts +60 -0
  199. package/dist/stories/Cases.generated.stories.jsx +116 -0
  200. package/dist/stories/EmptyBox.stories.d.ts +2 -0
  201. package/dist/stories/EmptyBox.stories.jsx +16 -0
  202. package/dist/stories/Form.stories.d.ts +6 -0
  203. package/dist/stories/Form.stories.jsx +26 -0
  204. package/dist/stories/Heading.stories.d.ts +6 -0
  205. package/dist/stories/Heading.stories.jsx +10 -0
  206. package/dist/stories/Image.stories.d.ts +7 -0
  207. package/dist/stories/Image.stories.jsx +18 -0
  208. package/dist/stories/Line.stories.d.ts +1 -0
  209. package/dist/stories/Line.stories.jsx +12 -0
  210. package/dist/stories/LoadingScreen.stories.d.ts +1 -0
  211. package/dist/stories/LoadingScreen.stories.jsx +8 -0
  212. package/dist/stories/Modal.stories.d.ts +2 -0
  213. package/dist/stories/Modal.stories.jsx +36 -0
  214. package/dist/stories/PageComponents.stories.d.ts +2 -0
  215. package/dist/stories/PageComponents.stories.jsx +15 -1
  216. package/dist/stories/RadioGroup.stories.d.ts +1 -0
  217. package/dist/stories/RadioGroup.stories.jsx +14 -0
  218. package/dist/stories/Select.stories.d.ts +1 -0
  219. package/dist/stories/Select.stories.jsx +14 -0
  220. package/dist/stories/TabsContainer.stories.d.ts +1 -0
  221. package/dist/stories/TabsContainer.stories.jsx +12 -0
  222. package/dist/stories/TextField.stories.d.ts +2 -0
  223. package/dist/stories/TextField.stories.jsx +22 -0
  224. package/dist/stories/Toaster.stories.d.ts +6 -0
  225. package/dist/stories/Toaster.stories.jsx +29 -0
  226. package/dist/tailwind-preset-auto.js +2 -1
  227. package/dist/tailwind-preset.js +2 -1
  228. package/dist/theme-auto.css +1 -0
  229. package/dist/theme.css +1 -0
  230. package/dist/tokens.css +1 -0
  231. package/dist/tokens.json +7 -0
  232. package/package.json +4 -2
@@ -0,0 +1,26 @@
1
+ # An agent shows its sources
2
+
3
+ The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.
4
+
5
+ ## Answer
6
+
7
+ Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section.
8
+
9
+ ## Why
10
+
11
+ A person can check an answer only when they can open what it came from.
12
+
13
+ ## Do
14
+
15
+ - Put the sources directly under the reply they support.
16
+ - Show each source as a card with its title and where it lives, such as the space name or the date.
17
+ - Make each card open the source itself, in the product or on the service it came from.
18
+ - Show the first six sources and a 'Show N more' button for the rest.
19
+
20
+ ## Don't
21
+
22
+ - Do not show a sources section when the reply used no sources.
23
+ - Do not show source cards on a person's message.
24
+ - Do not link a source card to any site other than the product or the service the source came from.
25
+
26
+ Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function AuthGateLoadingSpinnerWithLine(): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import LoadingScreen from '../../components/loadingScreen';
3
+ import { Center } from '../../components/layout';
4
+ // Shown while a step that can take longer than a second runs, before the app knows where to send the person.
5
+ // A real app swaps it for the next page as soon as the step ends.
6
+ export default function AuthGateLoadingSpinnerWithLine() {
7
+ return (<Center fill>
8
+ <LoadingScreen label="Checking invite…"/>
9
+ </Center>);
10
+ }
@@ -0,0 +1 @@
1
+ export default function AuthGateLoadingSpinner(): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import LoadingScreen from '../../components/loadingScreen';
3
+ import { Center } from '../../components/layout';
4
+ // Shown while the app checks the session, before it knows whether to show the page or the login form.
5
+ // A real app swaps it for the page, or goes to the login page, as soon as the check ends.
6
+ export default function AuthGateLoadingSpinner() {
7
+ return (<Center fill>
8
+ <LoadingScreen />
9
+ </Center>);
10
+ }
@@ -0,0 +1,70 @@
1
+ # Login check loading
2
+
3
+ The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show.
4
+
5
+ **Not built yet:** Scindo on the web shows 'Please wait' under the step while it checks an invite, and a small spinner instead of `LoadingScreen` while onboarding checks for a workspace.
6
+
7
+ ## Do
8
+
9
+ - Show the spinner from the first render, before anything else, as `LoadingScreen` in `Center` with `fill`.
10
+ - Replace the spinner with the page, or go to the login page, as soon as the check ends.
11
+ - Show no text when the wait is normally under about a second.
12
+ - Name the step in `LoadingScreen`'s `label` when it can take longer than about a second: `label="Checking invite…"`.
13
+ - Use the same screen as the full-screen spinner in 'Page loading': `LoadingScreen` alone in `Center` with `fill`.
14
+
15
+ ## Don't
16
+
17
+ - Do not show the login form, or the page, before the check ends. It flashes and then goes away.
18
+ - Do not write a line that names no step, such as 'Loading…' or 'Please wait'.
19
+ - Do not put a line under a spinner whose wait is normally under about a second.
20
+ - Do not put more than one line under the spinner, or write it in a separate Paragraph.
21
+
22
+ ## Option: Spinner
23
+
24
+ Use when: The wait is normally under about a second, such as reading the session.
25
+
26
+ Uses: `Center`, `LoadingScreen`
27
+
28
+ ```tsx
29
+ 'use client';
30
+ import LoadingScreen from 'oneslash-design-system/components/loadingScreen';
31
+ import { Center } from 'oneslash-design-system/components/layout';
32
+
33
+ // Shown while the app checks the session, before it knows whether to show the page or the login form.
34
+ // A real app swaps it for the page, or goes to the login page, as soon as the check ends.
35
+ export default function AuthGateLoadingSpinner() {
36
+ return (
37
+ <Center fill>
38
+ <LoadingScreen />
39
+ </Center>
40
+ );
41
+ }
42
+ ```
43
+
44
+ ## Option: Spinner with a line
45
+
46
+ Use when: A named step can take longer than about a second, such as 'Checking invite…' or 'Joining workspace…'.
47
+
48
+ Uses: `Center`, `LoadingScreen`
49
+
50
+ ```tsx
51
+ 'use client';
52
+ import LoadingScreen from 'oneslash-design-system/components/loadingScreen';
53
+ import { Center } from 'oneslash-design-system/components/layout';
54
+
55
+ // Shown while a step that can take longer than a second runs, before the app knows where to send the person.
56
+ // A real app swaps it for the next page as soon as the step ends.
57
+ export default function AuthGateLoadingSpinnerWithLine() {
58
+ return (
59
+ <Center fill>
60
+ <LoadingScreen label="Checking invite…" />
61
+ </Center>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ## Native
67
+
68
+ On Apple use `ProgressView()` centered in the window, with a label only for a named step that can take longer.
69
+
70
+ Seen in: Commentify admin, Scindo.
@@ -0,0 +1 @@
1
+ export default function CheckYourEmailAlertOnLogin(): import("react").JSX.Element;
@@ -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
+ }