oneslash-design-system 2.14.2 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/DESIGN.md +138 -1
- package/dist/cases/accept-invite/signed-in.d.ts +1 -0
- package/dist/cases/accept-invite/signed-in.jsx +57 -0
- package/dist/cases/accept-invite/signed-out.d.ts +1 -0
- package/dist/cases/accept-invite/signed-out.jsx +33 -0
- package/dist/cases/accept-invite.md +161 -0
- package/dist/cases/agent-asks-before-risky-action.md +29 -0
- package/dist/cases/agent-cancels-when-unanswered.md +27 -0
- package/dist/cases/agent-refuses-clearly.md +31 -0
- package/dist/cases/agent-says-what-it-is.md +29 -0
- package/dist/cases/agent-shows-progress.md +30 -0
- package/dist/cases/agent-shows-sources.md +26 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
- package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
- package/dist/cases/auth-gate-loading.md +70 -0
- package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
- package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
- package/dist/cases/check-your-email/page.d.ts +1 -0
- package/dist/cases/check-your-email/page.jsx +49 -0
- package/dist/cases/check-your-email.md +184 -0
- package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
- package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
- package/dist/cases/confirm-destructive-action.md +211 -0
- package/dist/cases/confirm-dialogs.md +36 -0
- package/dist/cases/create-modal/quick.d.ts +1 -0
- package/dist/cases/create-modal/quick.jsx +80 -0
- package/dist/cases/create-modal/with-settings.d.ts +1 -0
- package/dist/cases/create-modal/with-settings.jsx +99 -0
- package/dist/cases/create-modal.md +244 -0
- package/dist/cases/device-login/popup.d.ts +1 -0
- package/dist/cases/device-login/popup.jsx +14 -0
- package/dist/cases/device-login/provider-first.d.ts +1 -0
- package/dist/cases/device-login/provider-first.jsx +98 -0
- package/dist/cases/device-login.md +171 -0
- package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
- package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
- package/dist/cases/email-confirmed/page.d.ts +1 -0
- package/dist/cases/email-confirmed/page.jsx +21 -0
- package/dist/cases/email-confirmed.md +151 -0
- package/dist/cases/empty-list/region.d.ts +1 -0
- package/dist/cases/empty-list/region.jsx +13 -0
- package/dist/cases/empty-list/section.d.ts +1 -0
- package/dist/cases/empty-list/section.jsx +17 -0
- package/dist/cases/empty-list.md +77 -0
- package/dist/cases/empty-lists.md +35 -0
- package/dist/cases/empty-not-set-up/action.d.ts +1 -0
- package/dist/cases/empty-not-set-up/action.jsx +16 -0
- package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
- package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
- package/dist/cases/empty-not-set-up.md +88 -0
- package/dist/cases/empty-search/clear-search.d.ts +1 -0
- package/dist/cases/empty-search/clear-search.jsx +29 -0
- package/dist/cases/empty-search.md +77 -0
- package/dist/cases/error-page/full-page.d.ts +1 -0
- package/dist/cases/error-page/full-page.jsx +19 -0
- package/dist/cases/error-page/in-shell.d.ts +1 -0
- package/dist/cases/error-page/in-shell.jsx +39 -0
- package/dist/cases/error-page.md +107 -0
- package/dist/cases/feedback-form/modal.d.ts +1 -0
- package/dist/cases/feedback-form/modal.jsx +89 -0
- package/dist/cases/feedback-form.md +139 -0
- package/dist/cases/forgot-password/in-place.d.ts +1 -0
- package/dist/cases/forgot-password/in-place.jsx +155 -0
- package/dist/cases/forgot-password/own-page.d.ts +1 -0
- package/dist/cases/forgot-password/own-page.jsx +99 -0
- package/dist/cases/forgot-password.md +328 -0
- package/dist/cases/form-errors.md +32 -0
- package/dist/cases/import-checklist/modal.d.ts +1 -0
- package/dist/cases/import-checklist/modal.jsx +125 -0
- package/dist/cases/import-checklist.md +188 -0
- package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
- package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
- package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
- package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
- package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
- package/dist/cases/inline-form-feedback/toast.jsx +66 -0
- package/dist/cases/inline-form-feedback.md +237 -0
- package/dist/cases/invite-member/by-email.d.ts +1 -0
- package/dist/cases/invite-member/by-email.jsx +98 -0
- package/dist/cases/invite-member/by-link.d.ts +1 -0
- package/dist/cases/invite-member/by-link.jsx +122 -0
- package/dist/cases/invite-member.md +321 -0
- package/dist/cases/load-failure/inline.d.ts +1 -0
- package/dist/cases/load-failure/inline.jsx +52 -0
- package/dist/cases/load-failure/region.d.ts +1 -0
- package/dist/cases/load-failure/region.jsx +34 -0
- package/dist/cases/load-failure.md +155 -0
- package/dist/cases/log-out-confirm/modal.d.ts +1 -0
- package/dist/cases/log-out-confirm/modal.jsx +57 -0
- package/dist/cases/log-out-confirm.md +106 -0
- package/dist/cases/login-page/centered.d.ts +1 -0
- package/dist/cases/login-page/centered.jsx +72 -0
- package/dist/cases/login-page/email-only.d.ts +1 -0
- package/dist/cases/login-page/email-only.jsx +59 -0
- package/dist/cases/login-page/provider-first.d.ts +1 -0
- package/dist/cases/login-page/provider-first.jsx +66 -0
- package/dist/cases/login-page/split.d.ts +1 -0
- package/dist/cases/login-page/split.jsx +79 -0
- package/dist/cases/login-page.md +373 -0
- package/dist/cases/not-found-page/full-page.d.ts +1 -0
- package/dist/cases/not-found-page/full-page.jsx +16 -0
- package/dist/cases/not-found-page/in-shell.d.ts +1 -0
- package/dist/cases/not-found-page/in-shell.jsx +36 -0
- package/dist/cases/not-found-page.md +98 -0
- package/dist/cases/oauth-consent/simple.d.ts +1 -0
- package/dist/cases/oauth-consent/simple.jsx +73 -0
- package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
- package/dist/cases/oauth-consent/with-scope.jsx +89 -0
- package/dist/cases/oauth-consent.md +233 -0
- package/dist/cases/rename/inline.d.ts +1 -0
- package/dist/cases/rename/inline.jsx +58 -0
- package/dist/cases/rename/modal.d.ts +1 -0
- package/dist/cases/rename/modal.jsx +70 -0
- package/dist/cases/rename.md +205 -0
- package/dist/cases/route-loading/full-screen.d.ts +1 -0
- package/dist/cases/route-loading/full-screen.jsx +8 -0
- package/dist/cases/route-loading/region.d.ts +1 -0
- package/dist/cases/route-loading/region.jsx +26 -0
- package/dist/cases/route-loading.md +84 -0
- package/dist/cases/set-new-password/form.d.ts +1 -0
- package/dist/cases/set-new-password/form.jsx +130 -0
- package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
- package/dist/cases/set-new-password/invalid-link.jsx +50 -0
- package/dist/cases/set-new-password.md +247 -0
- package/dist/cases/sign-up-page/centered.d.ts +1 -0
- package/dist/cases/sign-up-page/centered.jsx +124 -0
- package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
- package/dist/cases/sign-up-page/provider-first.jsx +124 -0
- package/dist/cases/sign-up-page/split.d.ts +1 -0
- package/dist/cases/sign-up-page/split.jsx +134 -0
- package/dist/cases/sign-up-page.md +478 -0
- package/dist/cases/success-feedback.md +35 -0
- package/dist/cases/type-to-confirm/inline.d.ts +1 -0
- package/dist/cases/type-to-confirm/inline.jsx +69 -0
- package/dist/cases/type-to-confirm/modal.d.ts +1 -0
- package/dist/cases/type-to-confirm/modal.jsx +73 -0
- package/dist/cases/type-to-confirm.md +222 -0
- package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
- package/dist/cases/unsaved-changes-guard.md +239 -0
- package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
- package/dist/cases/upgrade-prompt/inline.jsx +52 -0
- package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
- package/dist/cases/upgrade-prompt/modal.jsx +43 -0
- package/dist/cases/upgrade-prompt.md +174 -0
- package/dist/cases.json +2073 -0
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/brandIcon.d.ts +12 -0
- package/dist/components/brandIcon.jsx +24 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/form.d.ts +11 -0
- package/dist/components/form.jsx +22 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/image.d.ts +14 -0
- package/dist/components/image.jsx +6 -0
- package/dist/components/layout.d.ts +18 -1
- package/dist/components/layout.jsx +16 -0
- package/dist/components/line.d.ts +3 -1
- package/dist/components/line.jsx +8 -1
- package/dist/components/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- package/dist/components/radioGroup.d.ts +2 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- package/dist/components/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +11 -5
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/tooltip.jsx +3 -1
- package/dist/designTokens.d.ts +1 -0
- package/dist/designTokens.js +1 -0
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.js +6 -0
- package/dist/internal/modal.d.ts +2 -0
- package/dist/internal/modal.js +21 -0
- package/dist/internal/toaster.d.ts +19 -0
- package/dist/internal/toaster.js +50 -0
- package/dist/native-mapping.json +23 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- package/dist/stories/BrandIcon.stories.d.ts +9 -0
- package/dist/stories/BrandIcon.stories.jsx +19 -0
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +116 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/Form.stories.d.ts +6 -0
- package/dist/stories/Form.stories.jsx +26 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/Image.stories.d.ts +7 -0
- package/dist/stories/Image.stories.jsx +18 -0
- package/dist/stories/Line.stories.d.ts +1 -0
- package/dist/stories/Line.stories.jsx +12 -0
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- package/dist/stories/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +36 -0
- package/dist/stories/PageComponents.stories.d.ts +2 -0
- package/dist/stories/PageComponents.stories.jsx +15 -1
- package/dist/stories/RadioGroup.stories.d.ts +1 -0
- package/dist/stories/RadioGroup.stories.jsx +14 -0
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -0
- package/dist/stories/TabsContainer.stories.d.ts +1 -0
- package/dist/stories/TabsContainer.stories.jsx +12 -0
- package/dist/stories/TextField.stories.d.ts +2 -0
- package/dist/stories/TextField.stories.jsx +22 -0
- package/dist/stories/Toaster.stories.d.ts +6 -0
- package/dist/stories/Toaster.stories.jsx +29 -0
- package/dist/tailwind-preset-auto.js +2 -1
- package/dist/tailwind-preset.js +2 -1
- package/dist/theme-auto.css +1 -0
- package/dist/theme.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/tokens.json +7 -0
- package/package.json +4 -2
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# Login page
|
|
2
|
+
|
|
3
|
+
A person who already has an account opens the product and is not logged in.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Show a problem with one field under that field.
|
|
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
|
+
- Name the provider on its button: 'Continue with Google'.
|
|
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.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not clear the email field after a failed attempt.
|
|
19
|
+
- Do not show sign-up fields on the login page; link or tab to sign-up.
|
|
20
|
+
- Do not replace the form with a spinner while logging in.
|
|
21
|
+
- Do not say which of the email or the password was wrong.
|
|
22
|
+
|
|
23
|
+
## Option: Centered column
|
|
24
|
+
|
|
25
|
+
Use when: The product has one way in, and most people log in with email and a password.
|
|
26
|
+
|
|
27
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Image`, `Line`, `Tab`, `TabsContainer`, `TextField`
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
'use client';
|
|
31
|
+
import { useEffect, useRef, useState } from 'react';
|
|
32
|
+
import Image from 'oneslash-design-system/components/image';
|
|
33
|
+
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
34
|
+
import Tab from 'oneslash-design-system/components/tab';
|
|
35
|
+
import Form from 'oneslash-design-system/components/form';
|
|
36
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
37
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
38
|
+
import Button from 'oneslash-design-system/components/button';
|
|
39
|
+
import Line from 'oneslash-design-system/components/line';
|
|
40
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
41
|
+
import { Center } from 'oneslash-design-system/components/layout';
|
|
42
|
+
|
|
43
|
+
// The product's mark. A real app passes its own file.
|
|
44
|
+
const productMark =
|
|
45
|
+
"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";
|
|
46
|
+
|
|
47
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
48
|
+
const router = { push: (url: string) => console.info(`Go to ${url}`) };
|
|
49
|
+
|
|
50
|
+
// A small check: some text, an @, then some text.
|
|
51
|
+
function looksLikeEmail(value: string) {
|
|
52
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default function LoginCentered() {
|
|
56
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
57
|
+
const [password, setPassword] = useState('');
|
|
58
|
+
const [error, setError] = useState('');
|
|
59
|
+
const [emailError, setEmailError] = useState('');
|
|
60
|
+
const [passwordError, setPasswordError] = useState('');
|
|
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), []);
|
|
66
|
+
|
|
67
|
+
function handleSubmit() {
|
|
68
|
+
if (loading) return;
|
|
69
|
+
setError('');
|
|
70
|
+
setEmailError('');
|
|
71
|
+
setPasswordError('');
|
|
72
|
+
if (!email.trim()) {
|
|
73
|
+
setEmailError('Enter your email.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!looksLikeEmail(email.trim())) {
|
|
77
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!password) {
|
|
81
|
+
setPasswordError('Enter your password.');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setLoading(true);
|
|
85
|
+
// Stands in for the request to the server.
|
|
86
|
+
timer.current = setTimeout(() => {
|
|
87
|
+
setLoading(false);
|
|
88
|
+
setError('That email and password do not match.');
|
|
89
|
+
}, 1200);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Center fill>
|
|
94
|
+
<Image src={productMark} alt="Acme" width={40} height={40} />
|
|
95
|
+
<TabsContainer fill>
|
|
96
|
+
<Tab label="Log In" isSelected onClickTab={() => {}} />
|
|
97
|
+
<Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={() => {}} />
|
|
98
|
+
</TabsContainer>
|
|
99
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
100
|
+
{error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
|
|
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(''); }} />
|
|
103
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
|
|
104
|
+
<Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
|
|
105
|
+
</Form>
|
|
106
|
+
<Line label="or" />
|
|
107
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
108
|
+
</Center>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Option: Brand beside the form
|
|
114
|
+
|
|
115
|
+
Use when: First-time visitors land here and need one line on what the product is.
|
|
116
|
+
|
|
117
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Image`, `Line`, `Link`, `Paragraph`, `Split`, `Stack`, `TextField`
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
'use client';
|
|
121
|
+
import { useEffect, useRef, useState } from 'react';
|
|
122
|
+
import Image from 'oneslash-design-system/components/image';
|
|
123
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
124
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
125
|
+
import Form from 'oneslash-design-system/components/form';
|
|
126
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
127
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
128
|
+
import Button from 'oneslash-design-system/components/button';
|
|
129
|
+
import Line from 'oneslash-design-system/components/line';
|
|
130
|
+
import Link from 'oneslash-design-system/components/link';
|
|
131
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
132
|
+
import { Center, Cluster, Split, Stack } from 'oneslash-design-system/components/layout';
|
|
133
|
+
|
|
134
|
+
// The product's mark. A real app passes its own file.
|
|
135
|
+
const productMark =
|
|
136
|
+
"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";
|
|
137
|
+
|
|
138
|
+
// A small check: some text, an @, then some text.
|
|
139
|
+
function looksLikeEmail(value: string) {
|
|
140
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export default function LoginSplit() {
|
|
144
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
145
|
+
const [password, setPassword] = useState('');
|
|
146
|
+
const [error, setError] = useState('');
|
|
147
|
+
const [emailError, setEmailError] = useState('');
|
|
148
|
+
const [passwordError, setPasswordError] = useState('');
|
|
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), []);
|
|
154
|
+
|
|
155
|
+
function handleSubmit() {
|
|
156
|
+
if (loading) return;
|
|
157
|
+
setError('');
|
|
158
|
+
setEmailError('');
|
|
159
|
+
setPasswordError('');
|
|
160
|
+
if (!email.trim()) {
|
|
161
|
+
setEmailError('Enter your email.');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (!looksLikeEmail(email.trim())) {
|
|
165
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!password) {
|
|
169
|
+
setPasswordError('Enter your password.');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setLoading(true);
|
|
173
|
+
// Stands in for the request to the server.
|
|
174
|
+
timer.current = setTimeout(() => {
|
|
175
|
+
setLoading(false);
|
|
176
|
+
setError('That email and password do not match.');
|
|
177
|
+
}, 1200);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<Split
|
|
182
|
+
fill
|
|
183
|
+
aside={
|
|
184
|
+
<Stack gap="large">
|
|
185
|
+
<Image src={productMark} alt="Acme" width={40} height={40} />
|
|
186
|
+
<Heading level={2} size="h4">Plan the week with your whole team.</Heading>
|
|
187
|
+
<Paragraph tone="secondary" measure="lede">
|
|
188
|
+
Acme keeps tasks, notes and decisions in one place.
|
|
189
|
+
</Paragraph>
|
|
190
|
+
</Stack>
|
|
191
|
+
}
|
|
192
|
+
>
|
|
193
|
+
<Center fill>
|
|
194
|
+
<Heading level={1} size="h5">Log in to Acme</Heading>
|
|
195
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
196
|
+
{error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
|
|
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(''); }} />
|
|
199
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
|
|
200
|
+
<Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
|
|
201
|
+
</Form>
|
|
202
|
+
<Line label="or" />
|
|
203
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
204
|
+
<Cluster gap="small">
|
|
205
|
+
<Paragraph tone="secondary" size="body2" measure="none">New here?</Paragraph>
|
|
206
|
+
<Link href="/sign-up" size="body2">Sign Up</Link>
|
|
207
|
+
</Cluster>
|
|
208
|
+
</Center>
|
|
209
|
+
</Split>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Option: Provider first
|
|
215
|
+
|
|
216
|
+
Use when: Most people log in with Google, GitHub or Apple; email is the fallback.
|
|
217
|
+
|
|
218
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Line`, `Stack`, `TextField`
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
'use client';
|
|
222
|
+
import { useEffect, useRef, useState } from 'react';
|
|
223
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
224
|
+
import Form from 'oneslash-design-system/components/form';
|
|
225
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
226
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
227
|
+
import Button from 'oneslash-design-system/components/button';
|
|
228
|
+
import Line from 'oneslash-design-system/components/line';
|
|
229
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
230
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
231
|
+
|
|
232
|
+
// A small check: some text, an @, then some text.
|
|
233
|
+
function looksLikeEmail(value: string) {
|
|
234
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default function LoginProviderFirst() {
|
|
238
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
239
|
+
const [password, setPassword] = useState('');
|
|
240
|
+
const [error, setError] = useState('');
|
|
241
|
+
const [emailError, setEmailError] = useState('');
|
|
242
|
+
const [passwordError, setPasswordError] = useState('');
|
|
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), []);
|
|
248
|
+
|
|
249
|
+
function handleSubmit() {
|
|
250
|
+
if (loading) return;
|
|
251
|
+
setError('');
|
|
252
|
+
setEmailError('');
|
|
253
|
+
setPasswordError('');
|
|
254
|
+
if (!email.trim()) {
|
|
255
|
+
setEmailError('Enter your email.');
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (!looksLikeEmail(email.trim())) {
|
|
259
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (!password) {
|
|
263
|
+
setPasswordError('Enter your password.');
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setLoading(true);
|
|
267
|
+
// Stands in for the request to the server.
|
|
268
|
+
timer.current = setTimeout(() => {
|
|
269
|
+
setLoading(false);
|
|
270
|
+
setError('That email and password do not match.');
|
|
271
|
+
}, 1200);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<Center fill>
|
|
276
|
+
<Heading level={1} size="h5">Log in to Acme</Heading>
|
|
277
|
+
<Stack gap="medium">
|
|
278
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
279
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with GitHub" decoIcon={<BrandIcon name="github" />} />
|
|
280
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Apple" decoIcon={<BrandIcon name="apple" />} />
|
|
281
|
+
</Stack>
|
|
282
|
+
<Line label="or" />
|
|
283
|
+
<Form aria-label="Log in with email" onSubmit={handleSubmit}>
|
|
284
|
+
{error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
|
|
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?" />
|
|
289
|
+
</Form>
|
|
290
|
+
</Center>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Option: Email only
|
|
296
|
+
|
|
297
|
+
Use when: An internal tool with no passwords: the person gets a login link by email.
|
|
298
|
+
|
|
299
|
+
Uses: `Alert`, `Button`, `Center`, `Form`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
|
|
300
|
+
|
|
301
|
+
```tsx
|
|
302
|
+
'use client';
|
|
303
|
+
import { useEffect, useRef, useState } from 'react';
|
|
304
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
305
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
306
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
307
|
+
import Form from 'oneslash-design-system/components/form';
|
|
308
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
309
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
310
|
+
import Button from 'oneslash-design-system/components/button';
|
|
311
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
312
|
+
|
|
313
|
+
// A small check: some text, an @, then some text.
|
|
314
|
+
function looksLikeEmail(value: string) {
|
|
315
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export default function LoginEmailOnly() {
|
|
319
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
320
|
+
const [sentTo, setSentTo] = useState('');
|
|
321
|
+
const [emailError, setEmailError] = useState('');
|
|
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), []);
|
|
327
|
+
|
|
328
|
+
function handleSubmit() {
|
|
329
|
+
if (loading) return;
|
|
330
|
+
setEmailError('');
|
|
331
|
+
setSentTo('');
|
|
332
|
+
if (!email.trim()) {
|
|
333
|
+
setEmailError('Enter your email.');
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (!looksLikeEmail(email.trim())) {
|
|
337
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
setLoading(true);
|
|
341
|
+
const address = email.trim();
|
|
342
|
+
// Stands in for the request to the server.
|
|
343
|
+
timer.current = setTimeout(() => {
|
|
344
|
+
setLoading(false);
|
|
345
|
+
setSentTo(address);
|
|
346
|
+
}, 1200);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return (
|
|
350
|
+
<Center fill>
|
|
351
|
+
<Surface padding="large">
|
|
352
|
+
<Stack gap="xlarge">
|
|
353
|
+
<Stack gap="small">
|
|
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>
|
|
356
|
+
</Stack>
|
|
357
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
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} />
|
|
361
|
+
</Form>
|
|
362
|
+
</Stack>
|
|
363
|
+
</Surface>
|
|
364
|
+
</Center>
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## Native
|
|
370
|
+
|
|
371
|
+
On Apple use `SignInWithAppleButton` for Apple, a grouped form for the fields, and system buttons.
|
|
372
|
+
|
|
373
|
+
Seen in: Commentify, Commentify admin, Scindo.
|
|
@@ -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;
|