@designa8/vibedesign-v6 1.15.3 → 1.20.12
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/index.cjs +3232 -1994
- package/dist/index.js +3242 -2004
- package/dist/styles.css +266 -28
- package/package.json +51 -1
- package/src/atoms/AppLayout/AppLayout.tsx +401 -395
- package/src/atoms/AppLayout/preview.tsx +29 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +182 -94
- package/src/atoms/AppSidebar/preview.tsx +20 -59
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +27 -73
- package/src/atoms/AppSidebarMobile/preview.tsx +18 -18
- package/src/atoms/AuthLogin/AuthLogin.tsx +200 -0
- package/src/atoms/AuthLogin/index.ts +2 -0
- package/src/atoms/AuthLogin/preview.tsx +22 -0
- package/src/atoms/AuthScreen/AuthScreen.tsx +7 -7
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +243 -0
- package/src/atoms/AuthSignUp/index.ts +2 -0
- package/src/atoms/AuthSignUp/preview.tsx +22 -0
- package/src/atoms/BillingToggle/BillingToggle.tsx +65 -0
- package/src/atoms/BillingToggle/index.ts +2 -0
- package/src/atoms/BillingToggle/preview.tsx +23 -0
- package/src/atoms/Button/Button.tsx +33 -17
- package/src/atoms/Button/preview.tsx +16 -0
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +370 -0
- package/src/atoms/ChatHistorySidebar/index.ts +2 -0
- package/src/atoms/ChatHistorySidebar/preview.tsx +60 -0
- package/src/atoms/ChatScreen/ChatScreen.tsx +331 -134
- package/src/atoms/ChatScreen/preview.tsx +123 -2
- package/src/atoms/Checkbox/Checkbox.tsx +89 -0
- package/src/atoms/Checkbox/index.ts +2 -0
- package/src/atoms/Checkbox/preview.tsx +60 -0
- package/src/atoms/Dropdown/Dropdown.tsx +195 -0
- package/src/atoms/Dropdown/index.ts +2 -0
- package/src/atoms/Dropdown/preview.tsx +56 -0
- package/src/atoms/FaqAccordionItem/FaqAccordionItem.tsx +60 -0
- package/src/atoms/FaqAccordionItem/index.ts +2 -0
- package/src/atoms/FaqAccordionItem/preview.tsx +26 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +8 -22
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +20 -33
- package/src/atoms/HomePageTemplate/preview.tsx +2 -2
- package/src/atoms/Icon/Icon.tsx +7 -5
- package/src/atoms/Icon/icons.data.ts +51 -0
- package/src/atoms/Input/Input.tsx +17 -9
- package/src/atoms/Input/preview.tsx +24 -25
- package/src/atoms/Menu/Menu.tsx +320 -0
- package/src/atoms/Menu/index.ts +2 -0
- package/src/atoms/Menu/preview.tsx +63 -0
- package/src/atoms/Modal/Modal.tsx +43 -37
- package/src/atoms/Modal/preview.tsx +13 -0
- package/src/atoms/NavItem/NavItem.tsx +33 -45
- package/src/atoms/NavItem/preview.tsx +21 -26
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +144 -192
- package/src/atoms/PreviewToolbar/preview.tsx +24 -4
- package/src/atoms/PricingCard/PricingCard.tsx +164 -0
- package/src/atoms/PricingCard/index.ts +2 -0
- package/src/atoms/PricingCard/preview.tsx +45 -0
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +219 -0
- package/src/atoms/PricingPageTemplate/index.ts +2 -0
- package/src/atoms/PricingPageTemplate/preview.tsx +10 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +117 -158
- package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +41 -167
- package/src/index.ts +10 -0
- package/src/tokens.css +5 -0
|
@@ -1,75 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import { Button } from "../Button";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
4
5
|
import { NavItem } from "../NavItem";
|
|
5
6
|
import { WorkspaceMenu } from "../WorkspaceMenu";
|
|
6
7
|
import { UpgradeCard } from "../UpgradeCard";
|
|
7
8
|
import type { NavItemSubItem } from "../NavItem";
|
|
8
9
|
|
|
9
|
-
/* ─── Icons ─────────────────────────────────────────────────────────────── */
|
|
10
|
-
|
|
11
|
-
const LogoIcon = () => (
|
|
12
|
-
<svg width="28" height="28" viewBox="0 0 48 48" fill="none" aria-hidden="true">
|
|
13
|
-
<path d="M12 36C12 36 8 28 16 22C20 19 26 20 26 20C26 20 22 26 18 30C16 32 12 36 12 36Z" style={{ fill: "var(--color-logo-orange)" }} />
|
|
14
|
-
<path d="M24 8C24 8 36 12 36 24C36 30 32 36 26 38C26 38 28 30 26 24C25 20 24 8 24 8Z" style={{ fill: "var(--color-logo-violet)" }} />
|
|
15
|
-
<path d="M12 36C12 36 16 24 24 20C28 18 36 20 36 20C36 20 30 28 26 32C22 36 12 36 12 36Z" style={{ fill: "var(--color-logo-pink)", opacity: 0.7 }} />
|
|
16
|
-
</svg>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const HamburgerIcon = () => (
|
|
20
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true" style={{ width: "20px", height: "20px" }}>
|
|
21
|
-
<line x1="3" y1="6" x2="21" y2="6" />
|
|
22
|
-
<line x1="3" y1="12" x2="21" y2="12" />
|
|
23
|
-
<line x1="3" y1="18" x2="21" y2="18" />
|
|
24
|
-
</svg>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const CloseIcon = () => (
|
|
28
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true" style={{ width: "20px", height: "20px" }}>
|
|
29
|
-
<line x1="18" y1="6" x2="6" y2="18" />
|
|
30
|
-
<line x1="6" y1="6" x2="18" y2="18" />
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const GiftIcon = () => (
|
|
35
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "20px", height: "20px" }} aria-hidden="true">
|
|
36
|
-
<polyline points="20 12 20 22 4 22 4 12" />
|
|
37
|
-
<rect x="2" y="7" width="20" height="5" />
|
|
38
|
-
<line x1="12" y1="22" x2="12" y2="7" />
|
|
39
|
-
<path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z" />
|
|
40
|
-
<path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z" />
|
|
41
|
-
</svg>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const InboxIcon = () => (
|
|
45
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
46
|
-
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
|
|
47
|
-
<path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
/** Sun icon — shown when darkMode is true (click to switch to light) */
|
|
52
|
-
const SunIcon = () => (
|
|
53
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
54
|
-
<circle cx="12" cy="12" r="5" />
|
|
55
|
-
<line x1="12" y1="1" x2="12" y2="3" />
|
|
56
|
-
<line x1="12" y1="21" x2="12" y2="23" />
|
|
57
|
-
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
|
|
58
|
-
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
|
|
59
|
-
<line x1="1" y1="12" x2="3" y2="12" />
|
|
60
|
-
<line x1="21" y1="12" x2="23" y2="12" />
|
|
61
|
-
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
|
|
62
|
-
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
|
|
63
|
-
</svg>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
/** Moon icon — shown when darkMode is false (click to switch to dark) */
|
|
67
|
-
const MoonIcon = () => (
|
|
68
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
69
|
-
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
70
|
-
</svg>
|
|
71
|
-
);
|
|
72
|
-
|
|
73
10
|
/* ─── Types ─────────────────────────────────────────────────────────────── */
|
|
74
11
|
|
|
75
12
|
export interface MobileNavSubItem {
|
|
@@ -83,6 +20,8 @@ export interface MobileNavEntry {
|
|
|
83
20
|
label: string;
|
|
84
21
|
icon?: React.ReactNode;
|
|
85
22
|
subItems?: MobileNavSubItem[];
|
|
23
|
+
/** When true and the entry has subItems, the group is always expanded and cannot be collapsed. */
|
|
24
|
+
alwaysExpanded?: boolean;
|
|
86
25
|
}
|
|
87
26
|
|
|
88
27
|
export interface AppSidebarMobileProps {
|
|
@@ -103,6 +42,8 @@ export interface AppSidebarMobileProps {
|
|
|
103
42
|
onDarkModeToggle?: () => void;
|
|
104
43
|
open?: boolean;
|
|
105
44
|
onOpenChange?: (open: boolean) => void;
|
|
45
|
+
/** Entry ids that should be expanded on first render (seeds internal expanded state). */
|
|
46
|
+
defaultExpandedIds?: string[];
|
|
106
47
|
className?: string;
|
|
107
48
|
}
|
|
108
49
|
|
|
@@ -126,6 +67,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
126
67
|
onDarkModeToggle,
|
|
127
68
|
open: openProp,
|
|
128
69
|
onOpenChange,
|
|
70
|
+
defaultExpandedIds,
|
|
129
71
|
className,
|
|
130
72
|
},
|
|
131
73
|
ref,
|
|
@@ -140,7 +82,9 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
140
82
|
onOpenChange?.(next);
|
|
141
83
|
};
|
|
142
84
|
|
|
143
|
-
const [expandedIds, setExpandedIds] = React.useState<Set<string>>(
|
|
85
|
+
const [expandedIds, setExpandedIds] = React.useState<Set<string>>(
|
|
86
|
+
() => new Set(defaultExpandedIds ?? []),
|
|
87
|
+
);
|
|
144
88
|
const toggleExpanded = (id: string) => {
|
|
145
89
|
setExpandedIds((prev) => {
|
|
146
90
|
const next = new Set(prev);
|
|
@@ -225,7 +169,15 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
225
169
|
style={{ backgroundColor: "var(--color-canvas)" }}
|
|
226
170
|
>
|
|
227
171
|
<div className="flex items-center gap-sm">
|
|
228
|
-
<
|
|
172
|
+
<span
|
|
173
|
+
className="flex-shrink-0 rounded-full"
|
|
174
|
+
style={{
|
|
175
|
+
width: "28px",
|
|
176
|
+
height: "28px",
|
|
177
|
+
background: "linear-gradient(135deg, var(--color-logo-orange), var(--color-logo-violet))",
|
|
178
|
+
}}
|
|
179
|
+
aria-hidden="true"
|
|
180
|
+
/>
|
|
229
181
|
<span className="text-body-sm font-weight-heading-sm text-ink truncate">{brandName}</span>
|
|
230
182
|
</div>
|
|
231
183
|
<Button
|
|
@@ -235,7 +187,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
235
187
|
onClick={() => setOpen(false)}
|
|
236
188
|
className="!p-xs !rounded-md"
|
|
237
189
|
>
|
|
238
|
-
<
|
|
190
|
+
<Icon name="close" />
|
|
239
191
|
</Button>
|
|
240
192
|
</div>
|
|
241
193
|
|
|
@@ -261,7 +213,8 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
261
213
|
{entries.map((entry) => {
|
|
262
214
|
const isActive = activeId === entry.id;
|
|
263
215
|
const hasSubItems = !!(entry.subItems?.length);
|
|
264
|
-
const
|
|
216
|
+
const isAlwaysExpanded = hasSubItems && !!entry.alwaysExpanded;
|
|
217
|
+
const isExpanded = isAlwaysExpanded ? true : expandedIds.has(entry.id);
|
|
265
218
|
|
|
266
219
|
const mappedSubItems: NavItemSubItem[] | undefined = hasSubItems
|
|
267
220
|
? entry.subItems!.map((sub) => ({
|
|
@@ -281,8 +234,9 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
281
234
|
label={entry.label}
|
|
282
235
|
active={isActive}
|
|
283
236
|
subItems={mappedSubItems}
|
|
237
|
+
alwaysExpanded={isAlwaysExpanded}
|
|
284
238
|
expanded={hasSubItems ? isExpanded : undefined}
|
|
285
|
-
onExpandToggle={hasSubItems ? () => toggleExpanded(entry.id) : undefined}
|
|
239
|
+
onExpandToggle={hasSubItems && !isAlwaysExpanded ? () => toggleExpanded(entry.id) : undefined}
|
|
286
240
|
onClick={(e) => {
|
|
287
241
|
onSelect?.(entry.id);
|
|
288
242
|
if (!hasSubItems) setOpen(false);
|
|
@@ -309,7 +263,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
309
263
|
className="flex-shrink-0 flex items-center justify-center rounded-full bg-surface-strong"
|
|
310
264
|
style={{ width: "36px", height: "36px" }}
|
|
311
265
|
>
|
|
312
|
-
<
|
|
266
|
+
<Icon name="gift-present" />
|
|
313
267
|
</span>
|
|
314
268
|
</div>
|
|
315
269
|
)}
|
|
@@ -342,7 +296,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
342
296
|
onClick={onDarkModeToggle}
|
|
343
297
|
className="!p-xs !rounded-sm"
|
|
344
298
|
>
|
|
345
|
-
{darkMode ?
|
|
299
|
+
<Icon name={darkMode ? "sun-light-mode" : "moon-dark-mode"} />
|
|
346
300
|
</Button>
|
|
347
301
|
)}
|
|
348
302
|
|
|
@@ -355,7 +309,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
355
309
|
onClick={onInboxClick}
|
|
356
310
|
className="!p-xs !rounded-sm relative"
|
|
357
311
|
>
|
|
358
|
-
<
|
|
312
|
+
<Icon name="inbox-mail-tray" />
|
|
359
313
|
<span
|
|
360
314
|
className="absolute rounded-full bg-semantic-error"
|
|
361
315
|
aria-label="New notifications"
|
|
@@ -383,7 +337,7 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
|
|
|
383
337
|
onClick={() => setOpen(true)}
|
|
384
338
|
className="!p-xs !rounded-md"
|
|
385
339
|
>
|
|
386
|
-
<
|
|
340
|
+
<Icon name="hamburger-menu" />
|
|
387
341
|
</Button>
|
|
388
342
|
</div>
|
|
389
343
|
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppSidebarMobile } from "./AppSidebarMobile";
|
|
3
|
-
|
|
4
|
-
const HomeIcon = () => (
|
|
5
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
6
|
-
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
|
7
|
-
<polyline points="9 22 9 12 15 12 15 22" />
|
|
8
|
-
</svg>
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const FolderIcon = () => (
|
|
12
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }} aria-hidden="true">
|
|
13
|
-
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />
|
|
14
|
-
</svg>
|
|
15
|
-
);
|
|
3
|
+
import { Icon } from "../Icon";
|
|
16
4
|
|
|
17
5
|
const ENTRIES = [
|
|
18
|
-
{ id: "home", label: "Home", icon: <
|
|
6
|
+
{ id: "home", label: "Home", icon: <Icon name="home" /> },
|
|
19
7
|
{
|
|
20
8
|
id: "projects",
|
|
21
9
|
label: "All projects",
|
|
22
|
-
icon: <
|
|
10
|
+
icon: <Icon name="folder" />,
|
|
23
11
|
subItems: [
|
|
24
12
|
{ id: "p1", label: "Design system" },
|
|
25
13
|
{ id: "p2", label: "Landing page" },
|
|
26
14
|
{ id: "p3", label: "Dashboard" },
|
|
27
15
|
],
|
|
28
16
|
},
|
|
17
|
+
{
|
|
18
|
+
id: "pinned",
|
|
19
|
+
label: "Pinned",
|
|
20
|
+
icon: <Icon name="star" />,
|
|
21
|
+
alwaysExpanded: true,
|
|
22
|
+
subItems: [
|
|
23
|
+
{ id: "pin1", label: "Weekly report" },
|
|
24
|
+
{ id: "pin2", label: "Roadmap" },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
29
27
|
];
|
|
30
28
|
|
|
31
29
|
export default function Preview() {
|
|
@@ -53,12 +51,12 @@ export default function Preview() {
|
|
|
53
51
|
/>
|
|
54
52
|
</div>
|
|
55
53
|
|
|
56
|
-
{/* With dark mode toggle */}
|
|
54
|
+
{/* With dark mode toggle + always-expanded "Pinned" group */}
|
|
57
55
|
<div className="rounded-xl bg-surface border border-hairline p-lg flex items-center justify-between gap-md">
|
|
58
56
|
<div>
|
|
59
|
-
<p className="text-body-sm font-weight-heading-sm text-ink mb-xs">
|
|
57
|
+
<p className="text-body-sm font-weight-heading-sm text-ink mb-xs">Always-expanded group + dark-mode toggle</p>
|
|
60
58
|
<p className="text-caption text-muted">
|
|
61
|
-
|
|
59
|
+
"Pinned" is always expanded and can't be collapsed; "All projects" still toggles via chevron.
|
|
62
60
|
Currently: <strong>{isDark ? "dark" : "light"}</strong>
|
|
63
61
|
</p>
|
|
64
62
|
</div>
|
|
@@ -67,6 +65,7 @@ export default function Preview() {
|
|
|
67
65
|
entries={ENTRIES}
|
|
68
66
|
activeId={activeId}
|
|
69
67
|
onSelect={setActiveId}
|
|
68
|
+
defaultExpandedIds={["projects"]}
|
|
70
69
|
workspaceName="Hello Designer"
|
|
71
70
|
showShareCard
|
|
72
71
|
showUpgradeCard
|
|
@@ -89,6 +88,7 @@ export default function Preview() {
|
|
|
89
88
|
entries={ENTRIES}
|
|
90
89
|
activeId={activeId}
|
|
91
90
|
onSelect={setActiveId}
|
|
91
|
+
defaultExpandedIds={["projects"]}
|
|
92
92
|
workspaceName="Hello Designer"
|
|
93
93
|
showShareCard
|
|
94
94
|
showUpgradeCard
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useState, useId } from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Input } from "../Input";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
|
|
6
|
+
export interface AuthLoginProps {
|
|
7
|
+
onLogin?: (values: { email: string; password: string }) => void;
|
|
8
|
+
onGoogleAuth?: () => void;
|
|
9
|
+
onSwitchToSignup?: () => void;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
/** Server-side error (e.g. invalid credentials). Rendered as a form-level alert above the submit button. */
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
16
|
+
|
|
17
|
+
export const AuthLogin = React.forwardRef<HTMLDivElement, AuthLoginProps>(
|
|
18
|
+
({ onLogin, onGoogleAuth, onSwitchToSignup, loading = false, error }, ref) => {
|
|
19
|
+
const [email, setEmail] = useState("");
|
|
20
|
+
const [password, setPassword] = useState("");
|
|
21
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
22
|
+
const [emailError, setEmailError] = useState<string | null>(null);
|
|
23
|
+
const [passwordError, setPasswordError] = useState<string | null>(null);
|
|
24
|
+
|
|
25
|
+
const emailId = useId();
|
|
26
|
+
const passwordId = useId();
|
|
27
|
+
|
|
28
|
+
const labelCls = "block text-body-sm font-weight-heading-sm text-ink mb-xs";
|
|
29
|
+
|
|
30
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
|
|
33
|
+
const trimmedEmail = email.trim();
|
|
34
|
+
let hasError = false;
|
|
35
|
+
let nextEmailError: string | null = null;
|
|
36
|
+
let nextPasswordError: string | null = null;
|
|
37
|
+
|
|
38
|
+
if (!trimmedEmail) {
|
|
39
|
+
nextEmailError = "Email is required.";
|
|
40
|
+
hasError = true;
|
|
41
|
+
} else if (trimmedEmail.length > 320 || !EMAIL_REGEX.test(trimmedEmail)) {
|
|
42
|
+
nextEmailError = "Enter a valid email address.";
|
|
43
|
+
hasError = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!password) {
|
|
47
|
+
nextPasswordError = "Password is required.";
|
|
48
|
+
hasError = true;
|
|
49
|
+
} else if (password.length > 200) {
|
|
50
|
+
nextPasswordError = "Password must be 200 characters or fewer.";
|
|
51
|
+
hasError = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setEmailError(nextEmailError);
|
|
55
|
+
setPasswordError(nextPasswordError);
|
|
56
|
+
|
|
57
|
+
if (hasError) return;
|
|
58
|
+
onLogin?.({ email: trimmedEmail, password });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
/* Full-width page background — fills the height of its column, content vertically centered */
|
|
63
|
+
<div ref={ref} className="w-full min-h-full bg-surface p-xl flex flex-col justify-center">
|
|
64
|
+
{/* Center column — limits content width on ultra-wide screens */}
|
|
65
|
+
<div className="w-full max-w-3xl mx-auto flex justify-center">
|
|
66
|
+
{/* Login card */}
|
|
67
|
+
<div style={{ width: "min(100%, 24rem)" }} className="text-center">
|
|
68
|
+
{/* Heading */}
|
|
69
|
+
<h1 className="mb-xs text-heading-lg text-ink font-weight-heading-lg">
|
|
70
|
+
Welcome back
|
|
71
|
+
</h1>
|
|
72
|
+
<p className="mb-xl text-body-md text-muted">
|
|
73
|
+
Sign in to continue building amazing systems.
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
{/* OAuth */}
|
|
77
|
+
<div className="space-y-sm text-left">
|
|
78
|
+
<Button
|
|
79
|
+
type="button"
|
|
80
|
+
variant="secondary"
|
|
81
|
+
size="lg"
|
|
82
|
+
className="w-full justify-center"
|
|
83
|
+
onClick={onGoogleAuth}
|
|
84
|
+
>
|
|
85
|
+
<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" className="shrink-0">
|
|
86
|
+
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="var(--color-google-blue)" />
|
|
87
|
+
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="var(--color-google-green)" />
|
|
88
|
+
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z" fill="var(--color-google-yellow)" />
|
|
89
|
+
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="var(--color-google-red)" />
|
|
90
|
+
</svg>
|
|
91
|
+
Continue with Google
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{/* Divider */}
|
|
96
|
+
<div className="my-xl flex items-center gap-base">
|
|
97
|
+
<div className="h-px flex-1 bg-hairline" />
|
|
98
|
+
<span className="text-body-sm text-muted-soft">or</span>
|
|
99
|
+
<div className="h-px flex-1 bg-hairline" />
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* Form */}
|
|
103
|
+
<form onSubmit={handleSubmit} noValidate className="space-y-base text-left">
|
|
104
|
+
<div>
|
|
105
|
+
<label htmlFor={emailId} className={labelCls}>Email</label>
|
|
106
|
+
<Input
|
|
107
|
+
id={emailId}
|
|
108
|
+
type="email"
|
|
109
|
+
autoComplete="email"
|
|
110
|
+
required
|
|
111
|
+
size="lg"
|
|
112
|
+
placeholder="you@company.com"
|
|
113
|
+
value={email}
|
|
114
|
+
onChange={(e) => {
|
|
115
|
+
setEmail(e.target.value);
|
|
116
|
+
if (emailError) setEmailError(null);
|
|
117
|
+
}}
|
|
118
|
+
error={emailError ?? undefined}
|
|
119
|
+
leadingIcon={<Icon name="inbox-mail-tray" size={18} />}
|
|
120
|
+
fullWidth
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div>
|
|
125
|
+
<div className="mb-xs flex items-center justify-between">
|
|
126
|
+
<label htmlFor={passwordId} className={labelCls + " mb-0"}>Password</label>
|
|
127
|
+
<a href="#" className="text-body-sm text-primary hover:underline">
|
|
128
|
+
Forgot password?
|
|
129
|
+
</a>
|
|
130
|
+
</div>
|
|
131
|
+
<Input
|
|
132
|
+
id={passwordId}
|
|
133
|
+
type={showPassword ? "text" : "password"}
|
|
134
|
+
required
|
|
135
|
+
size="lg"
|
|
136
|
+
autoComplete="current-password"
|
|
137
|
+
placeholder="••••••••"
|
|
138
|
+
value={password}
|
|
139
|
+
onChange={(e) => {
|
|
140
|
+
setPassword(e.target.value);
|
|
141
|
+
if (passwordError) setPasswordError(null);
|
|
142
|
+
}}
|
|
143
|
+
error={passwordError ?? undefined}
|
|
144
|
+
leadingIcon={<Icon name="lock-padlock" size={18} />}
|
|
145
|
+
trailingIcon={
|
|
146
|
+
<Button
|
|
147
|
+
type="button"
|
|
148
|
+
variant="ghost"
|
|
149
|
+
size="sm"
|
|
150
|
+
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
151
|
+
aria-pressed={showPassword}
|
|
152
|
+
onClick={() => setShowPassword((v) => !v)}
|
|
153
|
+
className="pointer-events-auto p-0 h-auto min-w-0 border-transparent bg-transparent text-muted hover:text-ink hover:bg-transparent"
|
|
154
|
+
>
|
|
155
|
+
<Icon name={showPassword ? "eye-off-hide-password" : "eye-show-password"} size={18} />
|
|
156
|
+
</Button>
|
|
157
|
+
}
|
|
158
|
+
fullWidth
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
{error && error.trim().length > 0 && (
|
|
163
|
+
<p role="alert" className="rounded-md px-base py-sm text-body-sm text-semantic-error">
|
|
164
|
+
{error}
|
|
165
|
+
</p>
|
|
166
|
+
)}
|
|
167
|
+
|
|
168
|
+
<Button
|
|
169
|
+
type="submit"
|
|
170
|
+
variant="primary"
|
|
171
|
+
size="lg"
|
|
172
|
+
loading={loading}
|
|
173
|
+
disabled={loading}
|
|
174
|
+
className="w-full border-none"
|
|
175
|
+
style={{
|
|
176
|
+
backgroundImage: "linear-gradient(135deg, var(--color-primary), var(--color-primary-hover))",
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{loading ? "Please wait…" : "Sign in"}
|
|
180
|
+
</Button>
|
|
181
|
+
</form>
|
|
182
|
+
|
|
183
|
+
{/* Footer */}
|
|
184
|
+
<p className="mt-xl text-body-sm text-muted">
|
|
185
|
+
Don’t have an account?{" "}
|
|
186
|
+
<Button type="button" variant="ghost" size="sm"
|
|
187
|
+
onClick={onSwitchToSignup}
|
|
188
|
+
style={{ whiteSpace: "normal" }}
|
|
189
|
+
className="text-primary hover:underline bg-transparent border-transparent p-0 h-auto">
|
|
190
|
+
Sign up
|
|
191
|
+
</Button>
|
|
192
|
+
</p>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
AuthLogin.displayName = "AuthLogin";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { AuthLogin } from "./AuthLogin";
|
|
3
|
+
|
|
4
|
+
export default function AuthLoginPreview() {
|
|
5
|
+
const [loading, setLoading] = useState(false);
|
|
6
|
+
|
|
7
|
+
const handleLogin = () => {
|
|
8
|
+
setLoading(true);
|
|
9
|
+
setTimeout(() => setLoading(false), 1200);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="w-full max-w-3xl mx-auto">
|
|
14
|
+
<AuthLogin
|
|
15
|
+
loading={loading}
|
|
16
|
+
onLogin={handleLogin}
|
|
17
|
+
onGoogleAuth={() => alert("Continue with Google")}
|
|
18
|
+
onSwitchToSignup={() => alert("Navigate to sign up")}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState, useId } from "react";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { Input } from "../Input";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
4
5
|
|
|
5
6
|
export type AuthTab = "login" | "signup";
|
|
6
7
|
|
|
@@ -8,11 +9,12 @@ export interface AuthScreenProps {
|
|
|
8
9
|
defaultTab?: AuthTab;
|
|
9
10
|
onLogin?: (values: { email: string; password: string }) => void;
|
|
10
11
|
onSignup?: (values: { name: string; email: string; password: string }) => void;
|
|
12
|
+
onGoogleAuth?: () => void;
|
|
11
13
|
loading?: boolean;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export const AuthScreen = React.forwardRef<HTMLDivElement, AuthScreenProps>(
|
|
15
|
-
({ defaultTab = "login", onLogin, onSignup, loading = false }, ref) => {
|
|
17
|
+
({ defaultTab = "login", onLogin, onSignup, onGoogleAuth, loading = false }, ref) => {
|
|
16
18
|
const [tab, setTab] = useState<AuthTab>(defaultTab);
|
|
17
19
|
const [name, setName] = useState("");
|
|
18
20
|
const [email, setEmail] = useState("");
|
|
@@ -53,10 +55,7 @@ export const AuthScreen = React.forwardRef<HTMLDivElement, AuthScreenProps>(
|
|
|
53
55
|
{/* Logo */}
|
|
54
56
|
<div className="mb-lg flex justify-center">
|
|
55
57
|
<div className="flex h-14 w-10 items-center justify-center rounded-full bg-primary">
|
|
56
|
-
<
|
|
57
|
-
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"
|
|
58
|
-
stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
59
|
-
</svg>
|
|
58
|
+
<Icon name="layers" className="text-on-primary" size={22} />
|
|
60
59
|
</div>
|
|
61
60
|
</div>
|
|
62
61
|
|
|
@@ -183,8 +182,9 @@ export const AuthScreen = React.forwardRef<HTMLDivElement, AuthScreenProps>(
|
|
|
183
182
|
<div className="h-px flex-1 bg-hairline" />
|
|
184
183
|
</div>
|
|
185
184
|
|
|
186
|
-
{/* Google
|
|
187
|
-
|
|
185
|
+
{/* Google — kept as a hand-authored multi-color brand mark (Google's four-color
|
|
186
|
+
logo cannot be represented by the single-color stroke icon registry) */}
|
|
187
|
+
<Button type="button" variant="secondary" size="md" className="w-full" onClick={onGoogleAuth}>
|
|
188
188
|
<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" className="shrink-0">
|
|
189
189
|
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="var(--color-google-blue)" />
|
|
190
190
|
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="var(--color-google-green)" />
|