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
@@ -1,33 +1,34 @@
1
1
  # Login page
2
2
 
3
- A person who already has an account opens the product and is not signed in.
3
+ A person who already has an account opens the product and is not logged in.
4
4
 
5
- **Not built yet:** Commentify and Scindo on the web replace the form with a spinner while signing in. They do not use the Button's loading state yet.
5
+ **Not built yet:** Commentify and Scindo on the web replace the form with a spinner while logging in. They do not use the Button's loading state yet.
6
6
 
7
7
  ## Do
8
8
 
9
9
  - Show a problem with one field under that field.
10
- - Show a refused sign-in or a failed request in an inline Alert above the fields.
11
- - When there is a password, put a text-only 'Forgot password?' Button right under the submit Button.
10
+ - Show a refused login or a failed request in an inline Alert above the fields.
11
+ - Put a text-only 'Forgot Password?' Button right under the submit Button when there is a password.
12
12
  - Name the provider on its button: 'Continue with Google'.
13
- - While signing in, show the loading state on the submit Button and keep the form in place.
13
+ - Show the loading state on the submit Button while logging in, and keep the form in place.
14
+ - Disable the fields while the request runs.
14
15
 
15
16
  ## Don't
16
17
 
17
18
  - Do not clear the email field after a failed attempt.
18
19
  - Do not show sign-up fields on the login page; link or tab to sign-up.
19
- - Do not replace the form with a spinner while signing in.
20
+ - Do not replace the form with a spinner while logging in.
20
21
  - Do not say which of the email or the password was wrong.
21
22
 
22
23
  ## Option: Centered column
23
24
 
24
- Use when: The product has one way in, and most people sign in with email and a password.
25
+ Use when: The product has one way in, and most people log in with email and a password.
25
26
 
26
27
  Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Image`, `Line`, `Tab`, `TabsContainer`, `TextField`
27
28
 
28
29
  ```tsx
29
30
  'use client';
30
- import { useState } from 'react';
31
+ import { useEffect, useRef, useState } from 'react';
31
32
  import Image from 'oneslash-design-system/components/image';
32
33
  import TabsContainer from 'oneslash-design-system/components/tabsContainer';
33
34
  import Tab from 'oneslash-design-system/components/tab';
@@ -58,6 +59,10 @@ export default function LoginCentered() {
58
59
  const [emailError, setEmailError] = useState('');
59
60
  const [passwordError, setPasswordError] = useState('');
60
61
  const [loading, setLoading] = useState(false);
62
+ const timer = useRef<ReturnType<typeof setTimeout>>();
63
+
64
+ // Stops the request if the example goes away before it ends.
65
+ useEffect(() => () => clearTimeout(timer.current), []);
61
66
 
62
67
  function handleSubmit() {
63
68
  if (loading) return;
@@ -69,7 +74,7 @@ export default function LoginCentered() {
69
74
  return;
70
75
  }
71
76
  if (!looksLikeEmail(email.trim())) {
72
- setEmailError('Enter a valid email address.');
77
+ setEmailError('Enter an email address, like name@example.com.');
73
78
  return;
74
79
  }
75
80
  if (!password) {
@@ -78,7 +83,7 @@ export default function LoginCentered() {
78
83
  }
79
84
  setLoading(true);
80
85
  // Stands in for the request to the server.
81
- setTimeout(() => {
86
+ timer.current = setTimeout(() => {
82
87
  setLoading(false);
83
88
  setError('That email and password do not match.');
84
89
  }, 1200);
@@ -87,16 +92,16 @@ export default function LoginCentered() {
87
92
  return (
88
93
  <Center fill>
89
94
  <Image src={productMark} alt="Acme" width={40} height={40} />
90
- <TabsContainer>
95
+ <TabsContainer fill>
91
96
  <Tab label="Log In" isSelected onClickTab={() => {}} />
92
97
  <Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={() => {}} />
93
98
  </TabsContainer>
94
99
  <Form aria-label="Log in" onSubmit={handleSubmit}>
95
100
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
96
- <TextField id="login-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
97
- <TextField id="login-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
101
+ <TextField id="login-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
102
+ <TextField id="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(''); }} />
98
103
  <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
99
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?" />
104
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
100
105
  </Form>
101
106
  <Line label="or" />
102
107
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
@@ -113,7 +118,7 @@ Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `I
113
118
 
114
119
  ```tsx
115
120
  'use client';
116
- import { useState } from 'react';
121
+ import { useEffect, useRef, useState } from 'react';
117
122
  import Image from 'oneslash-design-system/components/image';
118
123
  import Heading from 'oneslash-design-system/components/heading';
119
124
  import Paragraph from 'oneslash-design-system/components/paragraph';
@@ -142,6 +147,10 @@ export default function LoginSplit() {
142
147
  const [emailError, setEmailError] = useState('');
143
148
  const [passwordError, setPasswordError] = useState('');
144
149
  const [loading, setLoading] = useState(false);
150
+ const timer = useRef<ReturnType<typeof setTimeout>>();
151
+
152
+ // Stops the request if the example goes away before it ends.
153
+ useEffect(() => () => clearTimeout(timer.current), []);
145
154
 
146
155
  function handleSubmit() {
147
156
  if (loading) return;
@@ -153,7 +162,7 @@ export default function LoginSplit() {
153
162
  return;
154
163
  }
155
164
  if (!looksLikeEmail(email.trim())) {
156
- setEmailError('Enter a valid email address.');
165
+ setEmailError('Enter an email address, like name@example.com.');
157
166
  return;
158
167
  }
159
168
  if (!password) {
@@ -162,7 +171,7 @@ export default function LoginSplit() {
162
171
  }
163
172
  setLoading(true);
164
173
  // Stands in for the request to the server.
165
- setTimeout(() => {
174
+ timer.current = setTimeout(() => {
166
175
  setLoading(false);
167
176
  setError('That email and password do not match.');
168
177
  }, 1200);
@@ -182,19 +191,19 @@ export default function LoginSplit() {
182
191
  }
183
192
  >
184
193
  <Center fill>
185
- <Heading level={2} size="h5">Log in to Acme</Heading>
194
+ <Heading level={1} size="h5">Log in to Acme</Heading>
186
195
  <Form aria-label="Log in" onSubmit={handleSubmit}>
187
196
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
188
- <TextField id="split-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
189
- <TextField id="split-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
197
+ <TextField id="split-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
198
+ <TextField id="split-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
190
199
  <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
191
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?" />
200
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
192
201
  </Form>
193
202
  <Line label="or" />
194
203
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
195
204
  <Cluster gap="small">
196
205
  <Paragraph tone="secondary" size="body2" measure="none">New here?</Paragraph>
197
- <Link href="/signup" size="body2">Create an account</Link>
206
+ <Link href="/sign-up" size="body2">Sign Up</Link>
198
207
  </Cluster>
199
208
  </Center>
200
209
  </Split>
@@ -204,13 +213,13 @@ export default function LoginSplit() {
204
213
 
205
214
  ## Option: Provider first
206
215
 
207
- Use when: Most people sign in with Google, GitHub or Apple; email is the fallback.
216
+ Use when: Most people log in with Google, GitHub or Apple; email is the fallback.
208
217
 
209
218
  Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Line`, `Stack`, `TextField`
210
219
 
211
220
  ```tsx
212
221
  'use client';
213
- import { useState } from 'react';
222
+ import { useEffect, useRef, useState } from 'react';
214
223
  import Heading from 'oneslash-design-system/components/heading';
215
224
  import Form from 'oneslash-design-system/components/form';
216
225
  import Alert from 'oneslash-design-system/components/alert';
@@ -232,6 +241,10 @@ export default function LoginProviderFirst() {
232
241
  const [emailError, setEmailError] = useState('');
233
242
  const [passwordError, setPasswordError] = useState('');
234
243
  const [loading, setLoading] = useState(false);
244
+ const timer = useRef<ReturnType<typeof setTimeout>>();
245
+
246
+ // Stops the request if the example goes away before it ends.
247
+ useEffect(() => () => clearTimeout(timer.current), []);
235
248
 
236
249
  function handleSubmit() {
237
250
  if (loading) return;
@@ -243,7 +256,7 @@ export default function LoginProviderFirst() {
243
256
  return;
244
257
  }
245
258
  if (!looksLikeEmail(email.trim())) {
246
- setEmailError('Enter a valid email address.');
259
+ setEmailError('Enter an email address, like name@example.com.');
247
260
  return;
248
261
  }
249
262
  if (!password) {
@@ -252,7 +265,7 @@ export default function LoginProviderFirst() {
252
265
  }
253
266
  setLoading(true);
254
267
  // Stands in for the request to the server.
255
- setTimeout(() => {
268
+ timer.current = setTimeout(() => {
256
269
  setLoading(false);
257
270
  setError('That email and password do not match.');
258
271
  }, 1200);
@@ -260,19 +273,19 @@ export default function LoginProviderFirst() {
260
273
 
261
274
  return (
262
275
  <Center fill>
263
- <Heading level={2} size="h5">Sign in to Acme</Heading>
276
+ <Heading level={1} size="h5">Log in to Acme</Heading>
264
277
  <Stack gap="medium">
265
278
  <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
266
279
  <Button size="medium" type="secondary" state="enabled" label="Continue with GitHub" decoIcon={<BrandIcon name="github" />} />
267
280
  <Button size="medium" type="secondary" state="enabled" label="Continue with Apple" decoIcon={<BrandIcon name="apple" />} />
268
281
  </Stack>
269
282
  <Line label="or" />
270
- <Form aria-label="Sign in with email" onSubmit={handleSubmit}>
283
+ <Form aria-label="Log in with email" onSubmit={handleSubmit}>
271
284
  {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
272
- <TextField id="provider-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
273
- <TextField id="provider-password" label="Password" type="password" autoComplete="current-password" value={password} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
274
- <Button size="medium" type="primary" state="enabled" label="Sign in with email" htmlType="submit" loading={loading} />
275
- <Button size="medium" type="textOnly" state="enabled" label="Forgot password?" />
285
+ <TextField id="provider-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
286
+ <TextField id="provider-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
287
+ <Button size="medium" type="primary" state="enabled" label="Log In with Email" htmlType="submit" loading={loading} />
288
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
276
289
  </Form>
277
290
  </Center>
278
291
  );
@@ -281,13 +294,13 @@ export default function LoginProviderFirst() {
281
294
 
282
295
  ## Option: Email only
283
296
 
284
- Use when: An internal tool with no passwords: the person gets a sign-in link by email.
297
+ Use when: An internal tool with no passwords: the person gets a login link by email.
285
298
 
286
299
  Uses: `Alert`, `Button`, `Center`, `Form`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
287
300
 
288
301
  ```tsx
289
302
  'use client';
290
- import { useState } from 'react';
303
+ import { useEffect, useRef, useState } from 'react';
291
304
  import Surface from 'oneslash-design-system/components/surface';
292
305
  import Heading from 'oneslash-design-system/components/heading';
293
306
  import Paragraph from 'oneslash-design-system/components/paragraph';
@@ -307,6 +320,10 @@ export default function LoginEmailOnly() {
307
320
  const [sentTo, setSentTo] = useState('');
308
321
  const [emailError, setEmailError] = useState('');
309
322
  const [loading, setLoading] = useState(false);
323
+ const timer = useRef<ReturnType<typeof setTimeout>>();
324
+
325
+ // Stops the request if the example goes away before it ends.
326
+ useEffect(() => () => clearTimeout(timer.current), []);
310
327
 
311
328
  function handleSubmit() {
312
329
  if (loading) return;
@@ -317,13 +334,13 @@ export default function LoginEmailOnly() {
317
334
  return;
318
335
  }
319
336
  if (!looksLikeEmail(email.trim())) {
320
- setEmailError('Enter a valid email address.');
337
+ setEmailError('Enter an email address, like name@example.com.');
321
338
  return;
322
339
  }
323
340
  setLoading(true);
324
341
  const address = email.trim();
325
342
  // Stands in for the request to the server.
326
- setTimeout(() => {
343
+ timer.current = setTimeout(() => {
327
344
  setLoading(false);
328
345
  setSentTo(address);
329
346
  }, 1200);
@@ -334,13 +351,13 @@ export default function LoginEmailOnly() {
334
351
  <Surface padding="large">
335
352
  <Stack gap="xlarge">
336
353
  <Stack gap="small">
337
- <Heading level={2} size="h5">Log in</Heading>
338
- <Paragraph tone="secondary" size="body2" measure="none">We will email you a link to sign in.</Paragraph>
354
+ <Heading level={1} size="h5">Log in</Heading>
355
+ <Paragraph tone="secondary" size="body2" measure="none">We will email you a link to log in.</Paragraph>
339
356
  </Stack>
340
357
  <Form aria-label="Log in" onSubmit={handleSubmit}>
341
- {sentTo && <Alert type="success" variant="inline" message={`We sent a sign-in link to ${sentTo}.`} showCloseButton onClose={() => setSentTo('')} />}
342
- <TextField id="email-only-email" label="Email" type="email" autoComplete="username" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
343
- <Button size="medium" type="primary" state="enabled" label="Send sign-in link" htmlType="submit" loading={loading} />
358
+ {sentTo && <Alert type="success" variant="inline" message={`We sent a login link to ${sentTo}.`} autoDismiss={false} />}
359
+ <TextField id="email-only-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
360
+ <Button size="medium" type="primary" state="enabled" label="Send Login Link" htmlType="submit" loading={loading} />
344
361
  </Form>
345
362
  </Stack>
346
363
  </Surface>
@@ -0,0 +1 @@
1
+ export default function NotFoundPageFullPage(): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Paragraph from '../../components/paragraph';
4
+ import Button from '../../components/button';
5
+ import { Center, Cluster, Stack } from '../../components/layout';
6
+ export default function NotFoundPageFullPage() {
7
+ return (<Center fill>
8
+ <Stack gap="medium">
9
+ <Heading level={1} size="h5">Page not found</Heading>
10
+ <Paragraph tone="secondary" measure="none">The link may be wrong, or the page was moved or removed.</Paragraph>
11
+ </Stack>
12
+ <Cluster>
13
+ <Button size="medium" type="primary" state="enabled" label="Go Home" href="/"/>
14
+ </Cluster>
15
+ </Center>);
16
+ }
@@ -0,0 +1 @@
1
+ export default function NotFoundPageInShell(): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import Image from '../../components/image';
3
+ import TabsContainer from '../../components/tabsContainer';
4
+ import Tab from '../../components/tab';
5
+ import Surface from '../../components/surface';
6
+ import Heading from '../../components/heading';
7
+ import Paragraph from '../../components/paragraph';
8
+ import Button from '../../components/button';
9
+ import { Cluster, Stack } from '../../components/layout';
10
+ // The product's mark. A real app passes its own file.
11
+ 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";
12
+ // A real app passes the router from its framework, such as Next's useRouter().
13
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
14
+ export default function NotFoundPageInShell() {
15
+ return (<Stack gap="large">
16
+ <Cluster gap="large">
17
+ <Image src={productMark} alt="Acme" width={32} height={32}/>
18
+ <TabsContainer>
19
+ <Tab label="Home" isSelected={false} href="/" router={router} onClickTab={function () { }}/>
20
+ <Tab label="Projects" isSelected href="/projects" router={router} onClickTab={function () { }}/>
21
+ <Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={function () { }}/>
22
+ </TabsContainer>
23
+ </Cluster>
24
+ <Surface minHeight="tall" align="center">
25
+ <Stack gap="xlarge">
26
+ <Stack gap="medium">
27
+ <Heading level={1} size="h5">Page not found</Heading>
28
+ <Paragraph tone="secondary" measure="none">The link may be wrong, or the page was moved or removed.</Paragraph>
29
+ </Stack>
30
+ <Cluster>
31
+ <Button size="medium" type="primary" state="enabled" label="Go Home" href="/"/>
32
+ </Cluster>
33
+ </Stack>
34
+ </Surface>
35
+ </Stack>);
36
+ }
@@ -0,0 +1,98 @@
1
+ # Page not found
2
+
3
+ A person opens a link to a page that does not exist.
4
+
5
+ **Not built yet:** Commentify's page not found is one line of bare text, 'Page not found.', with no way home. Scindo on the web shows '404' as its heading, then bare text and a text link home. jinhwankim.com has no heading: it puts '404:' at the start of its `EmptyBox` text and labels its Button 'Go to Home'.
6
+
7
+ ## Do
8
+
9
+ - Say 'Page not found' in a `Heading` with `level={1}`.
10
+ - Add one line on what may have happened: 'The link may be wrong, or the page was moved or removed.'
11
+ - Offer one Button home: 'Go Home'.
12
+
13
+ ## Don't
14
+
15
+ - Do not make '404' the heading.
16
+ - Do not show a line of text with no way home.
17
+ - Do not blame the person for the link.
18
+
19
+ ## Option: Full page
20
+
21
+ Use when: The address is outside the app shell, so nothing else can show.
22
+
23
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Stack`
24
+
25
+ ```tsx
26
+ 'use client';
27
+ import Heading from 'oneslash-design-system/components/heading';
28
+ import Paragraph from 'oneslash-design-system/components/paragraph';
29
+ import Button from 'oneslash-design-system/components/button';
30
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
31
+
32
+ export default function NotFoundPageFullPage() {
33
+ return (
34
+ <Center fill>
35
+ <Stack gap="medium">
36
+ <Heading level={1} size="h5">Page not found</Heading>
37
+ <Paragraph tone="secondary" measure="none">The link may be wrong, or the page was moved or removed.</Paragraph>
38
+ </Stack>
39
+ <Cluster>
40
+ <Button size="medium" type="primary" state="enabled" label="Go Home" href="/" />
41
+ </Cluster>
42
+ </Center>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ## Option: Inside the shell
48
+
49
+ Use when: The address is inside the app and the navigation still works.
50
+
51
+ Uses: `Button`, `Cluster`, `Heading`, `Image`, `Paragraph`, `Stack`, `Surface`, `Tab`, `TabsContainer`
52
+
53
+ ```tsx
54
+ 'use client';
55
+ import Image from 'oneslash-design-system/components/image';
56
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
57
+ import Tab from 'oneslash-design-system/components/tab';
58
+ import Surface from 'oneslash-design-system/components/surface';
59
+ import Heading from 'oneslash-design-system/components/heading';
60
+ import Paragraph from 'oneslash-design-system/components/paragraph';
61
+ import Button from 'oneslash-design-system/components/button';
62
+ import { Cluster, Stack } from 'oneslash-design-system/components/layout';
63
+
64
+ // The product's mark. A real app passes its own file.
65
+ const productMark =
66
+ "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";
67
+
68
+ // A real app passes the router from its framework, such as Next's useRouter().
69
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
70
+
71
+ export default function NotFoundPageInShell() {
72
+ return (
73
+ <Stack gap="large">
74
+ <Cluster gap="large">
75
+ <Image src={productMark} alt="Acme" width={32} height={32} />
76
+ <TabsContainer>
77
+ <Tab label="Home" isSelected={false} href="/" router={router} onClickTab={() => {}} />
78
+ <Tab label="Projects" isSelected href="/projects" router={router} onClickTab={() => {}} />
79
+ <Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={() => {}} />
80
+ </TabsContainer>
81
+ </Cluster>
82
+ <Surface minHeight="tall" align="center">
83
+ <Stack gap="xlarge">
84
+ <Stack gap="medium">
85
+ <Heading level={1} size="h5">Page not found</Heading>
86
+ <Paragraph tone="secondary" measure="none">The link may be wrong, or the page was moved or removed.</Paragraph>
87
+ </Stack>
88
+ <Cluster>
89
+ <Button size="medium" type="primary" state="enabled" label="Go Home" href="/" />
90
+ </Cluster>
91
+ </Stack>
92
+ </Surface>
93
+ </Stack>
94
+ );
95
+ }
96
+ ```
97
+
98
+ Seen in: Commentify, Scindo, jinhwankim.com.
@@ -0,0 +1 @@
1
+ export default function OAuthConsentSimple(): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import UserImage from '../../components/userImage';
7
+ import Alert from '../../components/alert';
8
+ import Button from '../../components/button';
9
+ import LoadingScreen from '../../components/loadingScreen';
10
+ import { Center, Cluster, Grid, Stack } from '../../components/layout';
11
+ // The product's mark. A real app passes its own file.
12
+ 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";
13
+ // A real app passes the router from its framework, such as Next's useRouter().
14
+ // The app's name and cli.acme.dev come from the server's record of the registered app, never from the link.
15
+ // Going back to another site is a full page load, such as window.location.assign() in a real app.
16
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
17
+ export default function OAuthConsentSimple() {
18
+ var _a = useState(false), allowing = _a[0], setAllowing = _a[1];
19
+ var _b = useState(false), handingBack = _b[0], setHandingBack = _b[1];
20
+ var _c = useState(''), error = _c[0], setError = _c[1];
21
+ var timer = useRef();
22
+ // Stops the request if the example goes away before it ends.
23
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
24
+ function handleAllow() {
25
+ if (allowing)
26
+ return;
27
+ setError('');
28
+ setAllowing(true);
29
+ // Stands in for the request to the server.
30
+ // A failed request calls setError with one sentence instead, such as 'Acme CLI was not connected. Try again.'
31
+ timer.current = setTimeout(function () {
32
+ setAllowing(false);
33
+ setHandingBack(true);
34
+ // A real app also returns the `state` value the app sent, so the app can match the answer to its request.
35
+ router.push('https://cli.acme.dev/callback');
36
+ }, 1200);
37
+ }
38
+ // The app hears that the person said no, and nothing is shared.
39
+ // A real app also returns the `state` value the app sent.
40
+ function handleCancel() {
41
+ setHandingBack(true);
42
+ router.push('https://cli.acme.dev/callback?error=access_denied');
43
+ }
44
+ // Shown while the browser goes back to the app, the same as a named step in 'Login check loading'.
45
+ if (handingBack) {
46
+ return (<Center fill>
47
+ <LoadingScreen label="Going back to Acme CLI…"/>
48
+ </Center>);
49
+ }
50
+ return (<Center fill>
51
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
52
+ <Stack gap="medium">
53
+ <Heading level={1} size="h5">Acme CLI wants to connect to Acme</Heading>
54
+ <Paragraph tone="secondary" measure="none">It will be able to read your projects and tasks, and create tasks as you. You can remove its access at any time in Settings, under Connected apps.</Paragraph>
55
+ </Stack>
56
+ {/* The account that gives the access, so the person can tell it is the right one. */}
57
+ <Stack gap="small" align="start">
58
+ <Cluster gap="small">
59
+ <UserImage userHandle="Ada Lovelace"/>
60
+ <Paragraph size="body2" measure="none">ada@example.com</Paragraph>
61
+ </Cluster>
62
+ <Button size="small" type="textOnly" state={allowing ? 'disabled' : 'enabled'} label="Not You? Switch Account" onClickButton={function () { return router.push('/login?next=%2Foauth%2Fauthorize'); }}/>
63
+ </Stack>
64
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
65
+ <Stack gap="medium">
66
+ <Grid columns={2} gap="medium">
67
+ <Button size="medium" type="secondary" state={allowing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel}/>
68
+ <Button size="medium" type="primary" state="enabled" label="Allow" loading={allowing} onClickButton={handleAllow}/>
69
+ </Grid>
70
+ <Paragraph tone="secondary" size="caption" measure="none">You will go back to cli.acme.dev.</Paragraph>
71
+ </Stack>
72
+ </Center>);
73
+ }
@@ -0,0 +1 @@
1
+ export default function OAuthConsentWithScope(): import("react").JSX.Element;
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import UserImage from '../../components/userImage';
7
+ import Alert from '../../components/alert';
8
+ import Select from '../../components/select';
9
+ import Checkbox from '../../components/checkBox';
10
+ import Button from '../../components/button';
11
+ import LoadingScreen from '../../components/loadingScreen';
12
+ import { Center, Cluster, Grid, Stack } 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
+ // The app's name and cli.acme.dev come from the server's record of the registered app, never from the link.
17
+ // Going back to another site is a full page load, such as window.location.assign() in a real app.
18
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
19
+ // The workspaces the person belongs to.
20
+ var workspaces = [
21
+ { value: 'design', label: 'Acme Design' },
22
+ { value: 'marketing', label: 'Acme Marketing' },
23
+ ];
24
+ export default function OAuthConsentWithScope() {
25
+ var _a = useState('design'), workspace = _a[0], setWorkspace = _a[1];
26
+ // The wider access is off until the person turns it on.
27
+ var _b = useState(false), allWorkspaces = _b[0], setAllWorkspaces = _b[1];
28
+ var _c = useState(false), allowing = _c[0], setAllowing = _c[1];
29
+ var _d = useState(false), handingBack = _d[0], setHandingBack = _d[1];
30
+ var _e = useState(''), error = _e[0], setError = _e[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 handleAllow() {
35
+ if (allowing)
36
+ return;
37
+ setError('');
38
+ setAllowing(true);
39
+ // Stands in for the request to the server.
40
+ // A failed request calls setError with one sentence instead, such as 'Acme CLI was not connected. Try again.'
41
+ timer.current = setTimeout(function () {
42
+ setAllowing(false);
43
+ setHandingBack(true);
44
+ // A real app also returns the `state` value the app sent, so the app can match the answer to its request.
45
+ router.push('https://cli.acme.dev/callback');
46
+ }, 1200);
47
+ }
48
+ // The app hears that the person said no, and nothing is shared.
49
+ // A real app also returns the `state` value the app sent.
50
+ function handleCancel() {
51
+ setHandingBack(true);
52
+ router.push('https://cli.acme.dev/callback?error=access_denied');
53
+ }
54
+ // Shown while the browser goes back to the app, the same as a named step in 'Login check loading'.
55
+ if (handingBack) {
56
+ return (<Center fill>
57
+ <LoadingScreen label="Going back to Acme CLI…"/>
58
+ </Center>);
59
+ }
60
+ return (<Center fill>
61
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
62
+ <Stack gap="medium">
63
+ <Heading level={1} size="h5">Acme CLI wants to connect to Acme</Heading>
64
+ <Paragraph tone="secondary" measure="none">It will be able to read the projects and tasks you can see, and create tasks as you, in the workspaces you allow below. You can remove its access at any time in Settings, under Connected apps.</Paragraph>
65
+ </Stack>
66
+ {/* The account that gives the access, so the person can tell it is the right one. */}
67
+ <Stack gap="small" align="start">
68
+ <Cluster gap="small">
69
+ <UserImage userHandle="Ada Lovelace"/>
70
+ <Paragraph size="body2" measure="none">ada@example.com</Paragraph>
71
+ </Cluster>
72
+ <Button size="small" type="textOnly" state={allowing ? 'disabled' : 'enabled'} label="Not You? Switch Account" onClickButton={function () { return router.push('/login?next=%2Foauth%2Fauthorize'); }}/>
73
+ </Stack>
74
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
75
+ <Stack gap="small">
76
+ {/* The line above names the field on screen, and `aria-label` names it for a screen reader. */}
77
+ <Paragraph tone="secondary" size="body2" measure="none">Workspace</Paragraph>
78
+ <Select aria-label="Workspace" value={workspace} options={workspaces} disabled={allowing} onChange={function (v) { return setWorkspace(typeof v === 'string' ? v : v[0]); }}/>
79
+ </Stack>
80
+ <Checkbox label="Also allow my other workspaces" secondLabel="It can then do the same in every workspace you belong to. It still sees only what you can see." checked={allWorkspaces} disabled={allowing} onChange={setAllWorkspaces}/>
81
+ <Stack gap="medium">
82
+ <Grid columns={2} gap="medium">
83
+ <Button size="medium" type="secondary" state={allowing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel}/>
84
+ <Button size="medium" type="primary" state="enabled" label="Allow" loading={allowing} onClickButton={handleAllow}/>
85
+ </Grid>
86
+ <Paragraph tone="secondary" size="caption" measure="none">You will go back to cli.acme.dev.</Paragraph>
87
+ </Stack>
88
+ </Center>);
89
+ }