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,155 @@
1
+ # Load failure
2
+
3
+ A list or a section could not load.
4
+
5
+ **Not built yet:** Scindo on the web shows its empty list, with no Try Again, when its API keys or its members fail to load. Commentify puts its 'Try again' Button under `EmptyBox`, not in its `action`.
6
+
7
+ ## Do
8
+
9
+ - Say what could not load: 'Could not load projects'.
10
+ - Offer a 'Try Again' Button. It is `loading` while it loads, and keeps its label.
11
+ - Show the list as soon as it loads.
12
+ - Keep the rest of the page working when only one section failed.
13
+ - Give the inline error Alert for a failed section no close button and `autoDismiss={false}`, so it stays until the section loads.
14
+
15
+ ## Don't
16
+
17
+ - Do not show the empty text, such as 'No projects yet', when the list failed to load.
18
+ - Do not show the error's own message, such as 'Failed to fetch'.
19
+ - Do not replace the whole page when only one section failed.
20
+
21
+ ## Option: Whole list failed
22
+
23
+ Use when: The whole list failed to load, so there is nothing else to show in its place.
24
+
25
+ Uses: `Button`, `EmptyBox`, `Heading`, `List`, `Stack`, `Surface`
26
+
27
+ ```tsx
28
+ 'use client';
29
+ import { useEffect, useRef, useState } from 'react';
30
+ import Surface from 'oneslash-design-system/components/surface';
31
+ import Heading from 'oneslash-design-system/components/heading';
32
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
33
+ import List from 'oneslash-design-system/components/list';
34
+ import Button from 'oneslash-design-system/components/button';
35
+ import { Stack } from 'oneslash-design-system/components/layout';
36
+
37
+ const projects = ['Website refresh', 'Hiring plan', 'Q4 budget', 'Office move'];
38
+
39
+ export default function LoadFailureRegion() {
40
+ const [loaded, setLoaded] = useState(false);
41
+ const [loading, setLoading] = useState(false);
42
+ const timer = useRef<ReturnType<typeof setTimeout>>();
43
+
44
+ // Stops the request if the example goes away before it ends.
45
+ useEffect(() => () => clearTimeout(timer.current), []);
46
+
47
+ function handleTryAgain() {
48
+ if (loading) return;
49
+ setLoading(true);
50
+ // Stands in for the request to the server.
51
+ timer.current = setTimeout(() => {
52
+ setLoading(false);
53
+ setLoaded(true);
54
+ }, 1200);
55
+ }
56
+
57
+ return (
58
+ <Stack gap="large">
59
+ <Heading level={2} size="h5">Projects</Heading>
60
+ {loaded ? (
61
+ <Surface minHeight="tall">
62
+ <List items={projects} size="body1" />
63
+ </Surface>
64
+ ) : (
65
+ <Surface minHeight="tall" align="center">
66
+ <EmptyBox
67
+ size="large"
68
+ icon="CloudOff"
69
+ text="Could not load projects"
70
+ secondText="Check your connection and try again."
71
+ action={<Button size="medium" type="primary" state="enabled" label="Try Again" loading={loading} onClickButton={handleTryAgain} />}
72
+ />
73
+ </Surface>
74
+ )}
75
+ </Stack>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Option: One section failed
81
+
82
+ Use when: One section failed to load and the rest of the page works.
83
+
84
+ Uses: `Alert`, `Button`, `Center`, `Cluster`, `Heading`, `List`, `Paragraph`, `Stack`, `Surface`
85
+
86
+ ```tsx
87
+ 'use client';
88
+ import { useEffect, useRef, useState } from 'react';
89
+ import Surface from 'oneslash-design-system/components/surface';
90
+ import Heading from 'oneslash-design-system/components/heading';
91
+ import Paragraph from 'oneslash-design-system/components/paragraph';
92
+ import Alert from 'oneslash-design-system/components/alert';
93
+ import List from 'oneslash-design-system/components/list';
94
+ import Button from 'oneslash-design-system/components/button';
95
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
96
+
97
+ const invoices = ['November 2026: $240', 'October 2026: $240', 'September 2026: $180'];
98
+
99
+ export default function LoadFailureInline() {
100
+ const [error, setError] = useState('Could not load your invoices.');
101
+ const [loading, setLoading] = useState(false);
102
+ const timer = useRef<ReturnType<typeof setTimeout>>();
103
+
104
+ // Stops the request if the example goes away before it ends.
105
+ useEffect(() => () => clearTimeout(timer.current), []);
106
+
107
+ function handleTryAgain() {
108
+ if (loading) return;
109
+ setLoading(true);
110
+ // Stands in for the request to the server.
111
+ timer.current = setTimeout(() => {
112
+ setLoading(false);
113
+ setError('');
114
+ }, 1200);
115
+ }
116
+
117
+ return (
118
+ <Center width="page">
119
+ <Stack gap="xlarge">
120
+ <Surface padding="large">
121
+ <Stack gap="medium">
122
+ <Heading level={2} size="h6">Plan</Heading>
123
+ <Paragraph size="body2" measure="none">Team plan, 12 seats, renews on December 1.</Paragraph>
124
+ <Cluster>
125
+ <Button size="small" type="secondary" state="enabled" label="Change Plan" />
126
+ </Cluster>
127
+ </Stack>
128
+ </Surface>
129
+ <Surface padding="large">
130
+ <Stack gap="medium">
131
+ <Heading level={2} size="h6">Invoices</Heading>
132
+ {error ? (
133
+ <>
134
+ {/* The section stays failed until it loads, so the Alert has no close button and does not close on its own. */}
135
+ <Alert type="error" variant="inline" message={error} autoDismiss={false} />
136
+ <Cluster>
137
+ <Button size="small" type="primary" state="enabled" label="Try Again" loading={loading} onClickButton={handleTryAgain} />
138
+ </Cluster>
139
+ </>
140
+ ) : (
141
+ <List items={invoices} size="body2" />
142
+ )}
143
+ </Stack>
144
+ </Surface>
145
+ </Stack>
146
+ </Center>
147
+ );
148
+ }
149
+ ```
150
+
151
+ ## Native
152
+
153
+ On Apple use `ContentUnavailableView`, with a 'Try Again' Button in its `actions`.
154
+
155
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function LogOutConfirmModal(): import("react").JSX.Element;
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Modal from '../../components/modal';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import Button from '../../components/button';
7
+ import { Center, Cluster, Stack } from '../../components/layout';
8
+ export default function LogOutConfirmModal() {
9
+ // Opens on the confirm, as if the person just chose Log Out.
10
+ var _a = useState(true), open = _a[0], setOpen = _a[1];
11
+ var _b = useState(false), loggingOut = _b[0], setLoggingOut = _b[1];
12
+ var _c = useState(false), loggedOut = _c[0], setLoggedOut = _c[1];
13
+ var timer = useRef();
14
+ // Stops the request if the example goes away before it ends.
15
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
16
+ // Escape, a click outside and Cancel all close it, except while the request runs.
17
+ function handleClose() {
18
+ if (loggingOut)
19
+ return;
20
+ setOpen(false);
21
+ }
22
+ function handleLogOut() {
23
+ if (loggingOut)
24
+ return;
25
+ setLoggingOut(true);
26
+ // Stands in for the request to the server.
27
+ timer.current = setTimeout(function () {
28
+ setLoggingOut(false);
29
+ setOpen(false);
30
+ setLoggedOut(true);
31
+ }, 1200);
32
+ }
33
+ // A real app goes to its login page here. The example shows a short logged-out page instead.
34
+ if (loggedOut) {
35
+ return (<Center fill>
36
+ <Heading level={1} size="h5">You are logged out</Heading>
37
+ <Cluster>
38
+ <Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { return setLoggedOut(false); }}/>
39
+ </Cluster>
40
+ </Center>);
41
+ }
42
+ return (<Center width="page">
43
+ <Stack gap="medium">
44
+ <Heading level={1} size="h5">Account</Heading>
45
+ <Paragraph tone="secondary" size="body2" measure="none">Logged in as ada@example.com.</Paragraph>
46
+ <Cluster>
47
+ <Button size="small" type="secondary" state="enabled" label="Log Out" onClickButton={function () { return setOpen(true); }}/>
48
+ </Cluster>
49
+ </Stack>
50
+ <Modal isOpen={open} size="small" title="Log Out" onClose={handleClose} actions={<>
51
+ <Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
52
+ <Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={handleLogOut}/>
53
+ </>}>
54
+ <Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
55
+ </Modal>
56
+ </Center>);
57
+ }
@@ -0,0 +1,106 @@
1
+ # Log-out confirm
2
+
3
+ A person chooses Log Out.
4
+
5
+ **Not built yet:** Scindo on the web says 'Log Out' but colors it as danger. Scindo on Apple says 'Sign Out' and puts it in the destructive role. Commentify and Commentify admin say 'Sign Out', title the Modal 'Confirm Sign Out', label the action 'Yes, Sign Out' and ask 'Are you sure you want to sign out?'.
6
+
7
+ ## Do
8
+
9
+ - Call it 'Log Out' everywhere: the menu item, the Modal title and the action Button. The way back in is 'Log In'.
10
+ - Say in one sentence what logging out means on this device.
11
+ - Ask before logging out, although logging out is easy to undo. A person can press it by mistake on a shared device, or with unsent work.
12
+ - Leave the action Button in the plain primary color. Logging out destroys nothing.
13
+ - Show `loading` on 'Log Out' while it runs, then show the logged-out page.
14
+
15
+ ## Don't
16
+
17
+ - Do not mix 'Sign Out' with 'Log In'. Use one word family: 'Log Out' and 'Log In'.
18
+ - Do not give the action Button `color="danger"`.
19
+ - Do not ask 'Are you sure you want to log out?'.
20
+ - Do not show a toast after logging out. The logged-out page says it.
21
+
22
+ ## Example: Confirm in a Modal
23
+
24
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`
25
+
26
+ ```tsx
27
+ 'use client';
28
+ import { useEffect, useRef, useState } from 'react';
29
+ import Modal from 'oneslash-design-system/components/modal';
30
+ import Heading from 'oneslash-design-system/components/heading';
31
+ import Paragraph from 'oneslash-design-system/components/paragraph';
32
+ import Button from 'oneslash-design-system/components/button';
33
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
34
+
35
+ export default function LogOutConfirmModal() {
36
+ // Opens on the confirm, as if the person just chose Log Out.
37
+ const [open, setOpen] = useState(true);
38
+ const [loggingOut, setLoggingOut] = useState(false);
39
+ const [loggedOut, setLoggedOut] = useState(false);
40
+ const timer = useRef<ReturnType<typeof setTimeout>>();
41
+
42
+ // Stops the request if the example goes away before it ends.
43
+ useEffect(() => () => clearTimeout(timer.current), []);
44
+
45
+ // Escape, a click outside and Cancel all close it, except while the request runs.
46
+ function handleClose() {
47
+ if (loggingOut) return;
48
+ setOpen(false);
49
+ }
50
+
51
+ function handleLogOut() {
52
+ if (loggingOut) return;
53
+ setLoggingOut(true);
54
+ // Stands in for the request to the server.
55
+ timer.current = setTimeout(() => {
56
+ setLoggingOut(false);
57
+ setOpen(false);
58
+ setLoggedOut(true);
59
+ }, 1200);
60
+ }
61
+
62
+ // A real app goes to its login page here. The example shows a short logged-out page instead.
63
+ if (loggedOut) {
64
+ return (
65
+ <Center fill>
66
+ <Heading level={1} size="h5">You are logged out</Heading>
67
+ <Cluster>
68
+ <Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={() => setLoggedOut(false)} />
69
+ </Cluster>
70
+ </Center>
71
+ );
72
+ }
73
+
74
+ return (
75
+ <Center width="page">
76
+ <Stack gap="medium">
77
+ <Heading level={1} size="h5">Account</Heading>
78
+ <Paragraph tone="secondary" size="body2" measure="none">Logged in as ada@example.com.</Paragraph>
79
+ <Cluster>
80
+ <Button size="small" type="secondary" state="enabled" label="Log Out" onClickButton={() => setOpen(true)} />
81
+ </Cluster>
82
+ </Stack>
83
+ <Modal
84
+ isOpen={open}
85
+ size="small"
86
+ title="Log Out"
87
+ onClose={handleClose}
88
+ actions={
89
+ <>
90
+ <Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
91
+ <Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={handleLogOut} />
92
+ </>
93
+ }
94
+ >
95
+ <Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
96
+ </Modal>
97
+ </Center>
98
+ );
99
+ }
100
+ ```
101
+
102
+ ## Native
103
+
104
+ On Apple use a system `confirmationDialog` titled 'Log Out', with a 'Log Out' Button and 'Cancel' in the `.cancel` role. Leave out the `.destructive` role: nothing is destroyed.
105
+
106
+ Seen in: Commentify, Commentify admin, Scindo.
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useState } from 'react';
2
+ import { useEffect, useRef, useState } from 'react';
3
3
  import Image from '../../components/image';
4
4
  import TabsContainer from '../../components/tabsContainer';
5
5
  import Tab from '../../components/tab';
@@ -25,6 +25,9 @@ export default function LoginCentered() {
25
25
  var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
26
26
  var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
27
27
  var _f = useState(false), loading = _f[0], setLoading = _f[1];
28
+ var timer = useRef();
29
+ // Stops the request if the example goes away before it ends.
30
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
28
31
  function handleSubmit() {
29
32
  if (loading)
30
33
  return;
@@ -36,7 +39,7 @@ export default function LoginCentered() {
36
39
  return;
37
40
  }
38
41
  if (!looksLikeEmail(email.trim())) {
39
- setEmailError('Enter a valid email address.');
42
+ setEmailError('Enter an email address, like name@example.com.');
40
43
  return;
41
44
  }
42
45
  if (!password) {
@@ -45,23 +48,23 @@ export default function LoginCentered() {
45
48
  }
46
49
  setLoading(true);
47
50
  // Stands in for the request to the server.
48
- setTimeout(function () {
51
+ timer.current = setTimeout(function () {
49
52
  setLoading(false);
50
53
  setError('That email and password do not match.');
51
54
  }, 1200);
52
55
  }
53
56
  return (<Center fill>
54
57
  <Image src={productMark} alt="Acme" width={40} height={40}/>
55
- <TabsContainer>
58
+ <TabsContainer fill>
56
59
  <Tab label="Log In" isSelected onClickTab={function () { }}/>
57
60
  <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={function () { }}/>
58
61
  </TabsContainer>
59
62
  <Form aria-label="Log in" onSubmit={handleSubmit}>
60
63
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
61
- <TextField id="login-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
62
- <TextField id="login-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
64
+ <TextField id="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(''); }}/>
65
+ <TextField id="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(''); }}/>
63
66
  <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
64
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
67
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?"/>
65
68
  </Form>
66
69
  <Line label="or"/>
67
70
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useState } from 'react';
2
+ import { useEffect, useRef, useState } from 'react';
3
3
  import Surface from '../../components/surface';
4
4
  import Heading from '../../components/heading';
5
5
  import Paragraph from '../../components/paragraph';
@@ -17,6 +17,9 @@ export default function LoginEmailOnly() {
17
17
  var _b = useState(''), sentTo = _b[0], setSentTo = _b[1];
18
18
  var _c = useState(''), emailError = _c[0], setEmailError = _c[1];
19
19
  var _d = useState(false), loading = _d[0], setLoading = _d[1];
20
+ var timer = useRef();
21
+ // Stops the request if the example goes away before it ends.
22
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
20
23
  function handleSubmit() {
21
24
  if (loading)
22
25
  return;
@@ -27,13 +30,13 @@ export default function LoginEmailOnly() {
27
30
  return;
28
31
  }
29
32
  if (!looksLikeEmail(email.trim())) {
30
- setEmailError('Enter a valid email address.');
33
+ setEmailError('Enter an email address, like name@example.com.');
31
34
  return;
32
35
  }
33
36
  setLoading(true);
34
37
  var address = email.trim();
35
38
  // Stands in for the request to the server.
36
- setTimeout(function () {
39
+ timer.current = setTimeout(function () {
37
40
  setLoading(false);
38
41
  setSentTo(address);
39
42
  }, 1200);
@@ -42,13 +45,13 @@ export default function LoginEmailOnly() {
42
45
  <Surface padding="large">
43
46
  <Stack gap="xlarge">
44
47
  <Stack gap="small">
45
- <Heading level={2} size="h5">Log in</Heading>
46
- <Paragraph tone="secondary" size="body2" measure="none">We will email you a link to sign in.</Paragraph>
48
+ <Heading level={1} size="h5">Log in</Heading>
49
+ <Paragraph tone="secondary" size="body2" measure="none">We will email you a link to log in.</Paragraph>
47
50
  </Stack>
48
51
  <Form aria-label="Log in" onSubmit={handleSubmit}>
49
- {sentTo && <Alert type="success" variant="inline" message={"We sent a sign-in link to ".concat(sentTo, ".")} showCloseButton onClose={function () { return setSentTo(''); }}/>}
50
- <TextField id="email-only-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
51
- <Button size="medium" type="primary" state="enabled" label="Send sign-in link" htmlType="submit" loading={loading}/>
52
+ {sentTo && <Alert type="success" variant="inline" message={"We sent a login link to ".concat(sentTo, ".")} autoDismiss={false}/>}
53
+ <TextField id="email-only-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
54
+ <Button size="medium" type="primary" state="enabled" label="Send Login Link" htmlType="submit" loading={loading}/>
52
55
  </Form>
53
56
  </Stack>
54
57
  </Surface>
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useState } from 'react';
2
+ import { useEffect, useRef, useState } from 'react';
3
3
  import Heading from '../../components/heading';
4
4
  import Form from '../../components/form';
5
5
  import Alert from '../../components/alert';
@@ -19,6 +19,9 @@ export default function LoginProviderFirst() {
19
19
  var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
20
20
  var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
21
21
  var _f = useState(false), loading = _f[0], setLoading = _f[1];
22
+ var timer = useRef();
23
+ // Stops the request if the example goes away before it ends.
24
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
22
25
  function handleSubmit() {
23
26
  if (loading)
24
27
  return;
@@ -30,7 +33,7 @@ export default function LoginProviderFirst() {
30
33
  return;
31
34
  }
32
35
  if (!looksLikeEmail(email.trim())) {
33
- setEmailError('Enter a valid email address.');
36
+ setEmailError('Enter an email address, like name@example.com.');
34
37
  return;
35
38
  }
36
39
  if (!password) {
@@ -39,25 +42,25 @@ export default function LoginProviderFirst() {
39
42
  }
40
43
  setLoading(true);
41
44
  // Stands in for the request to the server.
42
- setTimeout(function () {
45
+ timer.current = setTimeout(function () {
43
46
  setLoading(false);
44
47
  setError('That email and password do not match.');
45
48
  }, 1200);
46
49
  }
47
50
  return (<Center fill>
48
- <Heading level={2} size="h5">Sign in to Acme</Heading>
51
+ <Heading level={1} size="h5">Log in to Acme</Heading>
49
52
  <Stack gap="medium">
50
53
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
51
54
  <Button size="medium" type="secondary" state="enabled" label="Continue with GitHub" decoIcon={<BrandIcon name="github"/>}/>
52
55
  <Button size="medium" type="secondary" state="enabled" label="Continue with Apple" decoIcon={<BrandIcon name="apple"/>}/>
53
56
  </Stack>
54
57
  <Line label="or"/>
55
- <Form aria-label="Sign in with email" onSubmit={handleSubmit}>
58
+ <Form aria-label="Log in with email" onSubmit={handleSubmit}>
56
59
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
57
- <TextField id="provider-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
58
- <TextField id="provider-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
59
- <Button size="medium" type="primary" state="enabled" label="Sign in with email" htmlType="submit" loading={loading}/>
60
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
60
+ <TextField id="provider-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
61
+ <TextField id="provider-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(''); }}/>
62
+ <Button size="medium" type="primary" state="enabled" label="Log In with Email" htmlType="submit" loading={loading}/>
63
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?"/>
61
64
  </Form>
62
65
  </Center>);
63
66
  }
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useState } from 'react';
2
+ import { useEffect, useRef, useState } from 'react';
3
3
  import Image from '../../components/image';
4
4
  import Heading from '../../components/heading';
5
5
  import Paragraph from '../../components/paragraph';
@@ -24,6 +24,9 @@ export default function LoginSplit() {
24
24
  var _d = useState(''), emailError = _d[0], setEmailError = _d[1];
25
25
  var _e = useState(''), passwordError = _e[0], setPasswordError = _e[1];
26
26
  var _f = useState(false), loading = _f[0], setLoading = _f[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); }; }, []);
27
30
  function handleSubmit() {
28
31
  if (loading)
29
32
  return;
@@ -35,7 +38,7 @@ export default function LoginSplit() {
35
38
  return;
36
39
  }
37
40
  if (!looksLikeEmail(email.trim())) {
38
- setEmailError('Enter a valid email address.');
41
+ setEmailError('Enter an email address, like name@example.com.');
39
42
  return;
40
43
  }
41
44
  if (!password) {
@@ -44,7 +47,7 @@ export default function LoginSplit() {
44
47
  }
45
48
  setLoading(true);
46
49
  // Stands in for the request to the server.
47
- setTimeout(function () {
50
+ timer.current = setTimeout(function () {
48
51
  setLoading(false);
49
52
  setError('That email and password do not match.');
50
53
  }, 1200);
@@ -57,19 +60,19 @@ export default function LoginSplit() {
57
60
  </Paragraph>
58
61
  </Stack>}>
59
62
  <Center fill>
60
- <Heading level={2} size="h5">Log in to Acme</Heading>
63
+ <Heading level={1} size="h5">Log in to Acme</Heading>
61
64
  <Form aria-label="Log in" onSubmit={handleSubmit}>
62
65
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
63
- <TextField id="split-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
64
- <TextField id="split-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
66
+ <TextField id="split-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
67
+ <TextField id="split-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(''); }}/>
65
68
  <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
66
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?"/>
69
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?"/>
67
70
  </Form>
68
71
  <Line label="or"/>
69
72
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
70
73
  <Cluster gap="small">
71
74
  <Paragraph tone="secondary" size="body2" measure="none">New here?</Paragraph>
72
- <Link href="/signup" size="body2">Create an account</Link>
75
+ <Link href="/sign-up" size="body2">Sign Up</Link>
73
76
  </Cluster>
74
77
  </Center>
75
78
  </Split>);