@designa8/vibedesign-v6 1.20.20 → 2.1.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 +1 -1
- package/dist/fonts/plusjakartasans/PlusJakartaSans-Italic[wght].ttf +0 -0
- package/dist/fonts/plusjakartasans/PlusJakartaSans[wght].ttf +0 -0
- package/dist/index.cjs +12027 -4942
- package/dist/index.js +12089 -5004
- package/dist/styles.css +1393 -97
- package/package.json +116 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +567 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +199 -0
- package/src/atoms/AppLayout/AppLayout.tsx +85 -22
- package/src/atoms/AppLayout/preview.tsx +4 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +222 -137
- package/src/atoms/AppSidebar/preview.tsx +61 -8
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +241 -169
- package/src/atoms/AppSidebarMobile/preview.tsx +59 -89
- package/src/atoms/AuthLogin/AuthLogin.tsx +86 -49
- package/src/atoms/AuthLogin/preview.tsx +16 -0
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +206 -126
- package/src/atoms/AuthSignUp/preview.tsx +10 -0
- package/src/atoms/BottomSheet/BottomSheet.tsx +199 -0
- package/src/atoms/BottomSheet/index.ts +2 -0
- package/src/atoms/BottomSheet/preview.tsx +50 -0
- package/src/atoms/Button/Button.tsx +19 -3
- package/src/atoms/Button/preview.tsx +2 -1
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +160 -84
- package/src/atoms/ChatHistorySidebar/preview.tsx +81 -42
- package/src/atoms/ChatScreen/ChatScreen.tsx +298 -33
- package/src/atoms/ChatScreen/preview.tsx +54 -90
- package/src/atoms/Chip/Chip.tsx +81 -33
- package/src/atoms/Chip/preview.tsx +39 -21
- package/src/atoms/CodeEditor/CodeEditor.tsx +10 -4
- package/src/atoms/ComponentActionsSheet/ComponentActionsSheet.tsx +165 -0
- package/src/atoms/ComponentActionsSheet/index.ts +7 -0
- package/src/atoms/ComponentActionsSheet/preview.tsx +67 -0
- package/src/atoms/ComponentCard/ComponentCard.tsx +17 -35
- package/src/atoms/ComponentCard/preview.tsx +9 -9
- package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +153 -0
- package/src/atoms/DesignSystemLoader/index.ts +2 -0
- package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
- package/src/atoms/DesignSystemShowcase/DesignSystemShowcase.tsx +410 -0
- package/src/atoms/DesignSystemShowcase/index.ts +6 -0
- package/src/atoms/DesignSystemShowcase/preview.tsx +22 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.data.ts +254 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.tsx +946 -0
- package/src/atoms/DesignTokensPanel/index.ts +9 -0
- package/src/atoms/DesignTokensPanel/preview.tsx +39 -0
- package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +239 -0
- package/src/atoms/ExpandableMessage/fix-link-note.txt +3 -0
- package/src/atoms/ExpandableMessage/index.ts +2 -0
- package/src/atoms/ExpandableMessage/markdown.tsx +310 -0
- package/src/atoms/ExpandableMessage/preview.tsx +83 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
- package/src/atoms/FontCombobox/FontCombobox.tsx +655 -0
- package/src/atoms/FontCombobox/index.ts +6 -0
- package/src/atoms/FontCombobox/preview.tsx +111 -0
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +894 -96
- package/src/atoms/HomePageTemplate/preview.tsx +4 -0
- package/src/atoms/Icon/Icon.tsx +17 -11
- package/src/atoms/Icon/icons.data.ts +34 -0
- package/src/atoms/Input/Input.tsx +37 -21
- package/src/atoms/LandingHero/LandingHero.tsx +545 -0
- package/src/atoms/LandingHero/index.ts +6 -0
- package/src/atoms/LandingHero/preview.tsx +88 -0
- package/src/atoms/MarketingFooter/MarketingFooter.tsx +215 -0
- package/src/atoms/MarketingFooter/index.ts +7 -0
- package/src/atoms/MarketingFooter/preview.tsx +28 -0
- package/src/atoms/MarketingNavbar/MarketingNavbar.tsx +451 -0
- package/src/atoms/MarketingNavbar/index.ts +7 -0
- package/src/atoms/MarketingNavbar/preview.tsx +109 -0
- package/src/atoms/MobileActionsDrawer/MobileActionsDrawer.tsx +548 -0
- package/src/atoms/MobileActionsDrawer/index.ts +9 -0
- package/src/atoms/MobileActionsDrawer/preview.tsx +109 -0
- package/src/atoms/Modal/Modal.tsx +77 -28
- package/src/atoms/PreviewDock/PreviewDock.tsx +119 -0
- package/src/atoms/PreviewDock/index.ts +2 -0
- package/src/atoms/PreviewDock/preview.tsx +30 -0
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +47 -30
- package/src/atoms/PricingCard/PricingCard.tsx +15 -4
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +109 -89
- package/src/atoms/ProjectSettingsModal/ProjectSettingsModal.tsx +314 -0
- package/src/atoms/ProjectSettingsModal/index.ts +2 -0
- package/src/atoms/ProjectSettingsModal/preview.tsx +130 -0
- package/src/atoms/ProjectSettingsModal/switch.snippet.txt +8 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +750 -302
- package/src/atoms/PromptInputBar/preview.tsx +64 -64
- package/src/atoms/SettingsPageTemplate/SettingsPageTemplate.tsx +272 -0
- package/src/atoms/SettingsPageTemplate/index.ts +2 -0
- package/src/atoms/SettingsPageTemplate/preview.tsx +29 -0
- package/src/atoms/SidebarUpgradeBanner/SidebarUpgradeBanner.tsx +178 -0
- package/src/atoms/SidebarUpgradeBanner/index.ts +2 -0
- package/src/atoms/SidebarUpgradeBanner/preview.tsx +47 -0
- package/src/atoms/SkeletonChip/SkeletonChip.tsx +198 -0
- package/src/atoms/SkeletonChip/index.ts +2 -0
- package/src/atoms/SkeletonChip/preview.tsx +44 -0
- package/src/atoms/TemplateHeader/TemplateHeader.tsx +129 -0
- package/src/atoms/TemplateHeader/index.ts +2 -0
- package/src/atoms/TemplateHeader/preview.tsx +39 -0
- package/src/atoms/TemplateHero/TemplateHero.tsx +286 -0
- package/src/atoms/TemplateHero/index.ts +2 -0
- package/src/atoms/TemplateHero/preview.tsx +32 -0
- package/src/atoms/TemplateSummary/TemplateSummary.tsx +85 -0
- package/src/atoms/TemplateSummary/index.ts +2 -0
- package/src/atoms/TemplateSummary/preview.tsx +10 -0
- package/src/atoms/Toast/Toast.tsx +178 -0
- package/src/atoms/Toast/index.ts +2 -0
- package/src/atoms/Toast/preview.tsx +100 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +145 -67
- package/src/atoms/TopNavbar/preview.tsx +13 -7
- package/src/atoms/TopupModal/TopupModal.tsx +94 -0
- package/src/atoms/TopupModal/index.ts +2 -0
- package/src/atoms/TopupModal/preview.tsx +22 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +124 -43
- package/src/atoms/UpgradeCard/index.ts +1 -1
- package/src/atoms/UpgradeCard/preview.tsx +7 -14
- package/src/atoms/UpgradeModal/UpgradeModal.tsx +192 -0
- package/src/atoms/UpgradeModal/index.ts +2 -0
- package/src/atoms/UpgradeModal/preview.tsx +41 -0
- package/src/index.ts +23 -0
- package/src/tokens.css +45 -7
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useId } from "react";
|
|
1
|
+
import React, { useState, useId, useEffect, useRef } from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Input } from "../Input";
|
|
4
4
|
import { Icon } from "../Icon";
|
|
@@ -8,22 +8,24 @@ export interface AuthSignUpProps {
|
|
|
8
8
|
onGoogleAuth?: () => void;
|
|
9
9
|
onSwitchToLogin?: () => void;
|
|
10
10
|
loading?: boolean;
|
|
11
|
-
/** Server-side error (e.g. duplicate email).
|
|
11
|
+
/** Server-side error (e.g. duplicate email). Shown above the primary button. */
|
|
12
12
|
error?: string;
|
|
13
|
+
/** Optional legal copy (terms / privacy) rendered under the Log in line, inside the card. */
|
|
14
|
+
legalNote?: React.ReactNode;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
interface FieldErrors {
|
|
16
18
|
email?: string;
|
|
17
19
|
password?: string;
|
|
18
|
-
confirm?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
type Step = "email" | "password";
|
|
23
|
+
|
|
21
24
|
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
|
-
* Google's brand mark is a fixed four-
|
|
25
|
-
*
|
|
26
|
-
* rather than resolved via `<Icon name="google" />`.
|
|
27
|
+
* Google's brand mark is a fixed four-colour logo. The shared single-colour Icon
|
|
28
|
+
* atom cannot represent it, so it is drawn here with the google-* colour tokens.
|
|
27
29
|
*/
|
|
28
30
|
const GoogleLogo = () => (
|
|
29
31
|
<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" className="shrink-0">
|
|
@@ -47,163 +49,224 @@ const GoogleLogo = () => (
|
|
|
47
49
|
);
|
|
48
50
|
|
|
49
51
|
export const AuthSignUp = React.forwardRef<HTMLDivElement, AuthSignUpProps>(
|
|
50
|
-
({ onSignup, onGoogleAuth, onSwitchToLogin, loading = false, error }, ref) => {
|
|
52
|
+
({ onSignup, onGoogleAuth, onSwitchToLogin, loading = false, error, legalNote }, ref) => {
|
|
53
|
+
const [step, setStep] = useState<Step>("email");
|
|
51
54
|
const [email, setEmail] = useState("");
|
|
52
55
|
const [password, setPassword] = useState("");
|
|
53
|
-
const [confirm, setConfirm] = useState("");
|
|
54
56
|
const [showPassword, setShowPassword] = useState(false);
|
|
55
57
|
const [fieldErrors, setFieldErrors] = useState<FieldErrors>({});
|
|
58
|
+
const [entered, setEntered] = useState(true);
|
|
56
59
|
|
|
57
60
|
const emailId = useId();
|
|
58
61
|
const passwordId = useId();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const labelCls = "block text-body-sm font-weight-heading-sm text-ink mb-xs";
|
|
62
|
+
const helperId = useId();
|
|
62
63
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
errors.email = "Email is required.";
|
|
69
|
-
} else if (trimmedEmail.length > 320) {
|
|
70
|
-
errors.email = "Email must be 320 characters or fewer.";
|
|
71
|
-
} else if (!EMAIL_PATTERN.test(trimmedEmail)) {
|
|
72
|
-
errors.email = "Enter a valid email address.";
|
|
64
|
+
const isFirstRender = useRef(true);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (isFirstRender.current) {
|
|
67
|
+
isFirstRender.current = false;
|
|
68
|
+
return;
|
|
73
69
|
}
|
|
70
|
+
setEntered(false);
|
|
71
|
+
let raf2 = 0;
|
|
72
|
+
const raf1 = requestAnimationFrame(() => {
|
|
73
|
+
raf2 = requestAnimationFrame(() => setEntered(true));
|
|
74
|
+
});
|
|
75
|
+
document.getElementById(step === "email" ? emailId : passwordId)?.focus();
|
|
76
|
+
return () => {
|
|
77
|
+
cancelAnimationFrame(raf1);
|
|
78
|
+
cancelAnimationFrame(raf2);
|
|
79
|
+
};
|
|
80
|
+
}, [step, emailId, passwordId]);
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
errors.password = "Password is required.";
|
|
77
|
-
} else if (password.length < 8) {
|
|
78
|
-
errors.password = "Password must be at least 8 characters.";
|
|
79
|
-
} else if (password.length > 200) {
|
|
80
|
-
errors.password = "Password must be 200 characters or fewer.";
|
|
81
|
-
}
|
|
82
|
+
const labelCls = "block text-body-sm text-ink mb-xs";
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const validateEmail = (): string | undefined => {
|
|
85
|
+
const trimmedEmail = email.trim();
|
|
86
|
+
if (!trimmedEmail) return "Email is required.";
|
|
87
|
+
if (trimmedEmail.length > 320) return "Email must be 320 characters or fewer.";
|
|
88
|
+
if (!EMAIL_PATTERN.test(trimmedEmail)) return "Enter a valid email address.";
|
|
89
|
+
return undefined;
|
|
90
|
+
};
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
const validatePassword = (): string | undefined => {
|
|
93
|
+
if (!password) return "Password is required.";
|
|
94
|
+
if (password.length < 8) return "Password must be at least 8 characters.";
|
|
95
|
+
if (password.length > 200) return "Password must be 200 characters or fewer.";
|
|
96
|
+
return undefined;
|
|
90
97
|
};
|
|
91
98
|
|
|
92
99
|
const handleSubmit = (e: React.FormEvent) => {
|
|
93
100
|
e.preventDefault();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
if (step === "email") {
|
|
102
|
+
const emailError = validateEmail();
|
|
103
|
+
setFieldErrors({ email: emailError });
|
|
104
|
+
if (emailError) return;
|
|
105
|
+
setEmail((v) => v.trim());
|
|
106
|
+
setStep("password");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const passwordError = validatePassword();
|
|
110
|
+
setFieldErrors({ password: passwordError });
|
|
111
|
+
if (passwordError) return;
|
|
97
112
|
onSignup?.({ email: email.trim(), password });
|
|
98
113
|
};
|
|
99
114
|
|
|
115
|
+
const handleEdit = () => {
|
|
116
|
+
setFieldErrors({});
|
|
117
|
+
setStep("email");
|
|
118
|
+
};
|
|
119
|
+
|
|
100
120
|
const passwordToggle = (
|
|
101
|
-
<
|
|
121
|
+
<button
|
|
102
122
|
type="button"
|
|
103
|
-
variant="ghost"
|
|
104
|
-
size="sm"
|
|
105
123
|
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
106
124
|
aria-pressed={showPassword}
|
|
107
125
|
onClick={() => setShowPassword((v) => !v)}
|
|
108
|
-
className="pointer-events-auto
|
|
126
|
+
className="pointer-events-auto flex cursor-pointer items-center justify-center rounded-sm p-xxs text-muted transition duration-150 ease-out hover:text-ink active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50"
|
|
109
127
|
>
|
|
110
|
-
<Icon name={showPassword ? "eye-off-hide-password" : "eye-show-password"} size={
|
|
111
|
-
</
|
|
128
|
+
<Icon name={showPassword ? "eye-off-hide-password" : "eye-show-password"} size={16} />
|
|
129
|
+
</button>
|
|
112
130
|
);
|
|
113
131
|
|
|
132
|
+
const linkBtnCls =
|
|
133
|
+
"cursor-pointer rounded-sm text-primary transition duration-150 ease-out hover:text-primary-hover hover:underline active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50";
|
|
134
|
+
|
|
114
135
|
return (
|
|
115
|
-
/*
|
|
116
|
-
<div ref={ref} className="min-h-full w-full bg-surface p-xl
|
|
117
|
-
|
|
118
|
-
<div className="w-full max-w-3xl mx-auto flex justify-center">
|
|
136
|
+
/* Page background — soft step off the card, content centered */
|
|
137
|
+
<div ref={ref} className="flex min-h-full w-full flex-col justify-center bg-surface p-xl">
|
|
138
|
+
<div className="mx-auto flex w-full max-w-3xl justify-center">
|
|
119
139
|
{/* Signup card */}
|
|
120
|
-
<div
|
|
140
|
+
<div
|
|
141
|
+
style={{ width: "min(100%, 26rem)" }}
|
|
142
|
+
className="rounded-xl border border-hairline bg-canvas p-xl text-center shadow-card"
|
|
143
|
+
>
|
|
144
|
+
{/* Brand mark */}
|
|
145
|
+
<div
|
|
146
|
+
aria-hidden="true"
|
|
147
|
+
className="mx-auto mb-base flex h-14 w-14 items-center justify-center rounded-lg bg-primary-soft"
|
|
148
|
+
>
|
|
149
|
+
<span className="flex h-9 w-9 items-center justify-center rounded-md bg-primary text-body-md text-on-primary">
|
|
150
|
+
P
|
|
151
|
+
</span>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
121
154
|
{/* Heading */}
|
|
122
|
-
<h1 className="mb-xs text-heading-
|
|
123
|
-
|
|
124
|
-
</h1>
|
|
125
|
-
<p className="mb-xl text-body-md text-muted">
|
|
126
|
-
Start building amazing systems.
|
|
127
|
-
</p>
|
|
155
|
+
<h1 className="mb-xs text-heading-md text-ink">Create an account</h1>
|
|
156
|
+
<p className="mb-lg text-body-sm text-muted">Start building amazing systems.</p>
|
|
128
157
|
|
|
129
158
|
{/* OAuth */}
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
</div>
|
|
159
|
+
<Button
|
|
160
|
+
type="button"
|
|
161
|
+
variant="secondary"
|
|
162
|
+
size="md"
|
|
163
|
+
className="w-full justify-center"
|
|
164
|
+
onClick={onGoogleAuth}
|
|
165
|
+
disabled={loading}
|
|
166
|
+
>
|
|
167
|
+
<GoogleLogo />
|
|
168
|
+
Continue with Google
|
|
169
|
+
</Button>
|
|
142
170
|
|
|
143
171
|
{/* Divider */}
|
|
144
|
-
<div className="my-
|
|
172
|
+
<div className="my-lg flex items-center gap-base">
|
|
145
173
|
<div className="h-px flex-1 bg-hairline" />
|
|
146
|
-
<span className="text-
|
|
174
|
+
<span className="text-caption text-muted-soft">or</span>
|
|
147
175
|
<div className="h-px flex-1 bg-hairline" />
|
|
148
176
|
</div>
|
|
149
177
|
|
|
150
|
-
{/*
|
|
151
|
-
<
|
|
152
|
-
<div>
|
|
153
|
-
<
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
placeholder="you@company.com"
|
|
161
|
-
value={email}
|
|
162
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
163
|
-
leadingIcon={<Icon name="inbox-mail-tray" size={18} />}
|
|
164
|
-
error={fieldErrors.email}
|
|
165
|
-
fullWidth
|
|
166
|
-
/>
|
|
178
|
+
{/* Step indicator */}
|
|
179
|
+
<div className="mb-base flex items-center justify-between text-left">
|
|
180
|
+
<div className="grid w-24 grid-cols-2 gap-xs" aria-hidden="true">
|
|
181
|
+
<span className="h-sm rounded-full bg-primary" />
|
|
182
|
+
<span className="relative h-sm overflow-hidden rounded-full bg-surface-strong">
|
|
183
|
+
<span
|
|
184
|
+
className="absolute inset-0 origin-left rounded-full bg-primary transition duration-200 ease-out"
|
|
185
|
+
style={{ transform: step === "password" ? "scaleX(1)" : "scaleX(0)" }}
|
|
186
|
+
/>
|
|
187
|
+
</span>
|
|
167
188
|
</div>
|
|
189
|
+
<span aria-live="polite" className="text-caption text-muted">
|
|
190
|
+
Step {step === "email" ? 1 : 2} of 2
|
|
191
|
+
</span>
|
|
192
|
+
</div>
|
|
168
193
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
{/* Form */}
|
|
195
|
+
<form onSubmit={handleSubmit} noValidate className="space-y-base text-left">
|
|
196
|
+
<div
|
|
197
|
+
data-state={entered ? "entered" : "entering"}
|
|
198
|
+
className="space-y-base transition duration-200 ease-out data-[state=entered]:translate-y-0 data-[state=entered]:opacity-100 data-[state=entering]:translate-y-1 data-[state=entering]:opacity-0"
|
|
199
|
+
>
|
|
200
|
+
{step === "email" ? (
|
|
201
|
+
<div>
|
|
202
|
+
<label htmlFor={emailId} className={labelCls}>Email</label>
|
|
203
|
+
<Input
|
|
204
|
+
id={emailId}
|
|
205
|
+
type="email"
|
|
206
|
+
autoComplete="email"
|
|
207
|
+
required
|
|
208
|
+
size="md"
|
|
209
|
+
placeholder="you@company.com"
|
|
210
|
+
value={email}
|
|
211
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
212
|
+
leadingIcon={<Icon name="inbox-mail-tray" size={16} />}
|
|
213
|
+
error={fieldErrors.email}
|
|
214
|
+
fullWidth
|
|
215
|
+
/>
|
|
216
|
+
</div>
|
|
217
|
+
) : (
|
|
218
|
+
<>
|
|
219
|
+
<div>
|
|
220
|
+
<span className={labelCls}>Email</span>
|
|
221
|
+
<div className="flex h-10 w-full items-center justify-between gap-sm rounded-md border border-hairline bg-surface-soft px-md">
|
|
222
|
+
<span className="flex min-w-0 flex-1 items-center gap-sm">
|
|
223
|
+
<Icon name="circle-check" size={18} className="shrink-0 text-semantic-success" />
|
|
224
|
+
<span className="min-w-0 flex-1 truncate text-body-md text-ink">{email}</span>
|
|
225
|
+
</span>
|
|
226
|
+
<button
|
|
227
|
+
type="button"
|
|
228
|
+
onClick={handleEdit}
|
|
229
|
+
disabled={loading}
|
|
230
|
+
aria-label="Edit email address"
|
|
231
|
+
className={`shrink-0 px-xs text-body-sm ${linkBtnCls}`}
|
|
232
|
+
>
|
|
233
|
+
Edit
|
|
234
|
+
</button>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
186
237
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
238
|
+
<div>
|
|
239
|
+
<label htmlFor={passwordId} className={labelCls}>Password</label>
|
|
240
|
+
<Input
|
|
241
|
+
id={passwordId}
|
|
242
|
+
type={showPassword ? "text" : "password"}
|
|
243
|
+
required
|
|
244
|
+
size="md"
|
|
245
|
+
autoComplete="new-password"
|
|
246
|
+
placeholder="••••••••"
|
|
247
|
+
value={password}
|
|
248
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
249
|
+
leadingIcon={<Icon name="lock-padlock" size={16} />}
|
|
250
|
+
trailingIcon={passwordToggle}
|
|
251
|
+
error={fieldErrors.password}
|
|
252
|
+
aria-describedby={fieldErrors.password ? undefined : helperId}
|
|
253
|
+
fullWidth
|
|
254
|
+
/>
|
|
255
|
+
{!fieldErrors.password && (
|
|
256
|
+
<p id={helperId} className="mt-xs text-caption text-muted">
|
|
257
|
+
At least 8 characters
|
|
258
|
+
</p>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
</>
|
|
262
|
+
)}
|
|
203
263
|
</div>
|
|
204
264
|
|
|
205
265
|
{error && (
|
|
206
|
-
<p
|
|
266
|
+
<p
|
|
267
|
+
role="alert"
|
|
268
|
+
className="rounded-md bg-semantic-error-soft px-base py-sm text-body-sm text-semantic-error"
|
|
269
|
+
>
|
|
207
270
|
{error}
|
|
208
271
|
</p>
|
|
209
272
|
)}
|
|
@@ -211,7 +274,7 @@ export const AuthSignUp = React.forwardRef<HTMLDivElement, AuthSignUpProps>(
|
|
|
211
274
|
<Button
|
|
212
275
|
type="submit"
|
|
213
276
|
variant="primary"
|
|
214
|
-
size="
|
|
277
|
+
size="md"
|
|
215
278
|
loading={loading}
|
|
216
279
|
disabled={loading}
|
|
217
280
|
className="w-full border-none"
|
|
@@ -219,20 +282,37 @@ export const AuthSignUp = React.forwardRef<HTMLDivElement, AuthSignUpProps>(
|
|
|
219
282
|
backgroundImage: "linear-gradient(135deg, var(--color-primary), var(--color-primary-hover))",
|
|
220
283
|
}}
|
|
221
284
|
>
|
|
222
|
-
{loading ?
|
|
285
|
+
{loading ? (
|
|
286
|
+
"Please wait…"
|
|
287
|
+
) : step === "email" ? (
|
|
288
|
+
<>
|
|
289
|
+
Continue
|
|
290
|
+
<Icon name="arrow-right" size={16} />
|
|
291
|
+
</>
|
|
292
|
+
) : (
|
|
293
|
+
"Create account"
|
|
294
|
+
)}
|
|
223
295
|
</Button>
|
|
224
296
|
</form>
|
|
225
297
|
|
|
226
298
|
{/* Footer */}
|
|
227
|
-
<p className="mt-
|
|
299
|
+
<p className="mt-lg text-body-sm text-muted">
|
|
228
300
|
Already have an account?{" "}
|
|
229
|
-
<
|
|
301
|
+
<button
|
|
302
|
+
type="button"
|
|
230
303
|
onClick={onSwitchToLogin}
|
|
231
|
-
|
|
232
|
-
className=
|
|
304
|
+
disabled={loading}
|
|
305
|
+
className={`text-body-sm ${linkBtnCls}`}
|
|
306
|
+
>
|
|
233
307
|
Log in
|
|
234
|
-
</
|
|
308
|
+
</button>
|
|
235
309
|
</p>
|
|
310
|
+
|
|
311
|
+
{legalNote ? (
|
|
312
|
+
<div className="mt-lg border-t border-hairline-soft pt-base text-caption text-muted-soft [&_a]:cursor-pointer [&_a]:text-primary [&_a]:transition [&_a]:duration-150 [&_a]:ease-out [&_a]:hover:underline">
|
|
313
|
+
{legalNote}
|
|
314
|
+
</div>
|
|
315
|
+
) : null}
|
|
236
316
|
</div>
|
|
237
317
|
</div>
|
|
238
318
|
</div>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { AuthSignUp } from "./AuthSignUp";
|
|
3
3
|
|
|
4
|
+
const linkCls =
|
|
5
|
+
"cursor-pointer rounded-sm text-primary transition duration-150 ease-out hover:underline active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
6
|
+
|
|
4
7
|
export default function AuthSignUpPreview() {
|
|
5
8
|
const [loading, setLoading] = useState(false);
|
|
6
9
|
|
|
@@ -16,6 +19,13 @@ export default function AuthSignUpPreview() {
|
|
|
16
19
|
onSignup={handleSignup}
|
|
17
20
|
onGoogleAuth={() => alert("Continue with Google")}
|
|
18
21
|
onSwitchToLogin={() => alert("Navigate to log in")}
|
|
22
|
+
legalNote={
|
|
23
|
+
<>
|
|
24
|
+
By continuing you agree to the{" "}
|
|
25
|
+
<a href="#terms" className={linkCls}>Terms</a> and{" "}
|
|
26
|
+
<a href="#privacy" className={linkCls}>Privacy Policy</a>
|
|
27
|
+
</>
|
|
28
|
+
}
|
|
19
29
|
/>
|
|
20
30
|
</div>
|
|
21
31
|
);
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
|
|
5
|
+
export type BottomSheetSize = "half" | "auto" | "full";
|
|
6
|
+
|
|
7
|
+
export interface BottomSheetProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onOpenChange: (open: boolean) => void;
|
|
10
|
+
title: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* "half" = 50% of the relative parent; "auto" hugs content (max 90% of parent);
|
|
14
|
+
* "full" = ~92% of the relative parent with a scrollable body, for tall content.
|
|
15
|
+
*/
|
|
16
|
+
size?: BottomSheetSize;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Fraction of the sheet height a handle drag must travel downward to dismiss. */
|
|
21
|
+
const DISMISS_RATIO = 0.3;
|
|
22
|
+
|
|
23
|
+
/** Fallback (ms) in case the close `transitionend` never fires (e.g. reduced motion). */
|
|
24
|
+
const CLOSE_FALLBACK_MS = 260;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Non-zero translateZ keeps the transform from collapsing to the identity matrix,
|
|
28
|
+
* which would drop the compositor layer and make the open animation pop into place.
|
|
29
|
+
*/
|
|
30
|
+
const LAYER_Z = "1px";
|
|
31
|
+
|
|
32
|
+
const sizeClasses: Record<BottomSheetSize, string> = {
|
|
33
|
+
half: "h-1/2",
|
|
34
|
+
auto: "max-h-[90%]",
|
|
35
|
+
full: "h-11/12",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** half/full: definite height, body fills the rest and scrolls. auto: body hugs its content. */
|
|
39
|
+
const bodyClasses: Record<BottomSheetSize, string> = {
|
|
40
|
+
half: "min-h-0 flex-1 overflow-y-auto px-base pb-base",
|
|
41
|
+
auto: "min-h-0 shrink overflow-y-auto px-base pb-base",
|
|
42
|
+
full: "min-h-0 flex-1 overflow-y-auto px-base pb-base",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const BottomSheet = React.forwardRef<HTMLDivElement, BottomSheetProps>(
|
|
46
|
+
({ open, onOpenChange, title, children, size = "auto", className }, ref) => {
|
|
47
|
+
const titleId = React.useId();
|
|
48
|
+
const sheetRef = React.useRef<HTMLDivElement>(null);
|
|
49
|
+
const dragStartY = React.useRef<number | null>(null);
|
|
50
|
+
const [dragY, setDragY] = React.useState(0);
|
|
51
|
+
const [dragging, setDragging] = React.useState(false);
|
|
52
|
+
|
|
53
|
+
// `shown` drives the transform; `inertOn` is toggled separately so it never
|
|
54
|
+
// flips in the same frame as the transform.
|
|
55
|
+
const [shown, setShown] = React.useState(open);
|
|
56
|
+
const [inertOn, setInertOn] = React.useState(!open);
|
|
57
|
+
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (open) {
|
|
60
|
+
// 1) clear inert first, 2) start the slide two frames later.
|
|
61
|
+
setInertOn(false);
|
|
62
|
+
let raf2 = 0;
|
|
63
|
+
const raf1 = requestAnimationFrame(() => {
|
|
64
|
+
raf2 = requestAnimationFrame(() => setShown(true));
|
|
65
|
+
});
|
|
66
|
+
return () => {
|
|
67
|
+
cancelAnimationFrame(raf1);
|
|
68
|
+
cancelAnimationFrame(raf2);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Close: slide out now, set inert only after the transition ends.
|
|
72
|
+
setShown(false);
|
|
73
|
+
const timer = window.setTimeout(() => setInertOn(true), CLOSE_FALLBACK_MS);
|
|
74
|
+
return () => window.clearTimeout(timer);
|
|
75
|
+
}, [open]);
|
|
76
|
+
|
|
77
|
+
// Escape closes while open.
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
if (!open) return;
|
|
80
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
81
|
+
if (event.key === "Escape") onOpenChange(false);
|
|
82
|
+
};
|
|
83
|
+
document.addEventListener("keydown", onKeyDown);
|
|
84
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
85
|
+
}, [open, onOpenChange]);
|
|
86
|
+
|
|
87
|
+
// Move focus into the sheet once it is no longer inert.
|
|
88
|
+
React.useEffect(() => {
|
|
89
|
+
if (open && !inertOn) sheetRef.current?.focus({ preventScroll: true });
|
|
90
|
+
}, [open, inertOn]);
|
|
91
|
+
|
|
92
|
+
const endDrag = (event: React.PointerEvent<HTMLDivElement>, cancelled: boolean) => {
|
|
93
|
+
if (dragStartY.current === null) return;
|
|
94
|
+
const distance = event.clientY - dragStartY.current;
|
|
95
|
+
const height = sheetRef.current?.offsetHeight ?? 0;
|
|
96
|
+
dragStartY.current = null;
|
|
97
|
+
setDragging(false);
|
|
98
|
+
setDragY(0);
|
|
99
|
+
if (!cancelled && height > 0 && distance > height * DISMISS_RATIO) {
|
|
100
|
+
onOpenChange(false);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const state = open ? "open" : "closed";
|
|
105
|
+
|
|
106
|
+
// translate3d with a non-zero Z so the layer is never dropped at rest.
|
|
107
|
+
const sheetTransform = !open || !shown
|
|
108
|
+
? `translate3d(0, 100%, ${LAYER_Z})`
|
|
109
|
+
: dragging && dragY > 0
|
|
110
|
+
? `translate3d(0, ${dragY}px, ${LAYER_Z})`
|
|
111
|
+
: `translate3d(0, 0, ${LAYER_Z})`;
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
ref={ref}
|
|
116
|
+
data-state={state}
|
|
117
|
+
className={[
|
|
118
|
+
"absolute inset-0 overflow-hidden",
|
|
119
|
+
open ? "pointer-events-auto" : "pointer-events-none",
|
|
120
|
+
].join(" ")}
|
|
121
|
+
style={{ zIndex: open ? "var(--z-modal, 1200)" : undefined }}
|
|
122
|
+
>
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
aria-label="Close"
|
|
126
|
+
tabIndex={open ? 0 : -1}
|
|
127
|
+
onClick={() => onOpenChange(false)}
|
|
128
|
+
data-state={state}
|
|
129
|
+
className="absolute inset-0 cursor-pointer bg-scrim/60 transition-opacity duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue data-[state=closed]:pointer-events-none data-[state=closed]:opacity-0 data-[state=open]:opacity-100"
|
|
130
|
+
/>
|
|
131
|
+
|
|
132
|
+
<div
|
|
133
|
+
ref={sheetRef}
|
|
134
|
+
role="dialog"
|
|
135
|
+
aria-modal="true"
|
|
136
|
+
aria-labelledby={titleId}
|
|
137
|
+
aria-hidden={!open}
|
|
138
|
+
inert={inertOn}
|
|
139
|
+
tabIndex={-1}
|
|
140
|
+
data-state={state}
|
|
141
|
+
onTransitionEnd={(event) => {
|
|
142
|
+
if (event.target !== event.currentTarget) return;
|
|
143
|
+
if (event.propertyName === "transform" && !open) setInertOn(true);
|
|
144
|
+
}}
|
|
145
|
+
style={{
|
|
146
|
+
transform: sheetTransform,
|
|
147
|
+
transition: dragging ? "none" : "transform 200ms ease-out",
|
|
148
|
+
willChange: "transform",
|
|
149
|
+
}}
|
|
150
|
+
className={[
|
|
151
|
+
"absolute inset-x-0 bottom-0 flex min-h-0 flex-col overflow-hidden rounded-xl rounded-b-none bg-canvas shadow-card focus-visible:outline-none",
|
|
152
|
+
"data-[state=closed]:pointer-events-none",
|
|
153
|
+
sizeClasses[size],
|
|
154
|
+
className,
|
|
155
|
+
]
|
|
156
|
+
.filter(Boolean)
|
|
157
|
+
.join(" ")}
|
|
158
|
+
>
|
|
159
|
+
<div
|
|
160
|
+
onPointerDown={(event) => {
|
|
161
|
+
dragStartY.current = event.clientY;
|
|
162
|
+
setDragging(true);
|
|
163
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
164
|
+
}}
|
|
165
|
+
onPointerMove={(event) => {
|
|
166
|
+
if (dragStartY.current === null) return;
|
|
167
|
+
setDragY(Math.max(0, event.clientY - dragStartY.current));
|
|
168
|
+
}}
|
|
169
|
+
onPointerUp={(event) => endDrag(event, false)}
|
|
170
|
+
onPointerCancel={(event) => endDrag(event, true)}
|
|
171
|
+
className="flex w-full shrink-0 cursor-grab touch-none justify-center pt-sm pb-xs active:cursor-grabbing"
|
|
172
|
+
>
|
|
173
|
+
<span aria-hidden="true" className="h-xs w-xxl rounded-xs bg-hairline-strong" />
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div className="flex shrink-0 items-center gap-sm px-base pb-sm">
|
|
177
|
+
<h2 id={titleId} className="text-heading-sm text-ink">
|
|
178
|
+
{title}
|
|
179
|
+
</h2>
|
|
180
|
+
<span className="flex-1" />
|
|
181
|
+
<Button
|
|
182
|
+
type="button"
|
|
183
|
+
variant="ghost"
|
|
184
|
+
size="sm"
|
|
185
|
+
aria-label="Close"
|
|
186
|
+
onClick={() => onOpenChange(false)}
|
|
187
|
+
>
|
|
188
|
+
<Icon name="close" className="size-4" aria-hidden="true" />
|
|
189
|
+
</Button>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div className={bodyClasses[size]}>{children}</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
BottomSheet.displayName = "BottomSheet";
|