oneslash-design-system 2.14.2 → 2.15.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 +10 -0
- package/dist/DESIGN.md +134 -1
- 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/login-page/centered.d.ts +1 -0
- package/dist/cases/login-page/centered.jsx +69 -0
- package/dist/cases/login-page/email-only.d.ts +1 -0
- package/dist/cases/login-page/email-only.jsx +56 -0
- package/dist/cases/login-page/provider-first.d.ts +1 -0
- package/dist/cases/login-page/provider-first.jsx +63 -0
- package/dist/cases/login-page/split.d.ts +1 -0
- package/dist/cases/login-page/split.jsx +76 -0
- package/dist/cases/login-page.md +356 -0
- package/dist/cases.json +256 -0
- package/dist/components/brandIcon.d.ts +12 -0
- package/dist/components/brandIcon.jsx +24 -0
- package/dist/components/form.d.ts +11 -0
- package/dist/components/form.jsx +22 -0
- 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/tabsContainer.jsx +4 -2
- package/dist/components/tooltip.jsx +3 -1
- package/dist/designTokens.d.ts +1 -0
- package/dist/designTokens.js +1 -0
- package/dist/native-mapping.json +17 -1
- 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 +8 -0
- package/dist/stories/Cases.generated.stories.jsx +12 -0
- package/dist/stories/Form.stories.d.ts +6 -0
- package/dist/stories/Form.stories.jsx +26 -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/PageComponents.stories.d.ts +2 -0
- package/dist/stories/PageComponents.stories.jsx +15 -1
- 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,356 @@
|
|
|
1
|
+
# Login page
|
|
2
|
+
|
|
3
|
+
A person who already has an account opens the product and is not signed in.
|
|
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.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
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.
|
|
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.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not clear the email field after a failed attempt.
|
|
18
|
+
- 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 say which of the email or the password was wrong.
|
|
21
|
+
|
|
22
|
+
## Option: Centered column
|
|
23
|
+
|
|
24
|
+
Use when: The product has one way in, and most people sign in with email and a password.
|
|
25
|
+
|
|
26
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Image`, `Line`, `Tab`, `TabsContainer`, `TextField`
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
'use client';
|
|
30
|
+
import { useState } from 'react';
|
|
31
|
+
import Image from 'oneslash-design-system/components/image';
|
|
32
|
+
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
33
|
+
import Tab from 'oneslash-design-system/components/tab';
|
|
34
|
+
import Form from 'oneslash-design-system/components/form';
|
|
35
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
36
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
37
|
+
import Button from 'oneslash-design-system/components/button';
|
|
38
|
+
import Line from 'oneslash-design-system/components/line';
|
|
39
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
40
|
+
import { Center } from 'oneslash-design-system/components/layout';
|
|
41
|
+
|
|
42
|
+
// The product's mark. A real app passes its own file.
|
|
43
|
+
const productMark =
|
|
44
|
+
"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";
|
|
45
|
+
|
|
46
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
47
|
+
const router = { push: (url: string) => console.info(`Go to ${url}`) };
|
|
48
|
+
|
|
49
|
+
// A small check: some text, an @, then some text.
|
|
50
|
+
function looksLikeEmail(value: string) {
|
|
51
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default function LoginCentered() {
|
|
55
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
56
|
+
const [password, setPassword] = useState('');
|
|
57
|
+
const [error, setError] = useState('');
|
|
58
|
+
const [emailError, setEmailError] = useState('');
|
|
59
|
+
const [passwordError, setPasswordError] = useState('');
|
|
60
|
+
const [loading, setLoading] = useState(false);
|
|
61
|
+
|
|
62
|
+
function handleSubmit() {
|
|
63
|
+
if (loading) return;
|
|
64
|
+
setError('');
|
|
65
|
+
setEmailError('');
|
|
66
|
+
setPasswordError('');
|
|
67
|
+
if (!email.trim()) {
|
|
68
|
+
setEmailError('Enter your email.');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!looksLikeEmail(email.trim())) {
|
|
72
|
+
setEmailError('Enter a valid email address.');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!password) {
|
|
76
|
+
setPasswordError('Enter your password.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
setLoading(true);
|
|
80
|
+
// Stands in for the request to the server.
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
setLoading(false);
|
|
83
|
+
setError('That email and password do not match.');
|
|
84
|
+
}, 1200);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Center fill>
|
|
89
|
+
<Image src={productMark} alt="Acme" width={40} height={40} />
|
|
90
|
+
<TabsContainer>
|
|
91
|
+
<Tab label="Log In" isSelected onClickTab={() => {}} />
|
|
92
|
+
<Tab label="Sign Up" isSelected={false} href="/sign-up" router={router} onClickTab={() => {}} />
|
|
93
|
+
</TabsContainer>
|
|
94
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
95
|
+
{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(''); }} />
|
|
98
|
+
<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?" />
|
|
100
|
+
</Form>
|
|
101
|
+
<Line label="or" />
|
|
102
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
103
|
+
</Center>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Option: Brand beside the form
|
|
109
|
+
|
|
110
|
+
Use when: First-time visitors land here and need one line on what the product is.
|
|
111
|
+
|
|
112
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Image`, `Line`, `Link`, `Paragraph`, `Split`, `Stack`, `TextField`
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
'use client';
|
|
116
|
+
import { useState } from 'react';
|
|
117
|
+
import Image from 'oneslash-design-system/components/image';
|
|
118
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
119
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
120
|
+
import Form from 'oneslash-design-system/components/form';
|
|
121
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
122
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
123
|
+
import Button from 'oneslash-design-system/components/button';
|
|
124
|
+
import Line from 'oneslash-design-system/components/line';
|
|
125
|
+
import Link from 'oneslash-design-system/components/link';
|
|
126
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
127
|
+
import { Center, Cluster, Split, Stack } from 'oneslash-design-system/components/layout';
|
|
128
|
+
|
|
129
|
+
// The product's mark. A real app passes its own file.
|
|
130
|
+
const productMark =
|
|
131
|
+
"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";
|
|
132
|
+
|
|
133
|
+
// A small check: some text, an @, then some text.
|
|
134
|
+
function looksLikeEmail(value: string) {
|
|
135
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default function LoginSplit() {
|
|
139
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
140
|
+
const [password, setPassword] = useState('');
|
|
141
|
+
const [error, setError] = useState('');
|
|
142
|
+
const [emailError, setEmailError] = useState('');
|
|
143
|
+
const [passwordError, setPasswordError] = useState('');
|
|
144
|
+
const [loading, setLoading] = useState(false);
|
|
145
|
+
|
|
146
|
+
function handleSubmit() {
|
|
147
|
+
if (loading) return;
|
|
148
|
+
setError('');
|
|
149
|
+
setEmailError('');
|
|
150
|
+
setPasswordError('');
|
|
151
|
+
if (!email.trim()) {
|
|
152
|
+
setEmailError('Enter your email.');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!looksLikeEmail(email.trim())) {
|
|
156
|
+
setEmailError('Enter a valid email address.');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (!password) {
|
|
160
|
+
setPasswordError('Enter your password.');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
setLoading(true);
|
|
164
|
+
// Stands in for the request to the server.
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
setLoading(false);
|
|
167
|
+
setError('That email and password do not match.');
|
|
168
|
+
}, 1200);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Split
|
|
173
|
+
fill
|
|
174
|
+
aside={
|
|
175
|
+
<Stack gap="large">
|
|
176
|
+
<Image src={productMark} alt="Acme" width={40} height={40} />
|
|
177
|
+
<Heading level={2} size="h4">Plan the week with your whole team.</Heading>
|
|
178
|
+
<Paragraph tone="secondary" measure="lede">
|
|
179
|
+
Acme keeps tasks, notes and decisions in one place.
|
|
180
|
+
</Paragraph>
|
|
181
|
+
</Stack>
|
|
182
|
+
}
|
|
183
|
+
>
|
|
184
|
+
<Center fill>
|
|
185
|
+
<Heading level={2} size="h5">Log in to Acme</Heading>
|
|
186
|
+
<Form aria-label="Log in" onSubmit={handleSubmit}>
|
|
187
|
+
{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(''); }} />
|
|
190
|
+
<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?" />
|
|
192
|
+
</Form>
|
|
193
|
+
<Line label="or" />
|
|
194
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
195
|
+
<Cluster gap="small">
|
|
196
|
+
<Paragraph tone="secondary" size="body2" measure="none">New here?</Paragraph>
|
|
197
|
+
<Link href="/signup" size="body2">Create an account</Link>
|
|
198
|
+
</Cluster>
|
|
199
|
+
</Center>
|
|
200
|
+
</Split>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Option: Provider first
|
|
206
|
+
|
|
207
|
+
Use when: Most people sign in with Google, GitHub or Apple; email is the fallback.
|
|
208
|
+
|
|
209
|
+
Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Line`, `Stack`, `TextField`
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
'use client';
|
|
213
|
+
import { useState } from 'react';
|
|
214
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
215
|
+
import Form from 'oneslash-design-system/components/form';
|
|
216
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
217
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
218
|
+
import Button from 'oneslash-design-system/components/button';
|
|
219
|
+
import Line from 'oneslash-design-system/components/line';
|
|
220
|
+
import BrandIcon from 'oneslash-design-system/components/brandIcon';
|
|
221
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
222
|
+
|
|
223
|
+
// A small check: some text, an @, then some text.
|
|
224
|
+
function looksLikeEmail(value: string) {
|
|
225
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export default function LoginProviderFirst() {
|
|
229
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
230
|
+
const [password, setPassword] = useState('');
|
|
231
|
+
const [error, setError] = useState('');
|
|
232
|
+
const [emailError, setEmailError] = useState('');
|
|
233
|
+
const [passwordError, setPasswordError] = useState('');
|
|
234
|
+
const [loading, setLoading] = useState(false);
|
|
235
|
+
|
|
236
|
+
function handleSubmit() {
|
|
237
|
+
if (loading) return;
|
|
238
|
+
setError('');
|
|
239
|
+
setEmailError('');
|
|
240
|
+
setPasswordError('');
|
|
241
|
+
if (!email.trim()) {
|
|
242
|
+
setEmailError('Enter your email.');
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (!looksLikeEmail(email.trim())) {
|
|
246
|
+
setEmailError('Enter a valid email address.');
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (!password) {
|
|
250
|
+
setPasswordError('Enter your password.');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
setLoading(true);
|
|
254
|
+
// Stands in for the request to the server.
|
|
255
|
+
setTimeout(() => {
|
|
256
|
+
setLoading(false);
|
|
257
|
+
setError('That email and password do not match.');
|
|
258
|
+
}, 1200);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<Center fill>
|
|
263
|
+
<Heading level={2} size="h5">Sign in to Acme</Heading>
|
|
264
|
+
<Stack gap="medium">
|
|
265
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
|
|
266
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with GitHub" decoIcon={<BrandIcon name="github" />} />
|
|
267
|
+
<Button size="medium" type="secondary" state="enabled" label="Continue with Apple" decoIcon={<BrandIcon name="apple" />} />
|
|
268
|
+
</Stack>
|
|
269
|
+
<Line label="or" />
|
|
270
|
+
<Form aria-label="Sign in with email" onSubmit={handleSubmit}>
|
|
271
|
+
{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?" />
|
|
276
|
+
</Form>
|
|
277
|
+
</Center>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Option: Email only
|
|
283
|
+
|
|
284
|
+
Use when: An internal tool with no passwords: the person gets a sign-in link by email.
|
|
285
|
+
|
|
286
|
+
Uses: `Alert`, `Button`, `Center`, `Form`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
'use client';
|
|
290
|
+
import { useState } from 'react';
|
|
291
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
292
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
293
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
294
|
+
import Form from 'oneslash-design-system/components/form';
|
|
295
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
296
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
297
|
+
import Button from 'oneslash-design-system/components/button';
|
|
298
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
299
|
+
|
|
300
|
+
// A small check: some text, an @, then some text.
|
|
301
|
+
function looksLikeEmail(value: string) {
|
|
302
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export default function LoginEmailOnly() {
|
|
306
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
307
|
+
const [sentTo, setSentTo] = useState('');
|
|
308
|
+
const [emailError, setEmailError] = useState('');
|
|
309
|
+
const [loading, setLoading] = useState(false);
|
|
310
|
+
|
|
311
|
+
function handleSubmit() {
|
|
312
|
+
if (loading) return;
|
|
313
|
+
setEmailError('');
|
|
314
|
+
setSentTo('');
|
|
315
|
+
if (!email.trim()) {
|
|
316
|
+
setEmailError('Enter your email.');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (!looksLikeEmail(email.trim())) {
|
|
320
|
+
setEmailError('Enter a valid email address.');
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
setLoading(true);
|
|
324
|
+
const address = email.trim();
|
|
325
|
+
// Stands in for the request to the server.
|
|
326
|
+
setTimeout(() => {
|
|
327
|
+
setLoading(false);
|
|
328
|
+
setSentTo(address);
|
|
329
|
+
}, 1200);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return (
|
|
333
|
+
<Center fill>
|
|
334
|
+
<Surface padding="large">
|
|
335
|
+
<Stack gap="xlarge">
|
|
336
|
+
<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>
|
|
339
|
+
</Stack>
|
|
340
|
+
<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} />
|
|
344
|
+
</Form>
|
|
345
|
+
</Stack>
|
|
346
|
+
</Surface>
|
|
347
|
+
</Center>
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Native
|
|
353
|
+
|
|
354
|
+
On Apple use `SignInWithAppleButton` for Apple, a grouped form for the fields, and system buttons.
|
|
355
|
+
|
|
356
|
+
Seen in: Commentify, Commentify admin, Scindo.
|
package/dist/cases.json
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cases": [
|
|
3
|
+
{
|
|
4
|
+
"id": "agent-asks-before-risky-action",
|
|
5
|
+
"title": "An agent asks before a risky action",
|
|
6
|
+
"kind": "rule",
|
|
7
|
+
"level": "rule",
|
|
8
|
+
"area": "agent",
|
|
9
|
+
"situation": "The agent is about to do something that changes shared work or is hard to undo.",
|
|
10
|
+
"answer": "An action is risky when it changes shared work or is hard to undo. In a product that works with code, that includes opening or merging a pull request, deleting files, closing an issue and rolling back a release. Carrying out a plan of several changes is risky too. Before a risky action the agent stops and posts a card with the exact action: every step it will take, or the changes themselves, which the person can open. The agent does nothing until the person presses the approve button.",
|
|
11
|
+
"why": "A person can only approve what they can see, and an agent's mistake in shared work costs other people.",
|
|
12
|
+
"do": [
|
|
13
|
+
"List every step in the card, in the order the agent will do them.",
|
|
14
|
+
"Offer a way to see the full changes, such as a View Changes button, before the approve button is pressed.",
|
|
15
|
+
"Let the person edit the plan or cancel it, not only approve it.",
|
|
16
|
+
"Once decided, mark the card Approved or Cancelled and remove its buttons."
|
|
17
|
+
],
|
|
18
|
+
"dont": [
|
|
19
|
+
"Do not carry out a risky action before the person approves it.",
|
|
20
|
+
"Do not replace the steps or the changes with a one-line summary.",
|
|
21
|
+
"Do not let the agent write the label of an approve or merge button.",
|
|
22
|
+
"Do not let a second click on a decided card approve or cancel it again."
|
|
23
|
+
],
|
|
24
|
+
"notBuiltYet": "In Scindo the agent asks before carrying out a plan, opening a pull request and merging one. It does not yet ask before deleting files, closing an issue or rolling back a release.",
|
|
25
|
+
"seenIn": [
|
|
26
|
+
"Scindo"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "agent-cancels-when-unanswered",
|
|
31
|
+
"title": "An agent cancels and reports when nobody answers",
|
|
32
|
+
"kind": "rule",
|
|
33
|
+
"level": "rule",
|
|
34
|
+
"area": "agent",
|
|
35
|
+
"situation": "The agent has asked a question or proposed an action, and nobody answers.",
|
|
36
|
+
"answer": "The agent never takes silence as a yes: while a question or proposal waits, it does nothing that depends on the answer. Each product sets the waiting time and shows it on the waiting card. When the time is up, the agent cancels the request, marks the card Cancelled, and posts one line saying what it did not do. The agent may write a plan that lists the unanswered questions as open questions. It may not carry out anything that depends on an answer.",
|
|
37
|
+
"why": "An agent that acts on silence does work nobody approved, and one that waits forever leaves work stuck without saying so.",
|
|
38
|
+
"do": [
|
|
39
|
+
"Keep the card and its buttons open until someone answers or the request is cancelled.",
|
|
40
|
+
"Notify the person who asked when the agent needs their answer.",
|
|
41
|
+
"When a request is cancelled, mark the card Cancelled and post one line on what was not done.",
|
|
42
|
+
"List questions asked before a plan that nobody answered as open questions in that plan."
|
|
43
|
+
],
|
|
44
|
+
"dont": [
|
|
45
|
+
"Do not treat no answer as approval.",
|
|
46
|
+
"Do not cancel a request without saying so in the thread."
|
|
47
|
+
],
|
|
48
|
+
"notBuiltYet": "No product cancels a waiting request on its own yet. In Scindo a request waits until a person answers, cancels or skips it, and the waiting time is not decided.",
|
|
49
|
+
"seenIn": [
|
|
50
|
+
"Scindo"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "agent-refuses-clearly",
|
|
55
|
+
"title": "An agent refuses clearly",
|
|
56
|
+
"kind": "rule",
|
|
57
|
+
"level": "rule",
|
|
58
|
+
"area": "agent",
|
|
59
|
+
"situation": "The product will not let the agent answer a request, for example because the workspace used all its agent replies for the month, reached its spending cap, or sent too many requests at once.",
|
|
60
|
+
"answer": "The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.",
|
|
61
|
+
"why": "A person who is refused needs to know why and what to do next, or they will just send the request again.",
|
|
62
|
+
"do": [
|
|
63
|
+
"Say which limit was reached, with the number when there is one: 'You've used all 50 AI agent responses this month.'",
|
|
64
|
+
"Say who can change it, or when to try again: 'Try again in a minute.'",
|
|
65
|
+
"Show the button that lifts the limit only to a person allowed to use it.",
|
|
66
|
+
"Let the person close the refusal without acting, with a button such as 'Not Now'."
|
|
67
|
+
],
|
|
68
|
+
"dont": [
|
|
69
|
+
"Do not show a general error message for a refusal.",
|
|
70
|
+
"Do not show an Upgrade button to someone who cannot upgrade."
|
|
71
|
+
],
|
|
72
|
+
"native": "On Apple the refusal is a row above the composer, with an Upgrade or Change Budget Cap button for admins and never a link to a web page.",
|
|
73
|
+
"notBuiltYet": "Scindo on the web does not follow this yet: it shows the Upgrade button to everyone. Scindo's Apple app shows it only to admins.",
|
|
74
|
+
"seenIn": [
|
|
75
|
+
"Scindo"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "agent-says-what-it-is",
|
|
80
|
+
"title": "An agent says what it is",
|
|
81
|
+
"kind": "rule",
|
|
82
|
+
"level": "rule",
|
|
83
|
+
"area": "agent",
|
|
84
|
+
"situation": "The agent posts in a thread where people also write, or replies to a person.",
|
|
85
|
+
"answer": "Every agent message has marks no person's message has. It shows an icon avatar instead of a photo, and the agent's own name. When the product knows which model wrote the reply, it shows the model name in small text next to the time. An agent the workspace connects from outside gets a plain bot icon, not the product's logo.",
|
|
86
|
+
"why": "People must see at a glance whether a person or an agent wrote what they are reading, and whose agent it is.",
|
|
87
|
+
"do": [
|
|
88
|
+
"Show the agent with an icon avatar, never a photo or an initial.",
|
|
89
|
+
"Name the agent in the message header: its role or given name, or 'Agent' when it has none.",
|
|
90
|
+
"Show the model name next to the time when the product knows it.",
|
|
91
|
+
"Show the product's logo on the product's own agent and a plain bot icon on an agent from outside, so people see whose agent it is."
|
|
92
|
+
],
|
|
93
|
+
"dont": [
|
|
94
|
+
"Do not show a photo for an agent, even when one is set.",
|
|
95
|
+
"Do not show the product's logo on an agent the product does not run."
|
|
96
|
+
],
|
|
97
|
+
"native": "On Apple an 'Agent' label with a sparkles icon sits next to a named agent's name, and the app draws the agent's avatar itself.",
|
|
98
|
+
"seenIn": [
|
|
99
|
+
"Scindo"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "agent-shows-progress",
|
|
104
|
+
"title": "An agent shows its progress",
|
|
105
|
+
"kind": "rule",
|
|
106
|
+
"level": "rule",
|
|
107
|
+
"area": "agent",
|
|
108
|
+
"situation": "The agent is working on a request and its reply is not ready yet.",
|
|
109
|
+
"answer": "While it works, the agent shows a live row in the thread, where its reply will appear: its name, the model, the seconds so far, the steps it has finished with a check mark, and the step it is on now in plain words, such as 'Reading file'. A Stop button stays on that row for the whole run. When the run is stopped, the agent posts a short note that it stopped.",
|
|
110
|
+
"why": "A person waiting on an agent needs to know it is still working, what it is doing, and that they can stop it.",
|
|
111
|
+
"do": [
|
|
112
|
+
"Show the progress row in the thread, where the reply will appear.",
|
|
113
|
+
"Name the current step in plain words, such as 'Reading file' or 'Editing code'.",
|
|
114
|
+
"Keep finished steps in view, each with a check mark.",
|
|
115
|
+
"Keep a Stop button on the row for the whole run."
|
|
116
|
+
],
|
|
117
|
+
"dont": [
|
|
118
|
+
"Do not show a spinner with no words.",
|
|
119
|
+
"Do not hide the Stop button while the agent writes its reply.",
|
|
120
|
+
"Do not say the agent stopped before the run has really ended."
|
|
121
|
+
],
|
|
122
|
+
"native": "On Apple the Send button turns into Stop while the agent works, and the note reads 'Stopped.' only once the run has really ended.",
|
|
123
|
+
"seenIn": [
|
|
124
|
+
"Scindo"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "agent-shows-sources",
|
|
129
|
+
"title": "An agent shows its sources",
|
|
130
|
+
"kind": "rule",
|
|
131
|
+
"level": "rule",
|
|
132
|
+
"area": "agent",
|
|
133
|
+
"situation": "The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.",
|
|
134
|
+
"answer": "Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section.",
|
|
135
|
+
"why": "A person can check an answer only when they can open what it came from.",
|
|
136
|
+
"do": [
|
|
137
|
+
"Put the sources directly under the reply they support.",
|
|
138
|
+
"Show each source as a card with its title and where it lives, such as the space name or the date.",
|
|
139
|
+
"Make each card open the source itself, in the product or on the service it came from.",
|
|
140
|
+
"Show the first six sources and a 'Show N more' button for the rest."
|
|
141
|
+
],
|
|
142
|
+
"dont": [
|
|
143
|
+
"Do not show a sources section when the reply used no sources.",
|
|
144
|
+
"Do not show source cards on a person's message.",
|
|
145
|
+
"Do not link a source card to any site other than the product or the service the source came from."
|
|
146
|
+
],
|
|
147
|
+
"seenIn": [
|
|
148
|
+
"Scindo"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "login-page",
|
|
153
|
+
"title": "Login page",
|
|
154
|
+
"kind": "design",
|
|
155
|
+
"level": "page",
|
|
156
|
+
"area": "auth",
|
|
157
|
+
"situation": "A person who already has an account opens the product and is not signed in.",
|
|
158
|
+
"do": [
|
|
159
|
+
"Show a problem with one field under that field.",
|
|
160
|
+
"Show a refused sign-in or a failed request in an inline Alert above the fields.",
|
|
161
|
+
"When there is a password, put a text-only 'Forgot password?' Button right under the submit Button.",
|
|
162
|
+
"Name the provider on its button: 'Continue with Google'.",
|
|
163
|
+
"While signing in, show the loading state on the submit Button and keep the form in place."
|
|
164
|
+
],
|
|
165
|
+
"dont": [
|
|
166
|
+
"Do not clear the email field after a failed attempt.",
|
|
167
|
+
"Do not show sign-up fields on the login page; link or tab to sign-up.",
|
|
168
|
+
"Do not replace the form with a spinner while signing in.",
|
|
169
|
+
"Do not say which of the email or the password was wrong."
|
|
170
|
+
],
|
|
171
|
+
"native": "On Apple use `SignInWithAppleButton` for Apple, a grouped form for the fields, and system buttons.",
|
|
172
|
+
"notBuiltYet": "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.",
|
|
173
|
+
"seenIn": [
|
|
174
|
+
"Commentify",
|
|
175
|
+
"Commentify admin",
|
|
176
|
+
"Scindo"
|
|
177
|
+
],
|
|
178
|
+
"options": [
|
|
179
|
+
{
|
|
180
|
+
"id": "centered",
|
|
181
|
+
"title": "Centered column",
|
|
182
|
+
"useWhen": "The product has one way in, and most people sign in with email and a password.",
|
|
183
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Line from 'oneslash-design-system/components/line';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { Center } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"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\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nexport default function LoginCentered() {\n const [email, setEmail] = useState('ada@example.com');\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n\n function handleSubmit() {\n if (loading) return;\n setError('');\n setEmailError('');\n setPasswordError('');\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter a valid email address.');\n return;\n }\n if (!password) {\n setPasswordError('Enter your password.');\n return;\n }\n setLoading(true);\n // Stands in for the request to the server.\n setTimeout(() => {\n setLoading(false);\n setError('That email and password do not match.');\n }, 1200);\n }\n\n return (\n <Center fill>\n <Image src={productMark} alt=\"Acme\" width={40} height={40} />\n <TabsContainer>\n <Tab label=\"Log In\" isSelected onClickTab={() => {}} />\n <Tab label=\"Sign Up\" isSelected={false} href=\"/sign-up\" router={router} onClickTab={() => {}} />\n </TabsContainer>\n <Form aria-label=\"Log in\" onSubmit={handleSubmit}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField id=\"login-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <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(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Log In\" htmlType=\"submit\" loading={loading} />\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Forgot password?\" />\n </Form>\n <Line label=\"or\" />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n </Center>\n );\n}\n",
|
|
184
|
+
"uses": [
|
|
185
|
+
"Alert",
|
|
186
|
+
"BrandIcon",
|
|
187
|
+
"Button",
|
|
188
|
+
"Center",
|
|
189
|
+
"Form",
|
|
190
|
+
"Image",
|
|
191
|
+
"Line",
|
|
192
|
+
"Tab",
|
|
193
|
+
"TabsContainer",
|
|
194
|
+
"TextField"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "split",
|
|
199
|
+
"title": "Brand beside the form",
|
|
200
|
+
"useWhen": "First-time visitors land here and need one line on what the product is.",
|
|
201
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Image from 'oneslash-design-system/components/image';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Line from 'oneslash-design-system/components/line';\nimport Link from 'oneslash-design-system/components/link';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { Center, Cluster, Split, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"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\";\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nexport default function LoginSplit() {\n const [email, setEmail] = useState('ada@example.com');\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n\n function handleSubmit() {\n if (loading) return;\n setError('');\n setEmailError('');\n setPasswordError('');\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter a valid email address.');\n return;\n }\n if (!password) {\n setPasswordError('Enter your password.');\n return;\n }\n setLoading(true);\n // Stands in for the request to the server.\n setTimeout(() => {\n setLoading(false);\n setError('That email and password do not match.');\n }, 1200);\n }\n\n return (\n <Split\n fill\n aside={\n <Stack gap=\"large\">\n <Image src={productMark} alt=\"Acme\" width={40} height={40} />\n <Heading level={2} size=\"h4\">Plan the week with your whole team.</Heading>\n <Paragraph tone=\"secondary\" measure=\"lede\">\n Acme keeps tasks, notes and decisions in one place.\n </Paragraph>\n </Stack>\n }\n >\n <Center fill>\n <Heading level={2} size=\"h5\">Log in to Acme</Heading>\n <Form aria-label=\"Log in\" onSubmit={handleSubmit}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField id=\"split-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <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(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Log In\" htmlType=\"submit\" loading={loading} />\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Forgot password?\" />\n </Form>\n <Line label=\"or\" />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n <Cluster gap=\"small\">\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">New here?</Paragraph>\n <Link href=\"/signup\" size=\"body2\">Create an account</Link>\n </Cluster>\n </Center>\n </Split>\n );\n}\n",
|
|
202
|
+
"uses": [
|
|
203
|
+
"Alert",
|
|
204
|
+
"BrandIcon",
|
|
205
|
+
"Button",
|
|
206
|
+
"Center",
|
|
207
|
+
"Cluster",
|
|
208
|
+
"Form",
|
|
209
|
+
"Heading",
|
|
210
|
+
"Image",
|
|
211
|
+
"Line",
|
|
212
|
+
"Link",
|
|
213
|
+
"Paragraph",
|
|
214
|
+
"Split",
|
|
215
|
+
"Stack",
|
|
216
|
+
"TextField"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "provider-first",
|
|
221
|
+
"title": "Provider first",
|
|
222
|
+
"useWhen": "Most people sign in with Google, GitHub or Apple; email is the fallback.",
|
|
223
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Line from 'oneslash-design-system/components/line';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nexport default function LoginProviderFirst() {\n const [email, setEmail] = useState('ada@example.com');\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n\n function handleSubmit() {\n if (loading) return;\n setError('');\n setEmailError('');\n setPasswordError('');\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter a valid email address.');\n return;\n }\n if (!password) {\n setPasswordError('Enter your password.');\n return;\n }\n setLoading(true);\n // Stands in for the request to the server.\n setTimeout(() => {\n setLoading(false);\n setError('That email and password do not match.');\n }, 1200);\n }\n\n return (\n <Center fill>\n <Heading level={2} size=\"h5\">Sign in to Acme</Heading>\n <Stack gap=\"medium\">\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with GitHub\" decoIcon={<BrandIcon name=\"github\" />} />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Apple\" decoIcon={<BrandIcon name=\"apple\" />} />\n </Stack>\n <Line label=\"or\" />\n <Form aria-label=\"Sign in with email\" onSubmit={handleSubmit}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField id=\"provider-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <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(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign in with email\" htmlType=\"submit\" loading={loading} />\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Forgot password?\" />\n </Form>\n </Center>\n );\n}\n",
|
|
224
|
+
"uses": [
|
|
225
|
+
"Alert",
|
|
226
|
+
"BrandIcon",
|
|
227
|
+
"Button",
|
|
228
|
+
"Center",
|
|
229
|
+
"Form",
|
|
230
|
+
"Heading",
|
|
231
|
+
"Line",
|
|
232
|
+
"Stack",
|
|
233
|
+
"TextField"
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": "email-only",
|
|
238
|
+
"title": "Email only",
|
|
239
|
+
"useWhen": "An internal tool with no passwords: the person gets a sign-in link by email.",
|
|
240
|
+
"source": "'use client';\nimport { useState } from 'react';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\nexport default function LoginEmailOnly() {\n const [email, setEmail] = useState('ada@example.com');\n const [sentTo, setSentTo] = useState('');\n const [emailError, setEmailError] = useState('');\n const [loading, setLoading] = useState(false);\n\n function handleSubmit() {\n if (loading) return;\n setEmailError('');\n setSentTo('');\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter a valid email address.');\n return;\n }\n setLoading(true);\n const address = email.trim();\n // Stands in for the request to the server.\n setTimeout(() => {\n setLoading(false);\n setSentTo(address);\n }, 1200);\n }\n\n return (\n <Center fill>\n <Surface padding=\"large\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"small\">\n <Heading level={2} size=\"h5\">Log in</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">We will email you a link to sign in.</Paragraph>\n </Stack>\n <Form aria-label=\"Log in\" onSubmit={handleSubmit}>\n {sentTo && <Alert type=\"success\" variant=\"inline\" message={`We sent a sign-in link to ${sentTo}.`} showCloseButton onClose={() => setSentTo('')} />}\n <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(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Send sign-in link\" htmlType=\"submit\" loading={loading} />\n </Form>\n </Stack>\n </Surface>\n </Center>\n );\n}\n",
|
|
241
|
+
"uses": [
|
|
242
|
+
"Alert",
|
|
243
|
+
"Button",
|
|
244
|
+
"Center",
|
|
245
|
+
"Form",
|
|
246
|
+
"Heading",
|
|
247
|
+
"Paragraph",
|
|
248
|
+
"Stack",
|
|
249
|
+
"Surface",
|
|
250
|
+
"TextField"
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type BrandName = 'google' | 'github' | 'apple';
|
|
3
|
+
interface BrandIconProps {
|
|
4
|
+
name: BrandName;
|
|
5
|
+
/** Pixel size. Ignored when `className` sets a size (`w-*`, `h-*`, `size-*`), as a Button does. */
|
|
6
|
+
size?: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Names the mark for assistive tech. Without it the icon is hidden from them. */
|
|
9
|
+
title?: string;
|
|
10
|
+
}
|
|
11
|
+
export default function BrandIcon({ name, size, className, title }: BrandIconProps): React.JSX.Element;
|
|
12
|
+
export {};
|