@wallarm-org/design-system 4.7.0 → 4.8.0-rc-fix-claude-code.1
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 +4 -2
- package/dist/components/BulkBar/index.d.ts +5 -0
- package/dist/components/Drawer/classes.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +65 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.d.ts +18 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.d.ts +5 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.js +42 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.d.ts +26 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.js +211 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.d.ts +9 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.js +148 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.d.ts +14 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.js +115 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.d.ts +10 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.js +77 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.d.ts +13 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.js +138 -0
- package/dist/components/NotificationCenter/index.d.ts +9 -0
- package/dist/components/NotificationCenter/index.js +9 -0
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +7 -5
- package/dist/components/SearchInput/SearchInput.js +119 -101
- package/dist/components/Select/SelectSearchInput.d.ts +1 -1
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Tabs/Tabs.js +30 -28
- package/dist/components/Tabs/TabsList/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/Tour/TourPositioner.d.ts +3 -0
- package/dist/components/Tour/TourPositioner.js +4 -4
- package/dist/guidelines/foundations/color.md +157 -0
- package/dist/guidelines/foundations/focus.md +122 -0
- package/dist/guidelines/foundations/layering.md +131 -0
- package/dist/guidelines/foundations/radius-elevation.md +111 -0
- package/dist/guidelines/foundations/spacing.md +117 -0
- package/dist/guidelines/foundations/typography.md +114 -0
- package/dist/guidelines/patterns/app-layout.md +1567 -0
- package/dist/guidelines/patterns/auth-page.md +668 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +605 -0
- package/dist/guidelines/patterns/create-edit-forms.md +768 -0
- package/dist/guidelines/patterns/detail-drawer.md +868 -0
- package/dist/guidelines/patterns/empty-states.md +461 -0
- package/dist/guidelines/patterns/entity-table.md +533 -0
- package/dist/guidelines/patterns/feedback-toasts.md +493 -0
- package/dist/guidelines/patterns/filtering.md +630 -0
- package/dist/guidelines/patterns/resource-list-page.md +558 -0
- package/dist/guidelines/patterns/settings-page.md +752 -0
- package/dist/guidelines/rules.md +25 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/metadata/components.json +12641 -9320
- package/dist/metadata/guidelines.json +1705 -0
- package/dist/theme/typography.css +5 -0
- package/dist/utils/formatDateTime.d.ts +6 -0
- package/dist/utils/formatDateTime.js +13 -1
- package/package.json +6 -1
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Auth page
|
|
3
|
+
description: Use when building a sign-in, organization select, SSO choice or password reset screen that shows one centered card on the animated background.
|
|
4
|
+
components: [AnimatedBackground, Logo, Heading, Text, VStack, HStack, Field, FieldLabel, FieldError, FieldGroup, Input, PasswordInput, OTPInput, PasswordComplexity, Button, Badge, Separator, RadioGroup, Radio, RadioIndicator, RadioLabel, Tag, Link, UtilityPage, Card, Toaster]
|
|
5
|
+
keywords: [auth, login, log in, sign in, sign-in, signin, sign up, password, forgot password, reset password, OTP, one-time code, verification code, SSO, single sign-on, continue with, OR separator, last used, organization select, tenant select, login card, AuthCard, AuthPage, LoginForm]
|
|
6
|
+
order: 100
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Auth page
|
|
10
|
+
|
|
11
|
+
An auth page is one 480px card, centered on `AnimatedBackground`, that holds one step of the sign-in flow.
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
| Need | Use | Not |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Sign in with email and password | Auth card: email step, then password step | A `Dialog` over the app |
|
|
18
|
+
| Pick one of several organizations | Auth card with `RadioGroup variant='card'` | `Select` inside the card |
|
|
19
|
+
| Enter a reset code and a new password | Auth card with `OTPInput`, `PasswordInput`, `PasswordComplexity` | Six separate `Input`s |
|
|
20
|
+
| Show a 404, 403, 500 or offline screen | `UtilityPage` | The auth card |
|
|
21
|
+
| Show that the app loads after sign-in | `SplashScreen` | A spinner inside the auth card |
|
|
22
|
+
|
|
23
|
+
There is no `AuthCard`, `AuthPage`, `AuthLayout` or `LoginForm` component; copy the first example into your app.
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
### Layout and spacing
|
|
28
|
+
|
|
29
|
+
- **Never** render the card inside `Page` or `AppShell`.
|
|
30
|
+
- `AnimatedBackground` centers the card. **Never** center it yourself with `fixed`, `absolute` or `translate`.
|
|
31
|
+
- Card: `w-[480px] rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80 flex flex-col gap-32`.
|
|
32
|
+
- **Never** add a shadow. **Never** use `Card`: it owns 16px padding.
|
|
33
|
+
- **Never** use `UtilityPage` for an auth step: its title is styled as an error code. **Never** copy its `w-[482px]`.
|
|
34
|
+
- **Never** copy the `AppShell` `LoginFlow` story; it has a shadow.
|
|
35
|
+
- Logo: `Logo type='full' size='md' className='mb-32 self-start'` (64px to the title).
|
|
36
|
+
- Title block: `VStack gap={0} align='start'`, `Heading size='2xl' weight='medium'` over `Text size='sm' color='secondary'`.
|
|
37
|
+
- Form: `VStack gap={16}` or `FieldGroup`. **Never** wrap `Field` to add margins.
|
|
38
|
+
- SSO and "Back" buttons: `variant='secondary' color='neutral' fullWidth`, stacked with `VStack gap={8}`. OR row: `HStack gap={12}` with two `Separator className='flex-1'` around a `span className='text-xs text-text-tertiary'`.
|
|
39
|
+
- **Never** pass `size` to `Button`, `Input` or `PasswordInput` in the card. The 36px defaults are correct.
|
|
40
|
+
- **Never** pass `className` to `Field`, `Heading` or `Text`. It is not applied.
|
|
41
|
+
- If the card outgrows the viewport, add `max-h-[calc(100dvh-64px)] overflow-y-auto`.
|
|
42
|
+
- Background: `bg-component-app-shell-bg`. There is no `bg-card`, `bg-primary` or `bg-surface`.
|
|
43
|
+
|
|
44
|
+
### Flow
|
|
45
|
+
|
|
46
|
+
- One card asks one thing. If a step needs two decisions, split it into two cards.
|
|
47
|
+
- If the email domain uses SSO, redirect after the email step. **Never** show an empty password step.
|
|
48
|
+
- If there are 6 or more organizations, show 5 and a ghost "Show more" `Button` under the group.
|
|
49
|
+
|
|
50
|
+
### Form behavior
|
|
51
|
+
|
|
52
|
+
- Use one `<form onSubmit>` per card; the primary `Button` is `type='submit' fullWidth`.
|
|
53
|
+
- Give every other `Button` in the form `type='button'`; without it, the button submits.
|
|
54
|
+
- **Never** put a bare `FieldAction` in a `<form>`: it submits the form. Use `FieldAction asChild` with an `<a href>`.
|
|
55
|
+
- `autoComplete`: `email`, `current-password` (sign-in), `new-password` (reset).
|
|
56
|
+
- Pass `otp` and `groupSize={3}` to `OTPInput`. The default groups 2 + 2 + 2.
|
|
57
|
+
- **Never** add `disabled={pending}` next to `loading`; use `disabled` only for an incomplete form. Keep fields enabled while pending.
|
|
58
|
+
- If sign-in fails, show `FieldError` under the password and keep both values. **Never** use an `Alert`, `Banner` or toast.
|
|
59
|
+
- If the code is wrong, pass `error` to `OTPInput` and add a `FieldError` in the same `Field`.
|
|
60
|
+
- Show the "LAST" badge on at most one button.
|
|
61
|
+
- For the resend countdown, use `Link disabled`. `FieldAction` takes no `disabled`.
|
|
62
|
+
- Import `FieldAction` and `FieldIndicator` from `@wallarm-org/design-system/Field`, `useToast` from `@wallarm-org/design-system/Toast`, icons from `@wallarm-org/design-system/icons`.
|
|
63
|
+
|
|
64
|
+
### Copy
|
|
65
|
+
|
|
66
|
+
| Part | Write | Not |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Sign-in title / subtitle | "Welcome back!" / "Sign in to your account" | "Login" |
|
|
69
|
+
| Other titles | "Select organization", "Reset password" | "Choose org" |
|
|
70
|
+
| Credentials error | "Email or password is incorrect." | "Wrong password", "User not found" |
|
|
71
|
+
| Submit | "Sign in" on the password step, "Continue" elsewhere | "Log in", "Submit", "Next" |
|
|
72
|
+
| SSO button | "Continue with {provider}" | "Sign in with SSO" |
|
|
73
|
+
| Separator | "OR" | "or continue with" |
|
|
74
|
+
| Organization subtitle | "Choose which organization to sign in to." | "Select one" |
|
|
75
|
+
| Reset subtitle | "We've sent a code to {email}" | "Check your inbox" |
|
|
76
|
+
| Resend | "Resend in {n}s", then "Resend code" | "Didn't get it?" |
|
|
77
|
+
| Reset toast | "Password reset" | "Your password was reset successfully!" |
|
|
78
|
+
| Placeholders | "you@your-company.com", "Enter" | "Email", "Password" |
|
|
79
|
+
|
|
80
|
+
- **Never** say which credential is wrong. Use sentence case.
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
The sign-in flow in the card shell every step renders inside.
|
|
85
|
+
|
|
86
|
+
The sign-in flow: an email step, then a password step with "Forgot password?", the OR row and
|
|
87
|
+
SSO buttons, one of them marked "LAST". There is no backend, so "Sign in" always shows the
|
|
88
|
+
wrong-credentials state; an SSO button shows its spinner on that button only.
|
|
89
|
+
|
|
90
|
+
```tsx story=Default
|
|
91
|
+
import { type ChangeEvent, type FormEvent, useState } from 'react';
|
|
92
|
+
import { AnimatedBackground } from '@wallarm-org/design-system/AnimatedBackground';
|
|
93
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
94
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
95
|
+
import { Field, FieldAction, FieldError, FieldLabel } from '@wallarm-org/design-system/Field';
|
|
96
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
97
|
+
import { Aws, Google } from '@wallarm-org/design-system/icons';
|
|
98
|
+
import { Input } from '@wallarm-org/design-system/Input';
|
|
99
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
100
|
+
import { PasswordInput } from '@wallarm-org/design-system/PasswordInput';
|
|
101
|
+
import { Separator } from '@wallarm-org/design-system/Separator';
|
|
102
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
103
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
104
|
+
|
|
105
|
+
export const Default = () => {
|
|
106
|
+
const [step, setStep] = useState<'email' | 'password'>('email');
|
|
107
|
+
const [email, setEmail] = useState('');
|
|
108
|
+
const [password, setPassword] = useState('');
|
|
109
|
+
const [failed, setFailed] = useState(false);
|
|
110
|
+
const [ssoPending, setSsoPending] = useState<SignInMethod | null>(null);
|
|
111
|
+
|
|
112
|
+
const handleEmailChange = (event: ChangeEvent<HTMLInputElement>) => setEmail(event.target.value);
|
|
113
|
+
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
114
|
+
setPassword(event.target.value);
|
|
115
|
+
setFailed(false);
|
|
116
|
+
};
|
|
117
|
+
const handleEmailSubmit = (event: FormEvent<HTMLFormElement>) => {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
setStep('password');
|
|
120
|
+
};
|
|
121
|
+
const handleSignIn = (event: FormEvent<HTMLFormElement>) => {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
onSignIn({ email, password });
|
|
124
|
+
setFailed(true);
|
|
125
|
+
};
|
|
126
|
+
const handleBack = () => {
|
|
127
|
+
setStep('email');
|
|
128
|
+
setPassword('');
|
|
129
|
+
setFailed(false);
|
|
130
|
+
};
|
|
131
|
+
const handleAws = () => {
|
|
132
|
+
setSsoPending('aws');
|
|
133
|
+
onSsoContinue('aws');
|
|
134
|
+
};
|
|
135
|
+
const handleGoogle = () => {
|
|
136
|
+
setSsoPending('google');
|
|
137
|
+
onSsoContinue('google');
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<AnimatedBackground className='h-full w-full bg-component-app-shell-bg'>
|
|
142
|
+
<div
|
|
143
|
+
data-testid='sign-in-card'
|
|
144
|
+
className='flex max-h-[calc(100dvh-64px)] w-[480px] flex-col gap-32 overflow-y-auto rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80'
|
|
145
|
+
>
|
|
146
|
+
<Logo type='full' size='md' className='mb-32 self-start' />
|
|
147
|
+
<VStack gap={0} align='start'>
|
|
148
|
+
<Heading size='2xl' weight='medium'>
|
|
149
|
+
Welcome back!
|
|
150
|
+
</Heading>
|
|
151
|
+
<Text size='sm' color='secondary'>
|
|
152
|
+
Sign in to your account
|
|
153
|
+
</Text>
|
|
154
|
+
</VStack>
|
|
155
|
+
|
|
156
|
+
{step === 'email' && (
|
|
157
|
+
<form onSubmit={handleEmailSubmit}>
|
|
158
|
+
<VStack gap={16}>
|
|
159
|
+
<Field data-testid='sign-in-email' required>
|
|
160
|
+
<FieldLabel>Email</FieldLabel>
|
|
161
|
+
<Input
|
|
162
|
+
type='email'
|
|
163
|
+
autoComplete='email'
|
|
164
|
+
placeholder='you@your-company.com'
|
|
165
|
+
value={email}
|
|
166
|
+
onChange={handleEmailChange}
|
|
167
|
+
/>
|
|
168
|
+
</Field>
|
|
169
|
+
<Button data-testid='sign-in-continue' type='submit' fullWidth disabled={!email}>
|
|
170
|
+
Continue
|
|
171
|
+
</Button>
|
|
172
|
+
</VStack>
|
|
173
|
+
</form>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{step === 'password' && (
|
|
177
|
+
<>
|
|
178
|
+
<form onSubmit={handleSignIn}>
|
|
179
|
+
<VStack gap={16}>
|
|
180
|
+
<Field data-testid='sign-in-password' invalid={failed}>
|
|
181
|
+
<FieldLabel>
|
|
182
|
+
Password
|
|
183
|
+
<FieldAction asChild>
|
|
184
|
+
<a href='#forgot-password'>Forgot password?</a>
|
|
185
|
+
</FieldAction>
|
|
186
|
+
</FieldLabel>
|
|
187
|
+
<PasswordInput
|
|
188
|
+
autoComplete='current-password'
|
|
189
|
+
placeholder='Enter'
|
|
190
|
+
error={failed}
|
|
191
|
+
value={password}
|
|
192
|
+
onChange={handlePasswordChange}
|
|
193
|
+
/>
|
|
194
|
+
{failed && <FieldError>Email or password is incorrect.</FieldError>}
|
|
195
|
+
</Field>
|
|
196
|
+
<VStack gap={8}>
|
|
197
|
+
<Button data-testid='sign-in-submit' type='submit' fullWidth disabled={!password}>
|
|
198
|
+
Sign in
|
|
199
|
+
</Button>
|
|
200
|
+
<Button
|
|
201
|
+
data-testid='sign-in-back'
|
|
202
|
+
type='button'
|
|
203
|
+
variant='secondary'
|
|
204
|
+
color='neutral'
|
|
205
|
+
fullWidth
|
|
206
|
+
onClick={handleBack}
|
|
207
|
+
>
|
|
208
|
+
Back
|
|
209
|
+
</Button>
|
|
210
|
+
</VStack>
|
|
211
|
+
</VStack>
|
|
212
|
+
</form>
|
|
213
|
+
|
|
214
|
+
<HStack gap={12}>
|
|
215
|
+
<Separator className='flex-1' />
|
|
216
|
+
<span className='text-xs text-text-tertiary'>OR</span>
|
|
217
|
+
<Separator className='flex-1' />
|
|
218
|
+
</HStack>
|
|
219
|
+
|
|
220
|
+
<VStack gap={8} data-testid='sign-in-sso'>
|
|
221
|
+
<div className='relative w-full'>
|
|
222
|
+
<Button
|
|
223
|
+
variant='secondary'
|
|
224
|
+
color='neutral'
|
|
225
|
+
fullWidth
|
|
226
|
+
loading={ssoPending === 'aws'}
|
|
227
|
+
onClick={handleAws}
|
|
228
|
+
>
|
|
229
|
+
<Aws />
|
|
230
|
+
Continue with AWS
|
|
231
|
+
</Button>
|
|
232
|
+
{LAST_METHOD === 'aws' && (
|
|
233
|
+
<Badge size='small' color='blue' className='absolute -top-6 -right-8 uppercase'>
|
|
234
|
+
Last
|
|
235
|
+
</Badge>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
<div className='relative w-full'>
|
|
239
|
+
<Button
|
|
240
|
+
variant='secondary'
|
|
241
|
+
color='neutral'
|
|
242
|
+
fullWidth
|
|
243
|
+
loading={ssoPending === 'google'}
|
|
244
|
+
onClick={handleGoogle}
|
|
245
|
+
>
|
|
246
|
+
<Google />
|
|
247
|
+
Continue with Google
|
|
248
|
+
</Button>
|
|
249
|
+
{LAST_METHOD === 'google' && (
|
|
250
|
+
<Badge size='small' color='blue' className='absolute -top-6 -right-8 uppercase'>
|
|
251
|
+
Last
|
|
252
|
+
</Badge>
|
|
253
|
+
)}
|
|
254
|
+
</div>
|
|
255
|
+
</VStack>
|
|
256
|
+
</>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
</AnimatedBackground>
|
|
260
|
+
);
|
|
261
|
+
};
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
A password field with "Forgot password?" as a link and the failed state.
|
|
265
|
+
|
|
266
|
+
The failed password step: the error names neither credential, the password stays in the field,
|
|
267
|
+
and editing it clears the error.
|
|
268
|
+
|
|
269
|
+
```tsx story=WrongCredentials
|
|
270
|
+
import { type ChangeEvent, type FormEvent, useState } from 'react';
|
|
271
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
272
|
+
import { Field, FieldAction, FieldError, FieldLabel } from '@wallarm-org/design-system/Field';
|
|
273
|
+
import { PasswordInput } from '@wallarm-org/design-system/PasswordInput';
|
|
274
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
275
|
+
|
|
276
|
+
export const WrongCredentials = () => {
|
|
277
|
+
const [password, setPassword] = useState('Winter2026');
|
|
278
|
+
const [failed, setFailed] = useState(true);
|
|
279
|
+
|
|
280
|
+
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
281
|
+
setPassword(event.target.value);
|
|
282
|
+
setFailed(false);
|
|
283
|
+
};
|
|
284
|
+
const handleSignIn = (event: FormEvent<HTMLFormElement>) => {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
onSignIn({ email: 'maria.lopez@acme-bank.com', password });
|
|
287
|
+
setFailed(true);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<div
|
|
292
|
+
data-testid='wrong-credentials-card'
|
|
293
|
+
className='flex max-h-[calc(100dvh-64px)] w-[480px] flex-col gap-32 overflow-y-auto rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80'
|
|
294
|
+
>
|
|
295
|
+
<form onSubmit={handleSignIn}>
|
|
296
|
+
<VStack gap={16}>
|
|
297
|
+
<Field data-testid='wrong-credentials-password' invalid={failed}>
|
|
298
|
+
<FieldLabel>
|
|
299
|
+
Password
|
|
300
|
+
<FieldAction asChild>
|
|
301
|
+
<a href='#forgot-password'>Forgot password?</a>
|
|
302
|
+
</FieldAction>
|
|
303
|
+
</FieldLabel>
|
|
304
|
+
<PasswordInput
|
|
305
|
+
autoComplete='current-password'
|
|
306
|
+
placeholder='Enter'
|
|
307
|
+
error={failed}
|
|
308
|
+
value={password}
|
|
309
|
+
onChange={handlePasswordChange}
|
|
310
|
+
/>
|
|
311
|
+
{failed && <FieldError>Email or password is incorrect.</FieldError>}
|
|
312
|
+
</Field>
|
|
313
|
+
<Button
|
|
314
|
+
data-testid='wrong-credentials-submit'
|
|
315
|
+
type='submit'
|
|
316
|
+
fullWidth
|
|
317
|
+
disabled={!password}
|
|
318
|
+
>
|
|
319
|
+
Sign in
|
|
320
|
+
</Button>
|
|
321
|
+
</VStack>
|
|
322
|
+
</form>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
};
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
The OR row and SSO buttons with the "LAST" badge.
|
|
329
|
+
|
|
330
|
+
A clicked SSO button shows its spinner; the other buttons stay as they are.
|
|
331
|
+
|
|
332
|
+
```tsx story=SsoButtons
|
|
333
|
+
import { useState } from 'react';
|
|
334
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
335
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
336
|
+
import { Aws, Google } from '@wallarm-org/design-system/icons';
|
|
337
|
+
import { Separator } from '@wallarm-org/design-system/Separator';
|
|
338
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
339
|
+
|
|
340
|
+
export const SsoButtons = () => {
|
|
341
|
+
const [ssoPending, setSsoPending] = useState<SignInMethod | null>(null);
|
|
342
|
+
|
|
343
|
+
const handleAws = () => {
|
|
344
|
+
setSsoPending('aws');
|
|
345
|
+
onSsoContinue('aws');
|
|
346
|
+
};
|
|
347
|
+
const handleGoogle = () => {
|
|
348
|
+
setSsoPending('google');
|
|
349
|
+
onSsoContinue('google');
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
return (
|
|
353
|
+
<div
|
|
354
|
+
data-testid='sso-card'
|
|
355
|
+
className='flex max-h-[calc(100dvh-64px)] w-[480px] flex-col gap-32 overflow-y-auto rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80'
|
|
356
|
+
>
|
|
357
|
+
<HStack gap={12}>
|
|
358
|
+
<Separator className='flex-1' />
|
|
359
|
+
<span className='text-xs text-text-tertiary'>OR</span>
|
|
360
|
+
<Separator className='flex-1' />
|
|
361
|
+
</HStack>
|
|
362
|
+
<VStack gap={8} data-testid='sso-buttons'>
|
|
363
|
+
<div className='relative w-full'>
|
|
364
|
+
<Button
|
|
365
|
+
variant='secondary'
|
|
366
|
+
color='neutral'
|
|
367
|
+
fullWidth
|
|
368
|
+
loading={ssoPending === 'aws'}
|
|
369
|
+
onClick={handleAws}
|
|
370
|
+
>
|
|
371
|
+
<Aws />
|
|
372
|
+
Continue with AWS
|
|
373
|
+
</Button>
|
|
374
|
+
{LAST_METHOD === 'aws' && (
|
|
375
|
+
<Badge size='small' color='blue' className='absolute -top-6 -right-8 uppercase'>
|
|
376
|
+
Last
|
|
377
|
+
</Badge>
|
|
378
|
+
)}
|
|
379
|
+
</div>
|
|
380
|
+
<div className='relative w-full'>
|
|
381
|
+
<Button
|
|
382
|
+
variant='secondary'
|
|
383
|
+
color='neutral'
|
|
384
|
+
fullWidth
|
|
385
|
+
loading={ssoPending === 'google'}
|
|
386
|
+
onClick={handleGoogle}
|
|
387
|
+
>
|
|
388
|
+
<Google />
|
|
389
|
+
Continue with Google
|
|
390
|
+
</Button>
|
|
391
|
+
{LAST_METHOD === 'google' && (
|
|
392
|
+
<Badge size='small' color='blue' className='absolute -top-6 -right-8 uppercase'>
|
|
393
|
+
Last
|
|
394
|
+
</Badge>
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
</VStack>
|
|
398
|
+
</div>
|
|
399
|
+
);
|
|
400
|
+
};
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Organization select, collapsed to 5 rows with "Show more".
|
|
404
|
+
|
|
405
|
+
Organization select for a user in 7 organizations: card radios collapsed to 5 rows, with a
|
|
406
|
+
ghost "Show more" button under the group.
|
|
407
|
+
|
|
408
|
+
```tsx story=SelectOrganization
|
|
409
|
+
import { type FormEvent, useState } from 'react';
|
|
410
|
+
import { AnimatedBackground } from '@wallarm-org/design-system/AnimatedBackground';
|
|
411
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
412
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
413
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
414
|
+
import { Radio, RadioGroup, RadioIndicator, RadioLabel } from '@wallarm-org/design-system/Radio';
|
|
415
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
416
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
417
|
+
|
|
418
|
+
export const SelectOrganization = () => {
|
|
419
|
+
const [value, setValue] = useState<string | null>(null);
|
|
420
|
+
const [expanded, setExpanded] = useState(false);
|
|
421
|
+
|
|
422
|
+
const visible = expanded ? ORGANIZATIONS : ORGANIZATIONS.slice(0, 5);
|
|
423
|
+
|
|
424
|
+
const handleValueChange = (details: { value: string | null }) => setValue(details.value);
|
|
425
|
+
const handleToggle = () => setExpanded(!expanded);
|
|
426
|
+
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
onOrganizationSelect(value);
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<AnimatedBackground className='h-full w-full bg-component-app-shell-bg'>
|
|
433
|
+
<div
|
|
434
|
+
data-testid='organization-card'
|
|
435
|
+
className='flex max-h-[calc(100dvh-64px)] w-[480px] flex-col gap-32 overflow-y-auto rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80'
|
|
436
|
+
>
|
|
437
|
+
<Logo type='full' size='md' className='mb-32 self-start' />
|
|
438
|
+
<VStack gap={0} align='start'>
|
|
439
|
+
<Heading size='2xl' weight='medium'>
|
|
440
|
+
Select organization
|
|
441
|
+
</Heading>
|
|
442
|
+
<Text size='sm' color='secondary'>
|
|
443
|
+
Choose which organization to sign in to.
|
|
444
|
+
</Text>
|
|
445
|
+
</VStack>
|
|
446
|
+
|
|
447
|
+
<form onSubmit={handleSubmit}>
|
|
448
|
+
<VStack gap={16}>
|
|
449
|
+
<VStack gap={8} data-testid='organization-list'>
|
|
450
|
+
<RadioGroup variant='card' value={value} onValueChange={handleValueChange}>
|
|
451
|
+
{visible.map(org => (
|
|
452
|
+
<Radio key={org.id} value={org.id}>
|
|
453
|
+
<RadioIndicator />
|
|
454
|
+
<RadioLabel>{org.name}</RadioLabel>
|
|
455
|
+
</Radio>
|
|
456
|
+
))}
|
|
457
|
+
</RadioGroup>
|
|
458
|
+
{ORGANIZATIONS.length > 5 && (
|
|
459
|
+
<Button
|
|
460
|
+
data-testid='organization-show-more'
|
|
461
|
+
type='button'
|
|
462
|
+
variant='ghost'
|
|
463
|
+
color='neutral'
|
|
464
|
+
onClick={handleToggle}
|
|
465
|
+
>
|
|
466
|
+
{expanded ? 'Show less' : 'Show more'}
|
|
467
|
+
</Button>
|
|
468
|
+
)}
|
|
469
|
+
</VStack>
|
|
470
|
+
<Button data-testid='organization-continue' type='submit' fullWidth disabled={!value}>
|
|
471
|
+
Continue
|
|
472
|
+
</Button>
|
|
473
|
+
</VStack>
|
|
474
|
+
</form>
|
|
475
|
+
</div>
|
|
476
|
+
</AnimatedBackground>
|
|
477
|
+
);
|
|
478
|
+
};
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
The reset code with a resend countdown, and the password rules from `passwordValidators`.
|
|
482
|
+
|
|
483
|
+
Password reset: a 6-digit code with a resend countdown, a new password with its confirmation,
|
|
484
|
+
and the full rule list from `passwordValidators`. "Continue" stays disabled until the code is
|
|
485
|
+
complete and every rule is met; it then shows the "Password reset" toast.
|
|
486
|
+
|
|
487
|
+
```tsx story=ResetPassword
|
|
488
|
+
import { type ChangeEvent, type FormEvent, useState } from 'react';
|
|
489
|
+
import { AnimatedBackground } from '@wallarm-org/design-system/AnimatedBackground';
|
|
490
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
491
|
+
import { Field, FieldIndicator, FieldLabel } from '@wallarm-org/design-system/Field';
|
|
492
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
493
|
+
import { OTPInput } from '@wallarm-org/design-system/InputOTP';
|
|
494
|
+
import { Link } from '@wallarm-org/design-system/Link';
|
|
495
|
+
import { Logo } from '@wallarm-org/design-system/Logo';
|
|
496
|
+
import { PasswordComplexity, type PasswordComplexityItem, passwordValidators } from '@wallarm-org/design-system/PasswordComplexity';
|
|
497
|
+
import { PasswordInput } from '@wallarm-org/design-system/PasswordInput';
|
|
498
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
499
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
500
|
+
import { useToast } from '@wallarm-org/design-system/Toast';
|
|
501
|
+
|
|
502
|
+
export const ResetPassword = () => {
|
|
503
|
+
const toast = useToast();
|
|
504
|
+
const [code, setCode] = useState('');
|
|
505
|
+
const [password, setPassword] = useState('');
|
|
506
|
+
const [confirm, setConfirm] = useState('');
|
|
507
|
+
|
|
508
|
+
// The app owns the resend timer; the story freezes it at 55 seconds.
|
|
509
|
+
const secondsLeft = 55;
|
|
510
|
+
|
|
511
|
+
const rules: PasswordComplexityItem[] = [
|
|
512
|
+
{
|
|
513
|
+
id: 'length',
|
|
514
|
+
label: 'At least 8 characters',
|
|
515
|
+
met: passwordValidators.minLength(8)(password),
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
id: 'uppercase',
|
|
519
|
+
label: 'One uppercase letter (A–Z)',
|
|
520
|
+
met: passwordValidators.hasUppercase(password),
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: 'lowercase',
|
|
524
|
+
label: 'One lowercase letter (a–z)',
|
|
525
|
+
met: passwordValidators.hasLowercase(password),
|
|
526
|
+
},
|
|
527
|
+
{ id: 'number', label: 'One number (0–9)', met: passwordValidators.hasNumber(password) },
|
|
528
|
+
{
|
|
529
|
+
id: 'symbol',
|
|
530
|
+
label: 'One symbol (e.g. ! ? @ #)',
|
|
531
|
+
met: passwordValidators.hasSymbol(password),
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
id: 'match',
|
|
535
|
+
label: 'Both passwords match',
|
|
536
|
+
met: passwordValidators.passwordsMatch(password, confirm),
|
|
537
|
+
},
|
|
538
|
+
];
|
|
539
|
+
const complete = code.length === 6 && rules.every(rule => rule.met);
|
|
540
|
+
|
|
541
|
+
const handleCodeChange = (details: { valueAsString: string }) => setCode(details.valueAsString);
|
|
542
|
+
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) =>
|
|
543
|
+
setPassword(event.target.value);
|
|
544
|
+
const handleConfirmChange = (event: ChangeEvent<HTMLInputElement>) =>
|
|
545
|
+
setConfirm(event.target.value);
|
|
546
|
+
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
|
|
547
|
+
event.preventDefault();
|
|
548
|
+
onPasswordReset();
|
|
549
|
+
toast.create({ id: 'password-reset', title: 'Password reset', type: 'default' });
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
return (
|
|
553
|
+
<AnimatedBackground className='h-full w-full bg-component-app-shell-bg'>
|
|
554
|
+
<div
|
|
555
|
+
data-testid='reset-password-card'
|
|
556
|
+
className='flex max-h-[calc(100dvh-64px)] w-[480px] flex-col gap-32 overflow-y-auto rounded-12 border-1 border-border-primary-light bg-bg-surface-1 px-48 pt-32 pb-80'
|
|
557
|
+
>
|
|
558
|
+
<Logo type='full' size='md' className='mb-32 self-start' />
|
|
559
|
+
<VStack gap={0} align='start'>
|
|
560
|
+
<Heading size='2xl' weight='medium'>
|
|
561
|
+
Reset password
|
|
562
|
+
</Heading>
|
|
563
|
+
<Text size='sm' color='secondary'>
|
|
564
|
+
We've sent a code to maria.lopez@acme-bank.com
|
|
565
|
+
</Text>
|
|
566
|
+
</VStack>
|
|
567
|
+
|
|
568
|
+
<form onSubmit={handleSubmit}>
|
|
569
|
+
<VStack gap={16}>
|
|
570
|
+
<Field data-testid='reset-password-code' required>
|
|
571
|
+
<FieldLabel>
|
|
572
|
+
Code
|
|
573
|
+
<FieldIndicator />
|
|
574
|
+
<Link
|
|
575
|
+
asChild
|
|
576
|
+
size='sm'
|
|
577
|
+
weight='medium'
|
|
578
|
+
disabled={secondsLeft > 0}
|
|
579
|
+
onClick={onResend}
|
|
580
|
+
className='ml-auto'
|
|
581
|
+
>
|
|
582
|
+
<button type='button'>
|
|
583
|
+
{secondsLeft > 0 ? `Resend in ${secondsLeft}s` : 'Resend code'}
|
|
584
|
+
</button>
|
|
585
|
+
</Link>
|
|
586
|
+
</FieldLabel>
|
|
587
|
+
<OTPInput otp groupSize={3} onValueChange={handleCodeChange} />
|
|
588
|
+
</Field>
|
|
589
|
+
<Field data-testid='reset-password-new' required>
|
|
590
|
+
<FieldLabel>
|
|
591
|
+
New password
|
|
592
|
+
<FieldIndicator />
|
|
593
|
+
</FieldLabel>
|
|
594
|
+
<PasswordInput
|
|
595
|
+
autoComplete='new-password'
|
|
596
|
+
placeholder='Enter'
|
|
597
|
+
value={password}
|
|
598
|
+
onChange={handlePasswordChange}
|
|
599
|
+
/>
|
|
600
|
+
</Field>
|
|
601
|
+
<Field data-testid='reset-password-confirm' required>
|
|
602
|
+
<FieldLabel>
|
|
603
|
+
Confirm password
|
|
604
|
+
<FieldIndicator />
|
|
605
|
+
</FieldLabel>
|
|
606
|
+
<PasswordInput
|
|
607
|
+
autoComplete='new-password'
|
|
608
|
+
placeholder='Enter'
|
|
609
|
+
value={confirm}
|
|
610
|
+
onChange={handleConfirmChange}
|
|
611
|
+
/>
|
|
612
|
+
</Field>
|
|
613
|
+
<PasswordComplexity data-testid='reset-password-rules' items={rules} />
|
|
614
|
+
<Button
|
|
615
|
+
data-testid='reset-password-submit'
|
|
616
|
+
type='submit'
|
|
617
|
+
fullWidth
|
|
618
|
+
disabled={!complete}
|
|
619
|
+
>
|
|
620
|
+
Continue
|
|
621
|
+
</Button>
|
|
622
|
+
</VStack>
|
|
623
|
+
</form>
|
|
624
|
+
</div>
|
|
625
|
+
</AnimatedBackground>
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
## States
|
|
631
|
+
|
|
632
|
+
| State | Show | Example component |
|
|
633
|
+
| --- | --- | --- |
|
|
634
|
+
| Email step | Email field and "Continue" | `Field` + `Input type='email'` |
|
|
635
|
+
| Password step | Password, "Forgot password?", OR, SSO | `PasswordInput`, `FieldAction asChild` |
|
|
636
|
+
| Submitting | Spinner on "Sign in" | `Button loading` |
|
|
637
|
+
| Wrong credentials | Red password border, error line | `Field invalid`, `PasswordInput error`, `FieldError` |
|
|
638
|
+
| Last used method | "LAST" on one button | `Badge size='small' color='blue'` |
|
|
639
|
+
| SSO redirect | Spinner on the clicked button only | `Button loading` |
|
|
640
|
+
| Organization chosen | Building icon, name, "Change" above the fields | `Tag` + `Link type='muted' size='sm'` |
|
|
641
|
+
| 6+ organizations | 5 rows, then "Show more" / "Show less" | Ghost `Button` |
|
|
642
|
+
| Resend countdown | "Resend in 55s", disabled | `Link disabled` |
|
|
643
|
+
| Password rules | Dot for unmet, check and strike-through for met | `PasswordComplexity` |
|
|
644
|
+
| Reset done | Sign-in card, then a toast | `toast.create({ title: 'Password reset', type: 'default' })` |
|
|
645
|
+
|
|
646
|
+
## What your app owns
|
|
647
|
+
|
|
648
|
+
- Step routing, the password-or-SSO lookup, credential checks, `pending` and error state, SSO redirects, the resend timer, code verification and the reset email.
|
|
649
|
+
- Storing the last-used method (cookie or `localStorage`).
|
|
650
|
+
- One `Toaster` at the app root.
|
|
651
|
+
|
|
652
|
+
These do not exist:
|
|
653
|
+
|
|
654
|
+
- A `variant` on `UtilityPage`.
|
|
655
|
+
- A `label` prop on `Separator`, or a badge prop on `Button`.
|
|
656
|
+
- A "Show more" row in `RadioGroup`. The card variant shows separate cards, not one joined list.
|
|
657
|
+
- A clear (X) button on `Input`, or a tertiary `Text color`.
|
|
658
|
+
- An outline for the last-used button. Render the badge only.
|
|
659
|
+
- A non-focusable `Tag`. Accept the extra tab stop.
|
|
660
|
+
|
|
661
|
+
## Related
|
|
662
|
+
|
|
663
|
+
- [Feedback toasts](./feedback-toasts.md): the "Password reset" toast and the single `Toaster`.
|
|
664
|
+
- [Create and edit forms](./create-edit-forms.md): `Field`, `FieldError` and required markers.
|
|
665
|
+
- [Spacing](../foundations/spacing.md): px utilities and stack gaps.
|
|
666
|
+
- [Typography](../foundations/typography.md): `Heading` and `Text` sizes.
|
|
667
|
+
- [Color](../foundations/color.md): surface, border and text tokens.
|
|
668
|
+
- [Radius and elevation](../foundations/radius-elevation.md): `rounded-12` and why the card has no shadow.
|