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,84 @@
1
+ # Page loading
2
+
3
+ A page or a pane is loading, and there is nothing to show yet.
4
+
5
+ ## Do
6
+
7
+ - Show the shell as soon as it can, and the spinner only where content is loading.
8
+ - Center the spinner in the space that is loading.
9
+ - Replace the spinner with the content as soon as it loads.
10
+ - Name the step in `LoadingScreen`'s `label` when a named step can take longer than about a second, as in 'Login check loading'.
11
+ - Use the same screen as the spinner in 'Login check loading' when nothing can show yet: `LoadingScreen` alone in `Center` with `fill`.
12
+
13
+ ## Don't
14
+
15
+ - Do not write a line that names no step, such as 'Loading…'.
16
+ - Do not cover the navigation with a spinner when only one pane is loading.
17
+ - Do not show the empty text while the list is still loading.
18
+
19
+ ## Option: Full screen
20
+
21
+ Use when: Nothing can show yet, not even the navigation.
22
+
23
+ Uses: `Center`, `LoadingScreen`
24
+
25
+ ```tsx
26
+ 'use client';
27
+ import LoadingScreen from 'oneslash-design-system/components/loadingScreen';
28
+ import { Center } from 'oneslash-design-system/components/layout';
29
+
30
+ export default function RouteLoadingFullScreen() {
31
+ return (
32
+ <Center fill>
33
+ <LoadingScreen />
34
+ </Center>
35
+ );
36
+ }
37
+ ```
38
+
39
+ ## Option: In one pane
40
+
41
+ Use when: The shell shows and one pane loads.
42
+
43
+ Uses: `Cluster`, `Image`, `LoadingScreen`, `Stack`, `Surface`, `Tab`, `TabsContainer`
44
+
45
+ ```tsx
46
+ 'use client';
47
+ import Image from 'oneslash-design-system/components/image';
48
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
49
+ import Tab from 'oneslash-design-system/components/tab';
50
+ import Surface from 'oneslash-design-system/components/surface';
51
+ import LoadingScreen from 'oneslash-design-system/components/loadingScreen';
52
+ import { Cluster, Stack } from 'oneslash-design-system/components/layout';
53
+
54
+ // The product's mark. A real app passes its own file.
55
+ const productMark =
56
+ "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";
57
+
58
+ // A real app passes the router from its framework, such as Next's useRouter().
59
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
60
+
61
+ export default function RouteLoadingRegion() {
62
+ return (
63
+ <Stack gap="large">
64
+ <Cluster gap="large">
65
+ <Image src={productMark} alt="Acme" width={32} height={32} />
66
+ <TabsContainer>
67
+ <Tab label="Home" isSelected={false} href="/" router={router} onClickTab={() => {}} />
68
+ <Tab label="Projects" isSelected href="/projects" router={router} onClickTab={() => {}} />
69
+ <Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={() => {}} />
70
+ </TabsContainer>
71
+ </Cluster>
72
+ <Surface minHeight="tall" align="center">
73
+ <LoadingScreen />
74
+ </Surface>
75
+ </Stack>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Native
81
+
82
+ On Apple use `ProgressView()` with no label, centered in the pane.
83
+
84
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function SetNewPasswordForm(): import("react").JSX.Element;
@@ -0,0 +1,130 @@
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 Heading from '../../components/heading';
7
+ import Paragraph from '../../components/paragraph';
8
+ import Form from '../../components/form';
9
+ import Alert from '../../components/alert';
10
+ import TextField from '../../components/textField';
11
+ import Button from '../../components/button';
12
+ import Line from '../../components/line';
13
+ import BrandIcon from '../../components/brandIcon';
14
+ import { Center, Stack } from '../../components/layout';
15
+ // The product's mark. A real app passes its own file.
16
+ 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";
17
+ // A real app passes the router from its framework, such as Next's useRouter().
18
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
19
+ // A real app passes the address of the account the reset link was sent for.
20
+ var address = 'ada@example.com';
21
+ // A small check: some text, an @, then some text.
22
+ function looksLikeEmail(value) {
23
+ return /^[^@\s]+@[^@\s]+$/.test(value);
24
+ }
25
+ export default function SetNewPasswordForm() {
26
+ var _a = useState(false), updated = _a[0], setUpdated = _a[1];
27
+ var _b = useState(''), newPassword = _b[0], setNewPassword = _b[1];
28
+ var _c = useState(''), confirmPassword = _c[0], setConfirmPassword = _c[1];
29
+ var _d = useState(''), newPasswordError = _d[0], setNewPasswordError = _d[1];
30
+ var _e = useState(''), confirmPasswordError = _e[0], setConfirmPasswordError = _e[1];
31
+ var _f = useState(''), notice = _f[0], setNotice = _f[1];
32
+ var _g = useState(address), email = _g[0], setEmail = _g[1];
33
+ var _h = useState(''), password = _h[0], setPassword = _h[1];
34
+ var _j = useState(''), emailError = _j[0], setEmailError = _j[1];
35
+ var _k = useState(''), passwordError = _k[0], setPasswordError = _k[1];
36
+ var _l = useState(''), error = _l[0], setError = _l[1];
37
+ var _m = useState(false), loading = _m[0], setLoading = _m[1];
38
+ var timer = useRef();
39
+ // Stops the request if the example goes away before it ends.
40
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
41
+ function handleUpdate() {
42
+ if (loading)
43
+ return;
44
+ setError('');
45
+ setNewPasswordError('');
46
+ setConfirmPasswordError('');
47
+ if (newPassword.length < 8) {
48
+ setNewPasswordError('Use at least 8 characters.');
49
+ return;
50
+ }
51
+ if (!confirmPassword) {
52
+ setConfirmPasswordError('Enter the new password again.');
53
+ return;
54
+ }
55
+ if (confirmPassword !== newPassword) {
56
+ setConfirmPasswordError('This does not match. Enter the same password as above.');
57
+ return;
58
+ }
59
+ setLoading(true);
60
+ // Stands in for the request to the server.
61
+ // A failed request calls setError with one sentence instead, such as 'Your password was not updated. Try again.'
62
+ timer.current = setTimeout(function () {
63
+ setLoading(false);
64
+ // A real app signs the reset session out and goes to its login page here, which shows the notice.
65
+ // The example shows it in place.
66
+ setNotice('Password updated. Log in with your new password.');
67
+ setUpdated(true);
68
+ }, 1200);
69
+ }
70
+ function handleLogIn() {
71
+ if (loading)
72
+ return;
73
+ setNotice('');
74
+ setError('');
75
+ setEmailError('');
76
+ setPasswordError('');
77
+ if (!email.trim()) {
78
+ setEmailError('Enter your email.');
79
+ return;
80
+ }
81
+ if (!looksLikeEmail(email.trim())) {
82
+ setEmailError('Enter an email address, like name@example.com.');
83
+ return;
84
+ }
85
+ if (!password) {
86
+ setPasswordError('Enter your password.');
87
+ return;
88
+ }
89
+ setLoading(true);
90
+ // Stands in for the request to the server.
91
+ timer.current = setTimeout(function () {
92
+ setLoading(false);
93
+ setError('That email and password do not match.');
94
+ }, 1200);
95
+ }
96
+ if (updated) {
97
+ return (<Center fill>
98
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
99
+ <TabsContainer fill>
100
+ <Tab label="Log In" isSelected onClickTab={function () { }}/>
101
+ <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={function () { }}/>
102
+ </TabsContainer>
103
+ <Form aria-label="Log in" onSubmit={handleLogIn}>
104
+ {/* 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. */}
105
+ {notice && <Alert type="success" variant="inline" message={notice} autoDismiss={false}/>}
106
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
107
+ <TextField id="set-new-password-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(''); }}/>
108
+ <TextField id="set-new-password-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(''); }}/>
109
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
110
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot Password?"/>
111
+ </Form>
112
+ <Line label="or"/>
113
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
114
+ </Center>);
115
+ }
116
+ return (<Center fill>
117
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
118
+ <Stack gap="medium">
119
+ <Heading level={1} size="h5">Set new password</Heading>
120
+ <Paragraph tone="secondary" measure="none">Choose a new password for {address}.</Paragraph>
121
+ </Stack>
122
+ <Form aria-label="Set new password" onSubmit={handleUpdate}>
123
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
124
+ {/* Editing the new password also clears the message under Confirm password, which may no longer be true. */}
125
+ <TextField id="set-new-password-new" label="New password" type="password" autoComplete="new-password" value={newPassword} disabled={loading} error={Boolean(newPasswordError)} errorText={newPasswordError} helperText="Use at least 8 characters." onChange={function (e) { setNewPassword(e.target.value); setNewPasswordError(''); setConfirmPasswordError(''); }}/>
126
+ <TextField id="set-new-password-confirm" label="Confirm password" type="password" autoComplete="new-password" value={confirmPassword} disabled={loading} error={Boolean(confirmPasswordError)} errorText={confirmPasswordError} onChange={function (e) { setConfirmPassword(e.target.value); setConfirmPasswordError(''); }}/>
127
+ <Button size="medium" type="primary" state="enabled" label="Update Password" htmlType="submit" loading={loading}/>
128
+ </Form>
129
+ </Center>);
130
+ }
@@ -0,0 +1 @@
1
+ export default function SetNewPasswordInvalidLink(): import("react").JSX.Element;
@@ -0,0 +1,50 @@
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 Alert from '../../components/alert';
8
+ import Button from '../../components/button';
9
+ import { Center, Stack } from '../../components/layout';
10
+ // A real app passes the router from its framework, such as Next's useRouter().
11
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
12
+ // A real app passes the address of the account the old link was sent for.
13
+ var address = 'ada@example.com';
14
+ export default function SetNewPasswordInvalidLink() {
15
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
16
+ var _b = useState(false), sent = _b[0], setSent = _b[1];
17
+ var timer = useRef();
18
+ // Stops the request if the example goes away before it ends.
19
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
20
+ function handleSendNewLink() {
21
+ if (loading)
22
+ return;
23
+ setLoading(true);
24
+ // Stands in for the request to the server.
25
+ // A failed request shows an inline error Alert above the Buttons, such as 'The link was not sent. Try again.'
26
+ timer.current = setTimeout(function () {
27
+ setLoading(false);
28
+ setSent(true);
29
+ }, 1200);
30
+ }
31
+ if (sent) {
32
+ return (<Center width="form" fill>
33
+ <Icon icon={Mail} size="large" color="secondary"/>
34
+ <Stack gap="medium">
35
+ <Heading level={1} size="h5">Check your email</Heading>
36
+ <Paragraph tone="secondary" measure="none">We sent a new link to {address}. Open it to set a new password.</Paragraph>
37
+ </Stack>
38
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
39
+ </Center>);
40
+ }
41
+ return (<Center width="form" fill>
42
+ <Heading level={1} size="h5">Set new password</Heading>
43
+ {/* The link cannot be used, so the form does not show. The Alert reports a standing condition: it has no close button and stays. */}
44
+ <Alert type="error" variant="inline" message="This link has expired or was already used." autoDismiss={false}/>
45
+ <Stack gap="large">
46
+ <Button size="medium" type="primary" state="enabled" label="Send a New Link" loading={loading} onClickButton={handleSendNewLink}/>
47
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
48
+ </Stack>
49
+ </Center>);
50
+ }
@@ -0,0 +1,247 @@
1
+ # Set new password
2
+
3
+ A person opened the link to reset their password and now chooses a new one.
4
+
5
+ **Not built yet:** Commentify and Scindo on the web replace the form with a spinner while updating, and show field problems in an Alert above the fields. Both accept 6 characters, and say 'Password must be at least 6 characters.' only after it is broken. Scindo's reset page has no invalid-link state.
6
+
7
+ ## Do
8
+
9
+ - Name the page 'Set new password' in a `Heading` with `level={1}`, and name the account it is for.
10
+ - Ask for 'New password' and 'Confirm password', and send them with 'Update Password'. Ask twice here: the old password is gone after this, and there is no other way to catch a typo.
11
+ - Say the product's password rule before the person breaks it, such as 'Use at least 8 characters.'
12
+ - Put the rule in the password field's `helperText`, so it is tied to the field.
13
+ - Check the rule on the server too, and show its refusal under the field.
14
+ - Show a problem with one field under that field: a password that does not match shows under Confirm password, and clears when either field changes.
15
+ - Show the loading state on the submit Button while updating, and keep the form in place.
16
+ - Log the person out of the reset link's session before showing the login form, so they really log in with the new password.
17
+ - Go to the login form on success, with a success Alert above it: 'Password updated. Log in with your new password.'
18
+
19
+ ## Don't
20
+
21
+ - Do not show the rule only after the person breaks it.
22
+ - Do not show a mismatch above the fields; it belongs under Confirm password.
23
+ - Do not replace the form with a spinner while updating.
24
+ - Do not show the form when the link is invalid or expired.
25
+
26
+ ## Option: New password form
27
+
28
+ Use when: The link is valid.
29
+
30
+ Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Image`, `Line`, `Paragraph`, `Stack`, `Tab`, `TabsContainer`, `TextField`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { useEffect, useRef, useState } from 'react';
35
+ import Image from 'oneslash-design-system/components/image';
36
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
37
+ import Tab from 'oneslash-design-system/components/tab';
38
+ import Heading from 'oneslash-design-system/components/heading';
39
+ import Paragraph from 'oneslash-design-system/components/paragraph';
40
+ import Form from 'oneslash-design-system/components/form';
41
+ import Alert from 'oneslash-design-system/components/alert';
42
+ import TextField from 'oneslash-design-system/components/textField';
43
+ import Button from 'oneslash-design-system/components/button';
44
+ import Line from 'oneslash-design-system/components/line';
45
+ import BrandIcon from 'oneslash-design-system/components/brandIcon';
46
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
47
+
48
+ // The product's mark. A real app passes its own file.
49
+ const productMark =
50
+ "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";
51
+
52
+ // A real app passes the router from its framework, such as Next's useRouter().
53
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
54
+
55
+ // A real app passes the address of the account the reset link was sent for.
56
+ const address = 'ada@example.com';
57
+
58
+ // A small check: some text, an @, then some text.
59
+ function looksLikeEmail(value: string) {
60
+ return /^[^@\s]+@[^@\s]+$/.test(value);
61
+ }
62
+
63
+ export default function SetNewPasswordForm() {
64
+ const [updated, setUpdated] = useState(false);
65
+ const [newPassword, setNewPassword] = useState('');
66
+ const [confirmPassword, setConfirmPassword] = useState('');
67
+ const [newPasswordError, setNewPasswordError] = useState('');
68
+ const [confirmPasswordError, setConfirmPasswordError] = useState('');
69
+ const [notice, setNotice] = useState('');
70
+ const [email, setEmail] = useState(address);
71
+ const [password, setPassword] = useState('');
72
+ const [emailError, setEmailError] = useState('');
73
+ const [passwordError, setPasswordError] = useState('');
74
+ const [error, setError] = useState('');
75
+ const [loading, setLoading] = useState(false);
76
+ const timer = useRef<ReturnType<typeof setTimeout>>();
77
+
78
+ // Stops the request if the example goes away before it ends.
79
+ useEffect(() => () => clearTimeout(timer.current), []);
80
+
81
+ function handleUpdate() {
82
+ if (loading) return;
83
+ setError('');
84
+ setNewPasswordError('');
85
+ setConfirmPasswordError('');
86
+ if (newPassword.length < 8) {
87
+ setNewPasswordError('Use at least 8 characters.');
88
+ return;
89
+ }
90
+ if (!confirmPassword) {
91
+ setConfirmPasswordError('Enter the new password again.');
92
+ return;
93
+ }
94
+ if (confirmPassword !== newPassword) {
95
+ setConfirmPasswordError('This does not match. Enter the same password as above.');
96
+ return;
97
+ }
98
+ setLoading(true);
99
+ // Stands in for the request to the server.
100
+ // A failed request calls setError with one sentence instead, such as 'Your password was not updated. Try again.'
101
+ timer.current = setTimeout(() => {
102
+ setLoading(false);
103
+ // A real app signs the reset session out and goes to its login page here, which shows the notice.
104
+ // The example shows it in place.
105
+ setNotice('Password updated. Log in with your new password.');
106
+ setUpdated(true);
107
+ }, 1200);
108
+ }
109
+
110
+ function handleLogIn() {
111
+ if (loading) return;
112
+ setNotice('');
113
+ setError('');
114
+ setEmailError('');
115
+ setPasswordError('');
116
+ if (!email.trim()) {
117
+ setEmailError('Enter your email.');
118
+ return;
119
+ }
120
+ if (!looksLikeEmail(email.trim())) {
121
+ setEmailError('Enter an email address, like name@example.com.');
122
+ return;
123
+ }
124
+ if (!password) {
125
+ setPasswordError('Enter your password.');
126
+ return;
127
+ }
128
+ setLoading(true);
129
+ // Stands in for the request to the server.
130
+ timer.current = setTimeout(() => {
131
+ setLoading(false);
132
+ setError('That email and password do not match.');
133
+ }, 1200);
134
+ }
135
+
136
+ if (updated) {
137
+ return (
138
+ <Center fill>
139
+ <Image src={productMark} alt="Acme" width={40} height={40} />
140
+ <TabsContainer fill>
141
+ <Tab label="Log In" isSelected onClickTab={() => {}} />
142
+ <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={() => {}} />
143
+ </TabsContainer>
144
+ <Form aria-label="Log in" onSubmit={handleLogIn}>
145
+ {/* 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. */}
146
+ {notice && <Alert type="success" variant="inline" message={notice} autoDismiss={false} />}
147
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
148
+ <TextField id="set-new-password-login-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
149
+ <TextField id="set-new-password-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(''); }} />
150
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
151
+ <Button size="medium" type="textOnly" state="enabled" label="Forgot Password?" />
152
+ </Form>
153
+ <Line label="or" />
154
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
155
+ </Center>
156
+ );
157
+ }
158
+
159
+ return (
160
+ <Center fill>
161
+ <Image src={productMark} alt="Acme" width={40} height={40} />
162
+ <Stack gap="medium">
163
+ <Heading level={1} size="h5">Set new password</Heading>
164
+ <Paragraph tone="secondary" measure="none">Choose a new password for {address}.</Paragraph>
165
+ </Stack>
166
+ <Form aria-label="Set new password" onSubmit={handleUpdate}>
167
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
168
+ {/* Editing the new password also clears the message under Confirm password, which may no longer be true. */}
169
+ <TextField id="set-new-password-new" label="New password" type="password" autoComplete="new-password" value={newPassword} disabled={loading} error={Boolean(newPasswordError)} errorText={newPasswordError} helperText="Use at least 8 characters." onChange={(e) => { setNewPassword(e.target.value); setNewPasswordError(''); setConfirmPasswordError(''); }} />
170
+ <TextField id="set-new-password-confirm" label="Confirm password" type="password" autoComplete="new-password" value={confirmPassword} disabled={loading} error={Boolean(confirmPasswordError)} errorText={confirmPasswordError} onChange={(e) => { setConfirmPassword(e.target.value); setConfirmPasswordError(''); }} />
171
+ <Button size="medium" type="primary" state="enabled" label="Update Password" htmlType="submit" loading={loading} />
172
+ </Form>
173
+ </Center>
174
+ );
175
+ }
176
+ ```
177
+
178
+ ## Option: Link no longer works
179
+
180
+ Use when: The link is invalid, expired or already used.
181
+
182
+ Uses: `Alert`, `Button`, `Center`, `Heading`, `Icon`, `Paragraph`, `Stack`
183
+
184
+ ```tsx
185
+ 'use client';
186
+ import { useEffect, useRef, useState } from 'react';
187
+ import { Mail } from 'lucide-react';
188
+ import Icon from 'oneslash-design-system/components/icon';
189
+ import Heading from 'oneslash-design-system/components/heading';
190
+ import Paragraph from 'oneslash-design-system/components/paragraph';
191
+ import Alert from 'oneslash-design-system/components/alert';
192
+ import Button from 'oneslash-design-system/components/button';
193
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
194
+
195
+ // A real app passes the router from its framework, such as Next's useRouter().
196
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
197
+
198
+ // A real app passes the address of the account the old link was sent for.
199
+ const address = 'ada@example.com';
200
+
201
+ export default function SetNewPasswordInvalidLink() {
202
+ const [loading, setLoading] = useState(false);
203
+ const [sent, setSent] = useState(false);
204
+ const timer = useRef<ReturnType<typeof setTimeout>>();
205
+
206
+ // Stops the request if the example goes away before it ends.
207
+ useEffect(() => () => clearTimeout(timer.current), []);
208
+
209
+ function handleSendNewLink() {
210
+ if (loading) return;
211
+ setLoading(true);
212
+ // Stands in for the request to the server.
213
+ // A failed request shows an inline error Alert above the Buttons, such as 'The link was not sent. Try again.'
214
+ timer.current = setTimeout(() => {
215
+ setLoading(false);
216
+ setSent(true);
217
+ }, 1200);
218
+ }
219
+
220
+ if (sent) {
221
+ return (
222
+ <Center width="form" fill>
223
+ <Icon icon={Mail} size="large" color="secondary" />
224
+ <Stack gap="medium">
225
+ <Heading level={1} size="h5">Check your email</Heading>
226
+ <Paragraph tone="secondary" measure="none">We sent a new link to {address}. Open it to set a new password.</Paragraph>
227
+ </Stack>
228
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={() => router.push('/login')} />
229
+ </Center>
230
+ );
231
+ }
232
+
233
+ return (
234
+ <Center width="form" fill>
235
+ <Heading level={1} size="h5">Set new password</Heading>
236
+ {/* The link cannot be used, so the form does not show. The Alert reports a standing condition: it has no close button and stays. */}
237
+ <Alert type="error" variant="inline" message="This link has expired or was already used." autoDismiss={false} />
238
+ <Stack gap="large">
239
+ <Button size="medium" type="primary" state="enabled" label="Send a New Link" loading={loading} onClickButton={handleSendNewLink} />
240
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Back to Login" onClickButton={() => router.push('/login')} />
241
+ </Stack>
242
+ </Center>
243
+ );
244
+ }
245
+ ```
246
+
247
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function SignUpCentered(): import("react").JSX.Element;
@@ -0,0 +1,124 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Mail } from 'lucide-react';
4
+ import Image from '../../components/image';
5
+ import TabsContainer from '../../components/tabsContainer';
6
+ import Tab from '../../components/tab';
7
+ import Form from '../../components/form';
8
+ import Alert from '../../components/alert';
9
+ import TextField from '../../components/textField';
10
+ import Paragraph from '../../components/paragraph';
11
+ import Heading from '../../components/heading';
12
+ import Icon from '../../components/icon';
13
+ import Button from '../../components/button';
14
+ import Line from '../../components/line';
15
+ import BrandIcon from '../../components/brandIcon';
16
+ import { Center, Stack } from '../../components/layout';
17
+ // The product's mark. A real app passes its own file.
18
+ 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";
19
+ // A real app passes the router from its framework, such as Next's useRouter().
20
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
21
+ // A small check: some text, an @, then some text.
22
+ function looksLikeEmail(value) {
23
+ return /^[^@\s]+@[^@\s]+$/.test(value);
24
+ }
25
+ export default function SignUpCentered() {
26
+ var _a = useState('Ada Lovelace'), name = _a[0], setName = _a[1];
27
+ var _b = useState('ada@example.com'), email = _b[0], setEmail = _b[1];
28
+ var _c = useState(''), password = _c[0], setPassword = _c[1];
29
+ var _d = useState(''), error = _d[0], setError = _d[1];
30
+ var _e = useState(''), nameError = _e[0], setNameError = _e[1];
31
+ var _f = useState(''), emailError = _f[0], setEmailError = _f[1];
32
+ var _g = useState(''), passwordError = _g[0], setPasswordError = _g[1];
33
+ var _h = useState(false), loading = _h[0], setLoading = _h[1];
34
+ // The address the link went to. Set once the account request ends, which shows the check-your-email view.
35
+ var _j = useState(''), sentTo = _j[0], setSentTo = _j[1];
36
+ var _k = useState(false), resending = _k[0], setResending = _k[1];
37
+ var _l = useState(false), resent = _l[0], setResent = _l[1];
38
+ var timer = useRef();
39
+ // Stops the request if the example goes away before it ends.
40
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
41
+ // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.
42
+ useEffect(function () {
43
+ if (!resent)
44
+ return;
45
+ var timer = setTimeout(function () { return setResent(false); }, 2000);
46
+ return function () { return clearTimeout(timer); };
47
+ }, [resent]);
48
+ function handleSubmit() {
49
+ if (loading)
50
+ return;
51
+ setError('');
52
+ setNameError('');
53
+ setEmailError('');
54
+ setPasswordError('');
55
+ if (!name.trim()) {
56
+ setNameError('Enter your name.');
57
+ return;
58
+ }
59
+ if (!email.trim()) {
60
+ setEmailError('Enter your email.');
61
+ return;
62
+ }
63
+ if (!looksLikeEmail(email.trim())) {
64
+ setEmailError('Enter an email address, like name@example.com.');
65
+ return;
66
+ }
67
+ if (password.length < 8) {
68
+ setPasswordError('Use at least 8 characters.');
69
+ return;
70
+ }
71
+ setLoading(true);
72
+ var address = email.trim();
73
+ // Stands in for the request to the server.
74
+ // A failed request calls setError with one sentence instead, such as 'Your account was not created. Try again.'
75
+ timer.current = setTimeout(function () {
76
+ // Every address goes on to the same view, so the page never says whether it has an account.
77
+ // The Button stays loading until the view changes.
78
+ setLoading(false);
79
+ setSentTo(address);
80
+ }, 1200);
81
+ }
82
+ function handleSendAgain() {
83
+ // One click sends one email: clicks while it sends or reads 'Sent' do nothing.
84
+ if (resending || resent)
85
+ return;
86
+ setResending(true);
87
+ // Stands in for the request to the server.
88
+ // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'
89
+ timer.current = setTimeout(function () {
90
+ setResending(false);
91
+ setResent(true);
92
+ }, 1200);
93
+ }
94
+ // The same view as the 'Check your email' case, in place of the form.
95
+ if (sentTo) {
96
+ return (<Center fill>
97
+ <Icon icon={Mail} size="large" color="secondary"/>
98
+ <Stack gap="medium">
99
+ <Heading level={1} size="h5">Check your email</Heading>
100
+ <Paragraph tone="secondary" measure="none">We sent a link to {sentTo}. Open it to continue.</Paragraph>
101
+ </Stack>
102
+ <Stack gap="large">
103
+ <Button size="medium" type="secondary" state="enabled" label={resent ? 'Sent' : 'Send Again'} loading={resending} onClickButton={handleSendAgain}/>
104
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
105
+ </Stack>
106
+ </Center>);
107
+ }
108
+ return (<Center fill>
109
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
110
+ <TabsContainer fill>
111
+ <Tab label="Log In" isSelected={false} href="/login" router={router} onClickTab={function () { }}/>
112
+ <Tab label="Sign Up" isSelected onClickTab={function () { }}/>
113
+ </TabsContainer>
114
+ <Form aria-label="Sign up" onSubmit={handleSubmit}>
115
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
116
+ <TextField id="sign-up-page-centered-name" label="Name" autoComplete="name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
117
+ <TextField id="sign-up-page-centered-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
118
+ <TextField id="sign-up-page-centered-password" label="Password" type="password" autoComplete="new-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} helperText="Use at least 8 characters." onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
119
+ <Button size="medium" type="primary" state="enabled" label="Sign Up" htmlType="submit" loading={loading}/>
120
+ </Form>
121
+ <Line label="or"/>
122
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
123
+ </Center>);
124
+ }
@@ -0,0 +1 @@
1
+ export default function SignUpProviderFirst(): import("react").JSX.Element;