@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,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppLayout } from "./AppLayout";
|
|
3
3
|
import type { ChatMessage } from "../ChatScreen";
|
|
4
|
+
import type { ChatHistoryItem } from "../ChatHistorySidebar";
|
|
4
5
|
|
|
5
6
|
// ─── Sample messages ──────────────────────────────────────────────────────────
|
|
6
7
|
|
|
@@ -35,9 +36,26 @@ const sampleMessages: ChatMessage[] = [
|
|
|
35
36
|
},
|
|
36
37
|
];
|
|
37
38
|
|
|
39
|
+
const sampleChatHistory: ChatHistoryItem[] = [
|
|
40
|
+
{ id: "1", label: "Landing page with pricing cards" },
|
|
41
|
+
{ id: "2", label: "Dashboard layout with sidebar nav" },
|
|
42
|
+
{ id: "3", label: "Onboarding flow wireframe" },
|
|
43
|
+
{ id: "4", label: "Settings page revamp" },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const sampleComponentHistory: ChatHistoryItem[] = [
|
|
47
|
+
{ id: "c1", label: "Button" },
|
|
48
|
+
{ id: "c2", label: "PricingCard" },
|
|
49
|
+
{ id: "c3", label: "AppSidebar" },
|
|
50
|
+
];
|
|
51
|
+
|
|
38
52
|
// ─── Preview export ───────────────────────────────────────────────────────────
|
|
39
53
|
|
|
40
54
|
export default function AppLayoutPreview() {
|
|
55
|
+
const [suggestDesigns, setSuggestDesigns] = React.useState(false);
|
|
56
|
+
const [historyOpen, setHistoryOpen] = React.useState(true);
|
|
57
|
+
const [activeHistoryId, setActiveHistoryId] = React.useState("1");
|
|
58
|
+
|
|
41
59
|
return (
|
|
42
60
|
<div className="w-full">
|
|
43
61
|
{/*
|
|
@@ -46,6 +64,15 @@ export default function AppLayoutPreview() {
|
|
|
46
64
|
*/}
|
|
47
65
|
<AppLayout
|
|
48
66
|
fillViewport={false}
|
|
67
|
+
showHistorySidebar
|
|
68
|
+
historySidebarBrandName="Assistant"
|
|
69
|
+
historySidebarOpen={historyOpen}
|
|
70
|
+
onHistorySidebarOpenChange={setHistoryOpen}
|
|
71
|
+
chatHistoryItems={sampleChatHistory}
|
|
72
|
+
componentHistoryItems={sampleComponentHistory}
|
|
73
|
+
activeHistoryId={activeHistoryId}
|
|
74
|
+
onSelectHistoryItem={setActiveHistoryId}
|
|
75
|
+
onNewChat={() => setActiveHistoryId("")}
|
|
49
76
|
navbarProps={{
|
|
50
77
|
avatarInitials: "OF",
|
|
51
78
|
version: "Latest",
|
|
@@ -56,6 +83,8 @@ export default function AppLayoutPreview() {
|
|
|
56
83
|
chatProps={{
|
|
57
84
|
messages: sampleMessages,
|
|
58
85
|
placeholder: "Tell me what to build…",
|
|
86
|
+
suggestDesigns,
|
|
87
|
+
onSuggestDesignsChange: setSuggestDesigns,
|
|
59
88
|
}}
|
|
60
89
|
/* Pass an explicit non-empty array to show the tab nav */
|
|
61
90
|
rightPanelTabs={["Preview", "Dashboard"]}
|
|
@@ -4,60 +4,7 @@ import { WorkspaceMenu } from "../WorkspaceMenu";
|
|
|
4
4
|
import { NavItem } from "../NavItem";
|
|
5
5
|
import type { NavItemSubItem } from "../NavItem";
|
|
6
6
|
import { UpgradeCard } from "../UpgradeCard";
|
|
7
|
-
|
|
8
|
-
/* ─── Inline SVG icons ───────────────────────────────────────────────────── */
|
|
9
|
-
|
|
10
|
-
const LogoIcon = () => (
|
|
11
|
-
<svg width="32" height="32" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
12
|
-
<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)" }} />
|
|
13
|
-
<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)" }} />
|
|
14
|
-
<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 }} />
|
|
15
|
-
</svg>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const GiftIcon = () => (
|
|
19
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "20px", height: "20px" }}>
|
|
20
|
-
<polyline points="20 12 20 22 4 22 4 12" />
|
|
21
|
-
<rect x="2" y="7" width="20" height="5" />
|
|
22
|
-
<line x1="12" y1="22" x2="12" y2="7" />
|
|
23
|
-
<path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z" />
|
|
24
|
-
<path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z" />
|
|
25
|
-
</svg>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const InboxIcon = () => (
|
|
29
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "20px", height: "20px" }}>
|
|
30
|
-
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
|
|
31
|
-
<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" />
|
|
32
|
-
</svg>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const SidebarIcon = () => (
|
|
36
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
37
|
-
<rect x="3" y="3" width="18" height="18" rx="2" />
|
|
38
|
-
<line x1="9" y1="3" x2="9" y2="21" />
|
|
39
|
-
</svg>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const SunIcon = () => (
|
|
43
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
44
|
-
<circle cx="12" cy="12" r="5" />
|
|
45
|
-
<line x1="12" y1="1" x2="12" y2="3" />
|
|
46
|
-
<line x1="12" y1="21" x2="12" y2="23" />
|
|
47
|
-
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
|
|
48
|
-
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
|
|
49
|
-
<line x1="1" y1="12" x2="3" y2="12" />
|
|
50
|
-
<line x1="21" y1="12" x2="23" y2="12" />
|
|
51
|
-
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
|
|
52
|
-
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
|
|
53
|
-
</svg>
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const MoonIcon = () => (
|
|
57
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
58
|
-
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
59
|
-
</svg>
|
|
60
|
-
);
|
|
7
|
+
import { Icon } from "../Icon";
|
|
61
8
|
|
|
62
9
|
/* ─── Types ──────────────────────────────────────────────────────────────── */
|
|
63
10
|
|
|
@@ -74,6 +21,12 @@ export interface NavEntry {
|
|
|
74
21
|
label: string;
|
|
75
22
|
icon?: React.ReactNode;
|
|
76
23
|
subItems?: NavSubItem[];
|
|
24
|
+
/**
|
|
25
|
+
* When true (and subItems is non-empty), this entry's sub-items are always
|
|
26
|
+
* rendered expanded and the chevron toggle is disabled — the entry cannot
|
|
27
|
+
* be collapsed by the user.
|
|
28
|
+
*/
|
|
29
|
+
alwaysExpanded?: boolean;
|
|
77
30
|
}
|
|
78
31
|
|
|
79
32
|
export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -96,17 +49,19 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
96
49
|
/** Called when the user selects a top-level entry. */
|
|
97
50
|
onSelect?: (id: string) => void;
|
|
98
51
|
|
|
99
|
-
/**
|
|
100
|
-
* ID of the currently-active sub-item (optional). Forwarded to each
|
|
101
|
-
* rendered NavItem so the matching nested sub-item row shows the selected
|
|
102
|
-
* indication. Does NOT affect which top-level entry is treated as active —
|
|
103
|
-
* that is driven exclusively by `activeId`.
|
|
104
|
-
*/
|
|
52
|
+
/** ID of the currently-active sub-item (optional). */
|
|
105
53
|
activeSubId?: string;
|
|
106
54
|
|
|
107
55
|
/** Called when the user selects a sub-item. */
|
|
108
56
|
onSubSelect?: (id: string) => void;
|
|
109
57
|
|
|
58
|
+
/**
|
|
59
|
+
* IDs of entries that should be expanded on first render. Seeds the
|
|
60
|
+
* internal expanded-subtree state once; subsequent expand/collapse is
|
|
61
|
+
* still managed internally.
|
|
62
|
+
*/
|
|
63
|
+
defaultExpandedIds?: string[];
|
|
64
|
+
|
|
110
65
|
// ── Footer opt-in props ──────────────────────────────────────────────────
|
|
111
66
|
|
|
112
67
|
/**
|
|
@@ -116,7 +71,7 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
116
71
|
workspaceName?: string;
|
|
117
72
|
|
|
118
73
|
/**
|
|
119
|
-
* When true, renders the "Share" referral card in the footer.
|
|
74
|
+
* When true, renders the "Share Lovable" referral card in the footer.
|
|
120
75
|
* Defaults to false.
|
|
121
76
|
*/
|
|
122
77
|
showShareCard?: boolean;
|
|
@@ -133,6 +88,19 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
133
88
|
*/
|
|
134
89
|
userInitials?: string;
|
|
135
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Email of the connected user. Shown as the header row of the account menu
|
|
93
|
+
* that opens when the avatar is clicked (requires onLogout to be set).
|
|
94
|
+
*/
|
|
95
|
+
userEmail?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* When provided, the avatar becomes a menu trigger: clicking it opens an
|
|
99
|
+
* account menu with the user's email as a header and a "Logout" item that
|
|
100
|
+
* calls this handler. If omitted the avatar has no menu.
|
|
101
|
+
*/
|
|
102
|
+
onLogout?: () => void;
|
|
103
|
+
|
|
136
104
|
/**
|
|
137
105
|
* When provided, renders an inbox button in the footer and calls this on click.
|
|
138
106
|
* If omitted the inbox button is not shown.
|
|
@@ -154,16 +122,6 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
154
122
|
*/
|
|
155
123
|
onDarkModeToggle?: () => void;
|
|
156
124
|
|
|
157
|
-
// ── Expand state seed ────────────────────────────────────────────────────
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* IDs of entries whose sub-item lists should be expanded on the initial
|
|
161
|
-
* render. The sidebar continues to manage expand/collapse state internally
|
|
162
|
-
* after mount — this only seeds the initial state and is NOT a controlled
|
|
163
|
-
* prop (changes after mount are ignored).
|
|
164
|
-
*/
|
|
165
|
-
defaultExpandedIds?: string[];
|
|
166
|
-
|
|
167
125
|
// ── Legacy / backwards-compatible props ──────────────────────────────────
|
|
168
126
|
|
|
169
127
|
/** @deprecated Use activeId instead. */
|
|
@@ -179,6 +137,112 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
179
137
|
children?: React.ReactNode;
|
|
180
138
|
}
|
|
181
139
|
|
|
140
|
+
/* ─── Account menu (avatar dropdown) ────────────────────────────────────── */
|
|
141
|
+
|
|
142
|
+
interface AccountMenuProps {
|
|
143
|
+
userInitials: string;
|
|
144
|
+
userEmail?: string;
|
|
145
|
+
onLogout: () => void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function AccountMenu({ userInitials, userEmail, onLogout }: AccountMenuProps) {
|
|
149
|
+
const [open, setOpen] = React.useState(false);
|
|
150
|
+
const [mounted, setMounted] = React.useState(false);
|
|
151
|
+
const [visible, setVisible] = React.useState(false);
|
|
152
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
153
|
+
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
if (open) {
|
|
156
|
+
setMounted(true);
|
|
157
|
+
const raf = requestAnimationFrame(() => {
|
|
158
|
+
requestAnimationFrame(() => setVisible(true));
|
|
159
|
+
});
|
|
160
|
+
return () => cancelAnimationFrame(raf);
|
|
161
|
+
}
|
|
162
|
+
setVisible(false);
|
|
163
|
+
const timer = window.setTimeout(() => setMounted(false), 200);
|
|
164
|
+
return () => window.clearTimeout(timer);
|
|
165
|
+
}, [open]);
|
|
166
|
+
|
|
167
|
+
React.useEffect(() => {
|
|
168
|
+
if (!open) return;
|
|
169
|
+
const handler = (e: MouseEvent) => {
|
|
170
|
+
if (containerRef.current && !containerRef.current.contains(e.target as Node)) {
|
|
171
|
+
setOpen(false);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
document.addEventListener("mousedown", handler);
|
|
175
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
176
|
+
}, [open]);
|
|
177
|
+
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
if (!open) return;
|
|
180
|
+
const handler = (e: KeyboardEvent) => {
|
|
181
|
+
if (e.key === "Escape") setOpen(false);
|
|
182
|
+
};
|
|
183
|
+
document.addEventListener("keydown", handler);
|
|
184
|
+
return () => document.removeEventListener("keydown", handler);
|
|
185
|
+
}, [open]);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<div ref={containerRef} className="relative inline-block flex-shrink-0">
|
|
189
|
+
<Button
|
|
190
|
+
type="button"
|
|
191
|
+
variant="primary"
|
|
192
|
+
aria-haspopup="menu"
|
|
193
|
+
aria-expanded={open}
|
|
194
|
+
aria-label="Account menu"
|
|
195
|
+
onClick={() => setOpen((v) => !v)}
|
|
196
|
+
pushEffect={false}
|
|
197
|
+
className="!p-0 !rounded-full !border-0 text-body-sm font-weight-heading-sm"
|
|
198
|
+
style={{ width: "36px", height: "36px" }}
|
|
199
|
+
>
|
|
200
|
+
{userInitials}
|
|
201
|
+
</Button>
|
|
202
|
+
|
|
203
|
+
{mounted && (
|
|
204
|
+
<div
|
|
205
|
+
role="menu"
|
|
206
|
+
aria-label="Account"
|
|
207
|
+
aria-hidden={!open}
|
|
208
|
+
className={[
|
|
209
|
+
"absolute left-0 bottom-full mb-xs origin-bottom rounded-sm bg-surface border border-hairline shadow-card z-10 overflow-hidden",
|
|
210
|
+
"flex flex-col gap-0 p-0",
|
|
211
|
+
"transition-all duration-200 ease-in-out will-change-transform",
|
|
212
|
+
visible
|
|
213
|
+
? "pointer-events-auto opacity-100 translate-y-0 scale-y-100"
|
|
214
|
+
: "pointer-events-none opacity-0 translate-y-1 scale-y-95",
|
|
215
|
+
].join(" ")}
|
|
216
|
+
style={{ minWidth: "200px" }}
|
|
217
|
+
>
|
|
218
|
+
{userEmail && (
|
|
219
|
+
<div className="px-md py-sm border-b border-hairline">
|
|
220
|
+
<span className="block text-body-sm text-ink font-weight-heading-sm truncate">
|
|
221
|
+
{userEmail}
|
|
222
|
+
</span>
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
<Button
|
|
227
|
+
role="menuitem"
|
|
228
|
+
type="button"
|
|
229
|
+
variant="ghost"
|
|
230
|
+
size="sm"
|
|
231
|
+
onClick={() => {
|
|
232
|
+
setOpen(false);
|
|
233
|
+
onLogout();
|
|
234
|
+
}}
|
|
235
|
+
className="!w-full !justify-start !rounded-none !px-md !py-sm !gap-sm !text-ink"
|
|
236
|
+
>
|
|
237
|
+
<Icon name="logout-sign-out" className="size-4 shrink-0" />
|
|
238
|
+
<span>Logout</span>
|
|
239
|
+
</Button>
|
|
240
|
+
</div>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
182
246
|
/* ─── Component ──────────────────────────────────────────────────────────── */
|
|
183
247
|
|
|
184
248
|
export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
@@ -190,17 +254,18 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
190
254
|
onSelect,
|
|
191
255
|
activeSubId,
|
|
192
256
|
onSubSelect,
|
|
257
|
+
defaultExpandedIds,
|
|
193
258
|
// footer opt-in props
|
|
194
259
|
workspaceName,
|
|
195
260
|
showShareCard = false,
|
|
196
261
|
showUpgradeCard = false,
|
|
197
262
|
userInitials,
|
|
263
|
+
userEmail,
|
|
264
|
+
onLogout,
|
|
198
265
|
onInboxClick,
|
|
199
266
|
// dark mode toggle
|
|
200
267
|
darkMode = false,
|
|
201
268
|
onDarkModeToggle,
|
|
202
|
-
// expand state seed
|
|
203
|
-
defaultExpandedIds,
|
|
204
269
|
// legacy compat
|
|
205
270
|
activeItem,
|
|
206
271
|
collapsed: collapsedProp,
|
|
@@ -223,13 +288,22 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
223
288
|
};
|
|
224
289
|
|
|
225
290
|
/* ── Expanded subtree state (managed internally per the spec) ── */
|
|
226
|
-
// Use a lazy initialiser so defaultExpandedIds seeds the Set only once
|
|
227
|
-
// on mount; subsequent renders ignore it (uncontrolled behaviour).
|
|
228
291
|
const [expandedIds, setExpandedIds] = React.useState<Set<string>>(
|
|
229
292
|
() => new Set(defaultExpandedIds ?? []),
|
|
230
293
|
);
|
|
231
294
|
|
|
295
|
+
const alwaysExpandedIds = React.useMemo(
|
|
296
|
+
() =>
|
|
297
|
+
new Set(
|
|
298
|
+
(entries ?? [])
|
|
299
|
+
.filter((entry) => entry.alwaysExpanded && entry.subItems && entry.subItems.length > 0)
|
|
300
|
+
.map((entry) => entry.id),
|
|
301
|
+
),
|
|
302
|
+
[entries],
|
|
303
|
+
);
|
|
304
|
+
|
|
232
305
|
const toggleExpanded = (id: string) => {
|
|
306
|
+
if (alwaysExpandedIds.has(id)) return;
|
|
233
307
|
setExpandedIds((prev) => {
|
|
234
308
|
const next = new Set(prev);
|
|
235
309
|
if (next.has(id)) next.delete(id);
|
|
@@ -274,7 +348,12 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
274
348
|
className="transition-all duration-300 ease-in-out overflow-hidden flex-shrink-0 flex items-center gap-sm min-w-0"
|
|
275
349
|
style={{ maxWidth: collapsed ? "0px" : "180px", opacity: collapsed ? 0 : 1 }}
|
|
276
350
|
>
|
|
277
|
-
<
|
|
351
|
+
<span
|
|
352
|
+
className="flex items-center justify-center rounded-md bg-primary text-on-primary flex-shrink-0"
|
|
353
|
+
style={{ width: "32px", height: "32px" }}
|
|
354
|
+
>
|
|
355
|
+
<Icon name="sparkle" className="size-4" />
|
|
356
|
+
</span>
|
|
278
357
|
{brandName && (
|
|
279
358
|
<span className="text-body-sm font-weight-heading-sm text-ink truncate">
|
|
280
359
|
{brandName}
|
|
@@ -297,7 +376,7 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
297
376
|
.filter(Boolean)
|
|
298
377
|
.join(" ")}
|
|
299
378
|
>
|
|
300
|
-
<
|
|
379
|
+
<Icon name="sidebar-panel-toggle" className="size-[18px]" />
|
|
301
380
|
</Button>
|
|
302
381
|
</div>
|
|
303
382
|
|
|
@@ -323,7 +402,8 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
323
402
|
{entries!.map((entry) => {
|
|
324
403
|
const isActive = resolvedActiveId === entry.id;
|
|
325
404
|
const hasSubItems = !!(entry.subItems && entry.subItems.length > 0);
|
|
326
|
-
const
|
|
405
|
+
const isAlwaysExpanded = hasSubItems && !!entry.alwaysExpanded;
|
|
406
|
+
const isExpanded = isAlwaysExpanded ? true : expandedIds.has(entry.id);
|
|
327
407
|
|
|
328
408
|
// Map AppSidebar's NavSubItem to NavItem's NavItemSubItem.
|
|
329
409
|
// Only pass subItems when there are actual sub-items — this ensures
|
|
@@ -347,10 +427,12 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
347
427
|
label={entry.label}
|
|
348
428
|
active={isActive}
|
|
349
429
|
iconOnly={collapsed}
|
|
430
|
+
alwaysExpanded={isAlwaysExpanded}
|
|
350
431
|
subItems={!collapsed ? mappedSubItems : undefined}
|
|
351
|
-
activeSubId={hasSubItems ? activeSubId : undefined}
|
|
352
432
|
expanded={hasSubItems ? isExpanded : undefined}
|
|
353
|
-
onExpandToggle={
|
|
433
|
+
onExpandToggle={
|
|
434
|
+
hasSubItems && !isAlwaysExpanded ? () => toggleExpanded(entry.id) : undefined
|
|
435
|
+
}
|
|
354
436
|
onClick={(e) => {
|
|
355
437
|
onSelect?.(entry.id);
|
|
356
438
|
if (hasSubItems) {
|
|
@@ -387,14 +469,14 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
387
469
|
{showShareCard && (
|
|
388
470
|
<div className="rounded-xl border border-hairline bg-surface px-md py-sm flex items-center justify-between gap-md">
|
|
389
471
|
<div className="flex flex-col gap-xxs min-w-0">
|
|
390
|
-
<span className="text-body-sm font-weight-heading-sm text-ink">Share
|
|
391
|
-
<span className="text-caption text-
|
|
472
|
+
<span className="text-body-sm font-weight-heading-sm text-ink">Share Lovable</span>
|
|
473
|
+
<span className="text-caption text-body">100 credits per paid referral</span>
|
|
392
474
|
</div>
|
|
393
475
|
<span
|
|
394
476
|
className="flex-shrink-0 flex items-center justify-center rounded-full bg-surface-strong"
|
|
395
477
|
style={{ width: "36px", height: "36px" }}
|
|
396
478
|
>
|
|
397
|
-
<
|
|
479
|
+
<Icon name="gift-present" className="size-5" />
|
|
398
480
|
</span>
|
|
399
481
|
</div>
|
|
400
482
|
)}
|
|
@@ -406,7 +488,7 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
406
488
|
</div>
|
|
407
489
|
)}
|
|
408
490
|
|
|
409
|
-
{/* Bottom bar: user avatar + inbox + dark mode toggle */}
|
|
491
|
+
{/* Bottom bar: user avatar (+ account menu) + inbox + dark mode toggle */}
|
|
410
492
|
{hasFooterBottomContent && (
|
|
411
493
|
<div
|
|
412
494
|
className={[
|
|
@@ -414,15 +496,21 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
414
496
|
collapsed ? "justify-center flex-col gap-xs" : "justify-between",
|
|
415
497
|
].join(" ")}
|
|
416
498
|
>
|
|
417
|
-
{/* User avatar — only when userInitials provided
|
|
499
|
+
{/* User avatar — only when userInitials provided. Becomes a menu
|
|
500
|
+
trigger with an email header + Logout item (Logout always shown
|
|
501
|
+
once onLogout is provided, even without userEmail). */}
|
|
418
502
|
{userInitials && (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
503
|
+
onLogout ? (
|
|
504
|
+
<AccountMenu userInitials={userInitials} userEmail={userEmail} onLogout={onLogout} />
|
|
505
|
+
) : (
|
|
506
|
+
<span
|
|
507
|
+
className="flex items-center justify-center rounded-full bg-primary text-on-primary text-body-sm font-weight-heading-sm cursor-pointer hover:bg-primary-hover transition-colors duration-150 flex-shrink-0"
|
|
508
|
+
style={{ width: "36px", height: "36px" }}
|
|
509
|
+
aria-label="User profile"
|
|
510
|
+
>
|
|
511
|
+
{userInitials}
|
|
512
|
+
</span>
|
|
513
|
+
)
|
|
426
514
|
)}
|
|
427
515
|
|
|
428
516
|
{/* Inbox — only when onInboxClick provided, fades out when collapsed */}
|
|
@@ -438,7 +526,7 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
438
526
|
onClick={onInboxClick}
|
|
439
527
|
className="!p-xs !rounded-sm relative"
|
|
440
528
|
>
|
|
441
|
-
<
|
|
529
|
+
<Icon name="inbox-mail-tray" className="size-5" />
|
|
442
530
|
<span
|
|
443
531
|
className="absolute top-1 right-1 rounded-full bg-semantic-error"
|
|
444
532
|
aria-label="New notifications"
|
|
@@ -457,7 +545,7 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
|
|
|
457
545
|
onClick={onDarkModeToggle}
|
|
458
546
|
className="!p-xs !rounded-sm flex-shrink-0"
|
|
459
547
|
>
|
|
460
|
-
{darkMode ?
|
|
548
|
+
<Icon name={darkMode ? "sun-light-mode" : "moon-dark-mode"} className="size-[18px]" />
|
|
461
549
|
</Button>
|
|
462
550
|
)}
|
|
463
551
|
</div>
|
|
@@ -1,51 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppSidebar } from "./AppSidebar";
|
|
3
3
|
import { Button } from "../Button";
|
|
4
|
+
import { Icon } from "../Icon";
|
|
4
5
|
import type { NavEntry } from "./AppSidebar";
|
|
5
6
|
|
|
6
|
-
/* ───
|
|
7
|
-
|
|
8
|
-
const HomeIcon = () => (
|
|
9
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
10
|
-
<path d="M3 9.75L12 3l9 6.75V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9.75z" />
|
|
11
|
-
<polyline points="9 21 9 12 15 12 15 21" />
|
|
12
|
-
</svg>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const SearchIcon = () => (
|
|
16
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
17
|
-
<circle cx="11" cy="11" r="8" />
|
|
18
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
19
|
-
</svg>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const FolderIcon = () => (
|
|
23
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
24
|
-
<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" />
|
|
25
|
-
</svg>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const StarIcon = () => (
|
|
29
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
30
|
-
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const SettingsIcon = () => (
|
|
35
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "18px", height: "18px" }}>
|
|
36
|
-
<circle cx="12" cy="12" r="3" />
|
|
37
|
-
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
|
|
38
|
-
</svg>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const SubFileIcon = () => (
|
|
42
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" style={{ width: "14px", height: "14px" }}>
|
|
43
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
|
44
|
-
<polyline points="14 2 14 8 20 8" />
|
|
45
|
-
</svg>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
/* ─── Scenario A: Full sidebar with dark mode toggle ────────────────────── */
|
|
7
|
+
/* ─── Scenario A: Full sidebar with dark mode + account menu ────────────── */
|
|
49
8
|
|
|
50
9
|
function FullSidebarDemo() {
|
|
51
10
|
const [collapsed, setCollapsed] = React.useState(false);
|
|
@@ -53,9 +12,9 @@ function FullSidebarDemo() {
|
|
|
53
12
|
const [activeSubId, setActiveSubId] = React.useState<string | undefined>("proj-alpha");
|
|
54
13
|
const [darkMode, setDarkMode] = React.useState(false);
|
|
55
14
|
const [subItems, setSubItems] = React.useState([
|
|
56
|
-
{ id: "proj-alpha", label: "Alpha", icon: <
|
|
57
|
-
{ id: "proj-beta", label: "Beta", icon: <
|
|
58
|
-
{ id: "proj-gamma", label: "Gamma", icon: <
|
|
15
|
+
{ id: "proj-alpha", label: "Alpha", icon: <Icon name="file-document" className="size-[14px]" /> },
|
|
16
|
+
{ id: "proj-beta", label: "Beta", icon: <Icon name="file-document" className="size-[14px]" /> },
|
|
17
|
+
{ id: "proj-gamma", label: "Gamma", icon: <Icon name="file-document" className="size-[14px]" /> },
|
|
59
18
|
]);
|
|
60
19
|
|
|
61
20
|
const handleDelete = (id: string) => {
|
|
@@ -64,22 +23,22 @@ function FullSidebarDemo() {
|
|
|
64
23
|
};
|
|
65
24
|
|
|
66
25
|
const entries: NavEntry[] = [
|
|
67
|
-
{ id: "home", label: "Home", icon: <
|
|
68
|
-
{ id: "search", label: "Search", icon: <
|
|
26
|
+
{ id: "home", label: "Home", icon: <Icon name="home" className="size-[18px]" /> },
|
|
27
|
+
{ id: "search", label: "Search", icon: <Icon name="search-magnifier" className="size-[18px]" /> },
|
|
69
28
|
{
|
|
70
29
|
id: "projects",
|
|
71
30
|
label: "Projects",
|
|
72
|
-
icon: <
|
|
31
|
+
icon: <Icon name="folder" className="size-[18px]" />,
|
|
73
32
|
subItems: subItems.map((s) => ({ ...s, onDelete: handleDelete })),
|
|
74
33
|
},
|
|
75
|
-
{ id: "starred", label: "Starred", icon: <
|
|
76
|
-
{ id: "settings", label: "Settings", icon: <
|
|
34
|
+
{ id: "starred", label: "Starred", icon: <Icon name="star" className="size-[18px]" /> },
|
|
35
|
+
{ id: "settings", label: "Settings", icon: <Icon name="settings-gear" className="size-[18px]" /> },
|
|
77
36
|
];
|
|
78
37
|
|
|
79
38
|
return (
|
|
80
39
|
<div>
|
|
81
40
|
<p className="text-caption text-muted mb-sm">
|
|
82
|
-
Full footer ·
|
|
41
|
+
Full footer · click the avatar to open the account menu (email header + Logout) · dark mode toggle
|
|
83
42
|
</p>
|
|
84
43
|
<div
|
|
85
44
|
className="relative flex bg-canvas rounded-xl border border-hairline shadow-card overflow-hidden"
|
|
@@ -98,6 +57,8 @@ function FullSidebarDemo() {
|
|
|
98
57
|
showShareCard
|
|
99
58
|
showUpgradeCard
|
|
100
59
|
userInitials="O"
|
|
60
|
+
userEmail="ofer@example.com"
|
|
61
|
+
onLogout={() => alert("Logged out")}
|
|
101
62
|
onInboxClick={() => {}}
|
|
102
63
|
darkMode={darkMode}
|
|
103
64
|
onDarkModeToggle={() => setDarkMode((d) => !d)}
|
|
@@ -139,9 +100,9 @@ function FullSidebarDemo() {
|
|
|
139
100
|
|
|
140
101
|
function MinimalSidebarDemo() {
|
|
141
102
|
const entries: NavEntry[] = [
|
|
142
|
-
{ id: "home", label: "Home", icon: <
|
|
143
|
-
{ id: "search", label: "Search", icon: <
|
|
144
|
-
{ id: "settings", label: "Settings", icon: <
|
|
103
|
+
{ id: "home", label: "Home", icon: <Icon name="home" className="size-[18px]" /> },
|
|
104
|
+
{ id: "search", label: "Search", icon: <Icon name="search-magnifier" className="size-[18px]" /> },
|
|
105
|
+
{ id: "settings", label: "Settings", icon: <Icon name="settings-gear" className="size-[18px]" /> },
|
|
145
106
|
];
|
|
146
107
|
|
|
147
108
|
const [activeId, setActiveId] = React.useState("home");
|
|
@@ -169,13 +130,13 @@ function MinimalSidebarDemo() {
|
|
|
169
130
|
);
|
|
170
131
|
}
|
|
171
132
|
|
|
172
|
-
/* ─── Scenario C: Partial footer — avatar + inbox + dark
|
|
133
|
+
/* ─── Scenario C: Partial footer — avatar (no menu) + inbox + dark toggle ─ */
|
|
173
134
|
|
|
174
135
|
function PartialFooterDemo() {
|
|
175
136
|
const [darkMode, setDarkMode] = React.useState(false);
|
|
176
137
|
const entries: NavEntry[] = [
|
|
177
|
-
{ id: "home", label: "Home", icon: <
|
|
178
|
-
{ id: "starred", label: "Starred", icon: <
|
|
138
|
+
{ id: "home", label: "Home", icon: <Icon name="home" className="size-[18px]" /> },
|
|
139
|
+
{ id: "starred", label: "Starred", icon: <Icon name="star" className="size-[18px]" /> },
|
|
179
140
|
];
|
|
180
141
|
|
|
181
142
|
const [activeId, setActiveId] = React.useState("home");
|
|
@@ -183,7 +144,7 @@ function PartialFooterDemo() {
|
|
|
183
144
|
return (
|
|
184
145
|
<div>
|
|
185
146
|
<p className="text-caption text-muted mb-sm">
|
|
186
|
-
Partial footer — user avatar, inbox, and dark mode toggle
|
|
147
|
+
Partial footer — user avatar (no email set, so no menu), inbox, and dark mode toggle
|
|
187
148
|
</p>
|
|
188
149
|
<div
|
|
189
150
|
className="relative flex bg-canvas rounded-xl border border-hairline shadow-card overflow-hidden"
|