@designa8/vibedesign-v6 1.20.20 → 2.1.2

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.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/dist/fonts/plusjakartasans/PlusJakartaSans-Italic[wght].ttf +0 -0
  3. package/dist/fonts/plusjakartasans/PlusJakartaSans[wght].ttf +0 -0
  4. package/dist/index.cjs +12027 -4942
  5. package/dist/index.js +12089 -5004
  6. package/dist/styles.css +1393 -97
  7. package/package.json +116 -1
  8. package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +567 -0
  9. package/src/atoms/AgentQuestionCard/index.ts +6 -0
  10. package/src/atoms/AgentQuestionCard/preview.tsx +199 -0
  11. package/src/atoms/AppLayout/AppLayout.tsx +85 -22
  12. package/src/atoms/AppLayout/preview.tsx +4 -0
  13. package/src/atoms/AppSidebar/AppSidebar.tsx +224 -138
  14. package/src/atoms/AppSidebar/index.ts +1 -1
  15. package/src/atoms/AppSidebar/preview.tsx +61 -8
  16. package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +242 -173
  17. package/src/atoms/AppSidebarMobile/preview.tsx +59 -89
  18. package/src/atoms/AuthLogin/AuthLogin.tsx +86 -49
  19. package/src/atoms/AuthLogin/preview.tsx +16 -0
  20. package/src/atoms/AuthSignUp/AuthSignUp.tsx +206 -126
  21. package/src/atoms/AuthSignUp/preview.tsx +10 -0
  22. package/src/atoms/BottomSheet/BottomSheet.tsx +199 -0
  23. package/src/atoms/BottomSheet/index.ts +2 -0
  24. package/src/atoms/BottomSheet/preview.tsx +50 -0
  25. package/src/atoms/Button/Button.tsx +19 -3
  26. package/src/atoms/Button/preview.tsx +2 -1
  27. package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +160 -84
  28. package/src/atoms/ChatHistorySidebar/preview.tsx +81 -42
  29. package/src/atoms/ChatScreen/ChatScreen.tsx +298 -33
  30. package/src/atoms/ChatScreen/preview.tsx +54 -90
  31. package/src/atoms/Chip/Chip.tsx +81 -33
  32. package/src/atoms/Chip/preview.tsx +39 -21
  33. package/src/atoms/CodeEditor/CodeEditor.tsx +10 -4
  34. package/src/atoms/ComponentActionsSheet/ComponentActionsSheet.tsx +165 -0
  35. package/src/atoms/ComponentActionsSheet/index.ts +7 -0
  36. package/src/atoms/ComponentActionsSheet/preview.tsx +67 -0
  37. package/src/atoms/ComponentCard/ComponentCard.tsx +17 -35
  38. package/src/atoms/ComponentCard/preview.tsx +9 -9
  39. package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +153 -0
  40. package/src/atoms/DesignSystemLoader/index.ts +2 -0
  41. package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
  42. package/src/atoms/DesignSystemShowcase/DesignSystemShowcase.tsx +410 -0
  43. package/src/atoms/DesignSystemShowcase/index.ts +6 -0
  44. package/src/atoms/DesignSystemShowcase/preview.tsx +22 -0
  45. package/src/atoms/DesignTokensPanel/DesignTokensPanel.data.ts +254 -0
  46. package/src/atoms/DesignTokensPanel/DesignTokensPanel.tsx +946 -0
  47. package/src/atoms/DesignTokensPanel/index.ts +9 -0
  48. package/src/atoms/DesignTokensPanel/preview.tsx +39 -0
  49. package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +239 -0
  50. package/src/atoms/ExpandableMessage/fix-link-note.txt +3 -0
  51. package/src/atoms/ExpandableMessage/index.ts +2 -0
  52. package/src/atoms/ExpandableMessage/markdown.tsx +310 -0
  53. package/src/atoms/ExpandableMessage/preview.tsx +83 -0
  54. package/src/atoms/ExportDesignMdModal/ExportDesignMdModal.tsx +6 -1
  55. package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
  56. package/src/atoms/FontCombobox/FontCombobox.tsx +655 -0
  57. package/src/atoms/FontCombobox/index.ts +6 -0
  58. package/src/atoms/FontCombobox/preview.tsx +111 -0
  59. package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +894 -96
  60. package/src/atoms/HomePageTemplate/preview.tsx +4 -0
  61. package/src/atoms/Icon/Icon.tsx +17 -11
  62. package/src/atoms/Icon/icons.data.ts +34 -0
  63. package/src/atoms/Input/Input.tsx +37 -21
  64. package/src/atoms/LandingHero/LandingHero.tsx +545 -0
  65. package/src/atoms/LandingHero/index.ts +6 -0
  66. package/src/atoms/LandingHero/preview.tsx +88 -0
  67. package/src/atoms/MarketingFooter/MarketingFooter.tsx +215 -0
  68. package/src/atoms/MarketingFooter/index.ts +7 -0
  69. package/src/atoms/MarketingFooter/preview.tsx +28 -0
  70. package/src/atoms/MarketingNavbar/MarketingNavbar.tsx +451 -0
  71. package/src/atoms/MarketingNavbar/index.ts +7 -0
  72. package/src/atoms/MarketingNavbar/preview.tsx +109 -0
  73. package/src/atoms/Menu/Menu.tsx +1 -1
  74. package/src/atoms/MobileActionsDrawer/MobileActionsDrawer.tsx +548 -0
  75. package/src/atoms/MobileActionsDrawer/index.ts +9 -0
  76. package/src/atoms/MobileActionsDrawer/preview.tsx +109 -0
  77. package/src/atoms/Modal/Modal.tsx +77 -28
  78. package/src/atoms/PreviewDock/PreviewDock.tsx +119 -0
  79. package/src/atoms/PreviewDock/index.ts +2 -0
  80. package/src/atoms/PreviewDock/preview.tsx +30 -0
  81. package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +47 -30
  82. package/src/atoms/PricingCard/PricingCard.tsx +15 -4
  83. package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +109 -89
  84. package/src/atoms/ProjectSettingsModal/ProjectSettingsModal.tsx +314 -0
  85. package/src/atoms/ProjectSettingsModal/index.ts +2 -0
  86. package/src/atoms/ProjectSettingsModal/preview.tsx +130 -0
  87. package/src/atoms/ProjectSettingsModal/switch.snippet.txt +8 -0
  88. package/src/atoms/PromptInputBar/PromptInputBar.tsx +750 -302
  89. package/src/atoms/PromptInputBar/preview.tsx +64 -64
  90. package/src/atoms/SettingsPageTemplate/SettingsPageTemplate.tsx +272 -0
  91. package/src/atoms/SettingsPageTemplate/index.ts +2 -0
  92. package/src/atoms/SettingsPageTemplate/preview.tsx +29 -0
  93. package/src/atoms/SidebarUpgradeBanner/SidebarUpgradeBanner.tsx +178 -0
  94. package/src/atoms/SidebarUpgradeBanner/index.ts +2 -0
  95. package/src/atoms/SidebarUpgradeBanner/preview.tsx +47 -0
  96. package/src/atoms/SkeletonChip/SkeletonChip.tsx +198 -0
  97. package/src/atoms/SkeletonChip/index.ts +2 -0
  98. package/src/atoms/SkeletonChip/preview.tsx +44 -0
  99. package/src/atoms/TemplateHeader/TemplateHeader.tsx +129 -0
  100. package/src/atoms/TemplateHeader/index.ts +2 -0
  101. package/src/atoms/TemplateHeader/preview.tsx +39 -0
  102. package/src/atoms/TemplateHero/TemplateHero.tsx +286 -0
  103. package/src/atoms/TemplateHero/index.ts +2 -0
  104. package/src/atoms/TemplateHero/preview.tsx +32 -0
  105. package/src/atoms/TemplateSummary/TemplateSummary.tsx +85 -0
  106. package/src/atoms/TemplateSummary/index.ts +2 -0
  107. package/src/atoms/TemplateSummary/preview.tsx +10 -0
  108. package/src/atoms/Toast/Toast.tsx +178 -0
  109. package/src/atoms/Toast/index.ts +2 -0
  110. package/src/atoms/Toast/preview.tsx +100 -0
  111. package/src/atoms/TopNavbar/TopNavbar.tsx +145 -67
  112. package/src/atoms/TopNavbar/preview.tsx +13 -7
  113. package/src/atoms/TopupModal/TopupModal.tsx +94 -0
  114. package/src/atoms/TopupModal/index.ts +2 -0
  115. package/src/atoms/TopupModal/preview.tsx +22 -0
  116. package/src/atoms/UpgradeCard/UpgradeCard.tsx +124 -43
  117. package/src/atoms/UpgradeCard/index.ts +1 -1
  118. package/src/atoms/UpgradeCard/preview.tsx +7 -14
  119. package/src/atoms/UpgradeModal/UpgradeModal.tsx +192 -0
  120. package/src/atoms/UpgradeModal/index.ts +2 -0
  121. package/src/atoms/UpgradeModal/preview.tsx +41 -0
  122. package/src/index.ts +23 -0
  123. package/src/tokens.css +45 -7
  124. package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
  125. package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import { Button } from "../Button";
3
- import { WorkspaceMenu } from "../WorkspaceMenu";
4
3
  import { NavItem } from "../NavItem";
5
4
  import type { NavItemSubItem } from "../NavItem";
6
5
  import { UpgradeCard } from "../UpgradeCard";
6
+ import { SkeletonChip } from "../SkeletonChip";
7
7
  import { Icon } from "../Icon";
8
8
 
9
9
  /* ─── Types ──────────────────────────────────────────────────────────────── */
@@ -29,7 +29,8 @@ export interface NavEntry {
29
29
  alwaysExpanded?: boolean;
30
30
  }
31
31
 
32
- export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
32
+ export interface AppSidebarProps
33
+ extends Omit<React.HTMLAttributes<HTMLElement>, "onSelect"> {
33
34
  /**
34
35
  * Brand / product name displayed in the header when the sidebar is expanded.
35
36
  * If omitted the default logo icon is shown without a title.
@@ -43,6 +44,17 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
43
44
  */
44
45
  entries?: NavEntry[];
45
46
 
47
+ /**
48
+ * When true, the nav entries are still loading (e.g. fetched async) and
49
+ * a stack of SkeletonChip shimmer rows is rendered in their place instead
50
+ * of `entries`. Automatically switches to icon-only skeleton rows when
51
+ * the sidebar is collapsed.
52
+ */
53
+ loading?: boolean;
54
+
55
+ /** Number of skeleton rows to show while `loading` is true. Defaults to 5. */
56
+ loadingCount?: number;
57
+
46
58
  /** ID of the currently-active top-level entry. */
47
59
  activeId?: string;
48
60
 
@@ -65,22 +77,36 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
65
77
  // ── Footer opt-in props ──────────────────────────────────────────────────
66
78
 
67
79
  /**
68
- * When provided, renders a WorkspaceMenu with this name in the nav area
69
- * (above entries). If omitted the WorkspaceMenu is not shown.
80
+ * @deprecated The workspace dropdown is no longer rendered. Accepted so
81
+ * existing callers keep type-checking; the value is ignored.
70
82
  */
71
83
  workspaceName?: string;
72
84
 
73
85
  /**
74
- * When true, renders the "Share Lovable" referral card in the footer.
75
- * Defaults to false.
86
+ * When provided, renders an UpgradeCard promo above the bottom bar and
87
+ * calls this when the whole card is clicked. If omitted the card is not
88
+ * shown. Hidden entirely when the sidebar is collapsed.
89
+ */
90
+ onUpgradeClick?: () => void;
91
+
92
+ /**
93
+ * Title text displayed in the UpgradeCard. Only used when onUpgradeClick
94
+ * is provided. Defaults to "Upgrade to Pro".
95
+ */
96
+ upgradeTitle?: string;
97
+
98
+ /**
99
+ * Subtitle text displayed in the UpgradeCard. Only used when onUpgradeClick
100
+ * is provided. Defaults to "Unlock more features".
76
101
  */
77
- showShareCard?: boolean;
102
+ upgradeSubtitle?: string;
78
103
 
79
104
  /**
80
- * When true, renders the UpgradeCard in the footer.
81
- * Defaults to false.
105
+ * Optional credits usage forwarded to the UpgradeCard `credits` prop.
106
+ * Only used when onUpgradeClick is provided. When omitted the card renders
107
+ * without a credits block.
82
108
  */
83
- showUpgradeCard?: boolean;
109
+ upgradeCredits?: { remaining: number; total: number; helper?: string };
84
110
 
85
111
  /**
86
112
  * When provided, renders a user avatar chip in the footer with these initials.
@@ -90,17 +116,26 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
90
116
 
91
117
  /**
92
118
  * 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).
119
+ * that opens when the avatar is clicked (requires onLogout or onSettings to
120
+ * be set).
94
121
  */
95
122
  userEmail?: string;
96
123
 
97
124
  /**
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.
125
+ * When provided, the avatar becomes a menu trigger and the account menu
126
+ * includes a "Logout" item that calls this handler. The menu opens as soon
127
+ * as either onLogout or onSettings is provided.
101
128
  */
102
129
  onLogout?: () => void;
103
130
 
131
+ /**
132
+ * When provided, the avatar becomes a menu trigger and the account menu
133
+ * includes a "User Settings" item (above Logout) that closes the menu and
134
+ * calls this handler. The menu opens as soon as either onLogout or
135
+ * onSettings is provided.
136
+ */
137
+ onSettings?: () => void;
138
+
104
139
  /**
105
140
  * When provided, renders an inbox button in the footer and calls this on click.
106
141
  * If omitted the inbox button is not shown.
@@ -142,28 +177,14 @@ export interface AppSidebarProps extends React.HTMLAttributes<HTMLElement> {
142
177
  interface AccountMenuProps {
143
178
  userInitials: string;
144
179
  userEmail?: string;
145
- onLogout: () => void;
180
+ onLogout?: () => void;
181
+ onSettings?: () => void;
146
182
  }
147
183
 
148
- function AccountMenu({ userInitials, userEmail, onLogout }: AccountMenuProps) {
184
+ function AccountMenu({ userInitials, userEmail, onLogout, onSettings }: AccountMenuProps) {
149
185
  const [open, setOpen] = React.useState(false);
150
- const [mounted, setMounted] = React.useState(false);
151
- const [visible, setVisible] = React.useState(false);
152
186
  const containerRef = React.useRef<HTMLDivElement>(null);
153
187
 
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
188
  React.useEffect(() => {
168
189
  if (!open) return;
169
190
  const handler = (e: MouseEvent) => {
@@ -200,29 +221,40 @@ function AccountMenu({ userInitials, userEmail, onLogout }: AccountMenuProps) {
200
221
  {userInitials}
201
222
  </Button>
202
223
 
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
- )}
224
+ <div
225
+ role="menu"
226
+ aria-label="Account"
227
+ aria-hidden={!open}
228
+ data-state={open ? "open" : "closed"}
229
+ className="absolute left-0 bottom-full mb-xs origin-bottom rounded-sm bg-surface border border-hairline shadow-card overflow-hidden flex flex-col gap-0 p-0 transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:translate-y-1 data-[state=closed]:scale-95 data-[state=closed]:opacity-0"
230
+ style={{ minWidth: "200px", zIndex: open ? "var(--z-dropdown, 1000)" : undefined }}
231
+ >
232
+ {userEmail && (
233
+ <div className="px-md py-sm border-b border-hairline">
234
+ <span className="block text-body-sm text-ink font-weight-heading-sm truncate">
235
+ {userEmail}
236
+ </span>
237
+ </div>
238
+ )}
225
239
 
240
+ {onSettings && (
241
+ <Button
242
+ role="menuitem"
243
+ type="button"
244
+ variant="ghost"
245
+ size="sm"
246
+ onClick={() => {
247
+ setOpen(false);
248
+ onSettings();
249
+ }}
250
+ className="!w-full !justify-start !rounded-none !px-md !py-sm !gap-sm !text-ink"
251
+ >
252
+ <Icon name="settings-gear" className="size-4 shrink-0" />
253
+ <span>User Settings</span>
254
+ </Button>
255
+ )}
256
+
257
+ {onLogout && (
226
258
  <Button
227
259
  role="menuitem"
228
260
  type="button"
@@ -237,31 +269,39 @@ function AccountMenu({ userInitials, userEmail, onLogout }: AccountMenuProps) {
237
269
  <Icon name="logout-sign-out" className="size-4 shrink-0" />
238
270
  <span>Logout</span>
239
271
  </Button>
240
- </div>
241
- )}
272
+ )}
273
+ </div>
242
274
  </div>
243
275
  );
244
276
  }
245
277
 
246
278
  /* ─── Component ──────────────────────────────────────────────────────────── */
247
279
 
280
+ /** Fallback for when `transitionend` never fires (reduced motion, no animation). */
281
+ const WIDTH_TRANSITION_FALLBACK_MS = 180;
282
+
248
283
  export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
249
284
  (
250
285
  {
251
286
  brandName,
252
287
  entries,
288
+ loading = false,
289
+ loadingCount = 5,
253
290
  activeId,
254
291
  onSelect,
255
292
  activeSubId,
256
293
  onSubSelect,
257
294
  defaultExpandedIds,
258
295
  // footer opt-in props
259
- workspaceName,
260
- showShareCard = false,
261
- showUpgradeCard = false,
296
+ workspaceName: _workspaceName,
297
+ onUpgradeClick,
298
+ upgradeTitle,
299
+ upgradeSubtitle,
300
+ upgradeCredits,
262
301
  userInitials,
263
302
  userEmail,
264
303
  onLogout,
304
+ onSettings,
265
305
  onInboxClick,
266
306
  // dark mode toggle
267
307
  darkMode = false,
@@ -276,7 +316,7 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
276
316
  },
277
317
  ref,
278
318
  ) => {
279
- /* ── Collapse state ── */
319
+ /* ── Collapse state (drives the WIDTH class only) ── */
280
320
  const [internalCollapsed, setInternalCollapsed] = React.useState(false);
281
321
  const isControlled = collapsedProp !== undefined;
282
322
  const collapsed = isControlled ? collapsedProp : internalCollapsed;
@@ -287,6 +327,56 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
287
327
  onCollapsedChange?.(next);
288
328
  };
289
329
 
330
+ /* ── Settled chrome state ──
331
+ * `collapsed` flips the width immediately so the browser can paint the
332
+ * transition. `chromeCollapsed` lags behind: it only catches up once the
333
+ * width transition has finished, so labels, sub-items, the brand block and
334
+ * the upgrade card stay mounted (and get clipped by overflow-hidden) while
335
+ * the width animates. That keeps the long lists off the critical path of
336
+ * the frame that starts the animation. */
337
+ const [chromeCollapsed, setChromeCollapsed] = React.useState(collapsed);
338
+
339
+ const navRef = React.useRef<HTMLElement | null>(null);
340
+ const assignRef = React.useCallback(
341
+ (node: HTMLElement | null) => {
342
+ navRef.current = node;
343
+ if (typeof ref === "function") ref(node);
344
+ else if (ref) (ref as React.MutableRefObject<HTMLElement | null>).current = node;
345
+ },
346
+ [ref],
347
+ );
348
+
349
+ React.useEffect(() => {
350
+ if (chromeCollapsed === collapsed) return;
351
+
352
+ const node = navRef.current;
353
+ let settled = false;
354
+ let timer: number | undefined;
355
+
356
+ const settle = () => {
357
+ if (settled) return;
358
+ settled = true;
359
+ if (timer !== undefined) window.clearTimeout(timer);
360
+ node?.removeEventListener("transitionend", onTransitionEnd);
361
+ setChromeCollapsed(collapsed);
362
+ };
363
+
364
+ function onTransitionEnd(event: TransitionEvent) {
365
+ if (event.target !== node) return;
366
+ if (event.propertyName !== "width") return;
367
+ settle();
368
+ }
369
+
370
+ node?.addEventListener("transitionend", onTransitionEnd);
371
+ timer = window.setTimeout(settle, WIDTH_TRANSITION_FALLBACK_MS);
372
+
373
+ return () => {
374
+ settled = true;
375
+ if (timer !== undefined) window.clearTimeout(timer);
376
+ node?.removeEventListener("transitionend", onTransitionEnd);
377
+ };
378
+ }, [collapsed, chromeCollapsed]);
379
+
290
380
  /* ── Expanded subtree state (managed internally per the spec) ── */
291
381
  const [expandedIds, setExpandedIds] = React.useState<Set<string>>(
292
382
  () => new Set(defaultExpandedIds ?? []),
@@ -318,17 +408,23 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
318
408
  const hasEntries = entries && entries.length > 0;
319
409
 
320
410
  /* ── Footer visibility ── */
321
- const hasFooterPromoContent = showShareCard || showUpgradeCard;
411
+ const hasFooterPromoContent = !!onUpgradeClick;
322
412
  const hasFooterBottomContent = !!(userInitials || onInboxClick || onDarkModeToggle);
323
413
  const hasFooterContent = hasFooterPromoContent || hasFooterBottomContent;
414
+ const hasAccountMenu = !!(onLogout || onSettings);
415
+
416
+ /* ── Upgrade card title/subtitle defaults ── */
417
+ const finalUpgradeTitle = upgradeTitle ?? "Upgrade to Pro";
418
+ const finalUpgradeSubtitle = upgradeSubtitle ?? "Unlock more features";
324
419
 
325
420
  return (
326
421
  <nav
327
- ref={ref}
422
+ ref={assignRef}
328
423
  aria-label={brandName ?? "Application"}
329
424
  className={[
330
425
  "flex flex-col bg-canvas border-r border-hairline h-full overflow-hidden",
331
- "transition-all duration-300 ease-in-out",
426
+ // Collapse animates the width only — 150ms ease-out, no transition-all.
427
+ "transition-[width] duration-150 ease-out",
332
428
  collapsed ? "w-14" : "w-64",
333
429
  className,
334
430
  ]
@@ -339,27 +435,28 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
339
435
  {/* ── Header: logo / brand name + collapse toggle ── */}
340
436
  <div
341
437
  className={[
342
- "flex items-center px-md pt-md pb-sm flex-shrink-0 transition-all duration-300",
343
- collapsed ? "justify-center" : "justify-between",
438
+ "flex items-center px-md pt-md pb-sm flex-shrink-0",
439
+ chromeCollapsed ? "justify-center" : "justify-between",
344
440
  ].join(" ")}
345
441
  >
346
- {/* Brand area — fades out when collapsed */}
347
- <div
348
- className="transition-all duration-300 ease-in-out overflow-hidden flex-shrink-0 flex items-center gap-sm min-w-0"
349
- style={{ maxWidth: collapsed ? "0px" : "180px", opacity: collapsed ? 0 : 1 }}
350
- >
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>
357
- {brandName && (
358
- <span className="text-body-sm font-weight-heading-sm text-ink truncate">
359
- {brandName}
442
+ {/* Brand area — stays mounted while the width animates and is clipped
443
+ by the nav's overflow; swapped out once the width has settled.
444
+ It shrinks (min-w-0) so the toggle stays reachable mid-animation. */}
445
+ {!chromeCollapsed && (
446
+ <div className="overflow-hidden flex-1 min-w-0 flex items-center gap-sm">
447
+ <span
448
+ className="flex items-center justify-center rounded-md bg-primary text-on-primary flex-shrink-0"
449
+ style={{ width: "32px", height: "32px" }}
450
+ >
451
+ <Icon name="sparkle" className="size-4" />
360
452
  </span>
361
- )}
362
- </div>
453
+ {brandName && (
454
+ <span className="text-body-sm font-weight-heading-sm text-ink truncate">
455
+ {brandName}
456
+ </span>
457
+ )}
458
+ </div>
459
+ )}
363
460
 
364
461
  {/* Collapse toggle */}
365
462
  <Button
@@ -368,8 +465,8 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
368
465
  aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
369
466
  onClick={handleCollapse}
370
467
  className={[
371
- "!p-xs !rounded-md flex-shrink-0 transition-all duration-200",
372
- collapsed
468
+ "!p-xs !rounded-md flex-shrink-0 transition-[background-color,box-shadow,color] duration-200 ease-out",
469
+ chromeCollapsed
373
470
  ? "!text-primary ring-2 ring-primary !bg-transparent hover:!bg-surface-soft"
374
471
  : "",
375
472
  ]
@@ -382,22 +479,19 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
382
479
 
383
480
  {/* ── Scrollable nav area ── */}
384
481
  <div className="flex-1 overflow-y-auto overflow-x-hidden px-sm space-y-xxs pb-sm">
385
- {/* Workspace selector — only when workspaceName provided and not collapsed */}
386
- {workspaceName && (
387
- <div
388
- className="overflow-hidden transition-all duration-300 ease-in-out"
389
- style={{
390
- maxHeight: collapsed ? "0px" : "60px",
391
- opacity: collapsed ? 0 : 1,
392
- marginBottom: collapsed ? "0px" : "8px",
393
- }}
394
- >
395
- <WorkspaceMenu workspaceName={workspaceName} initials={workspaceName.charAt(0).toUpperCase()} />
396
- </div>
482
+ {/* ── Loading state: shimmer rows stand in for the nav entries,
483
+ sized to match a real NavItem row exactly ── */}
484
+ {loading && (
485
+ <SkeletonChip
486
+ shape="row"
487
+ count={loadingCount}
488
+ iconOnly={chromeCollapsed}
489
+ label="Loading navigation"
490
+ />
397
491
  )}
398
492
 
399
493
  {/* ── Generic entries (new API) ── */}
400
- {hasEntries && (
494
+ {!loading && hasEntries && (
401
495
  <ul className="space-y-xxs" role="list">
402
496
  {entries!.map((entry) => {
403
497
  const isActive = resolvedActiveId === entry.id;
@@ -409,6 +503,9 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
409
503
  // Only pass subItems when there are actual sub-items — this ensures
410
504
  // NavItem's isExpandable check (subItems && subItems.length > 0) is
411
505
  // false for leaf entries, preventing the chevron from appearing.
506
+ // Sub-items stay mounted while the width animates (chromeCollapsed
507
+ // still false), so React does not tear down long lists in the frame
508
+ // that starts the collapse.
412
509
  const mappedSubItems: NavItemSubItem[] | undefined = hasSubItems
413
510
  ? entry.subItems!.map((sub) => ({
414
511
  id: sub.id,
@@ -426,9 +523,9 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
426
523
  icon={entry.icon}
427
524
  label={entry.label}
428
525
  active={isActive}
429
- iconOnly={collapsed}
526
+ iconOnly={chromeCollapsed}
430
527
  alwaysExpanded={isAlwaysExpanded}
431
- subItems={!collapsed ? mappedSubItems : undefined}
528
+ subItems={!chromeCollapsed ? mappedSubItems : undefined}
432
529
  expanded={hasSubItems ? isExpanded : undefined}
433
530
  onExpandToggle={
434
531
  hasSubItems && !isAlwaysExpanded ? () => toggleExpanded(entry.id) : undefined
@@ -445,11 +542,16 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
445
542
  </ul>
446
543
  )}
447
544
 
448
- {/* ── Optional children rendered below nav (only when expanded) ── */}
545
+ {/* ── Optional children rendered below nav ──
546
+ Kept mounted (never unmounted) and clipped while collapsed, with no
547
+ max-height / opacity animation so the chrome swap stays instant. */}
449
548
  {children && (
450
549
  <div
451
- className="overflow-hidden transition-all duration-300 ease-in-out"
452
- style={{ maxHeight: collapsed ? "0px" : "600px", opacity: collapsed ? 0 : 1 }}
550
+ className="overflow-hidden"
551
+ style={{
552
+ maxHeight: chromeCollapsed ? "0px" : "600px",
553
+ opacity: chromeCollapsed ? 0 : 1,
554
+ }}
453
555
  >
454
556
  {children}
455
557
  </div>
@@ -459,49 +561,36 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
459
561
  {/* ── Footer (only renders when there is footer content) ── */}
460
562
  {hasFooterContent && (
461
563
  <div className="flex-shrink-0 px-sm pb-md space-y-sm">
462
- {/* Promo cards — hidden when collapsed */}
463
- {hasFooterPromoContent && (
464
- <div
465
- className="overflow-hidden transition-all duration-300 ease-in-out space-y-sm"
466
- style={{ maxHeight: collapsed ? "0px" : "300px", opacity: collapsed ? 0 : 1 }}
467
- >
468
- {/* Share card */}
469
- {showShareCard && (
470
- <div className="rounded-xl border border-hairline bg-surface px-md py-sm flex items-center justify-between gap-md">
471
- <div className="flex flex-col gap-xxs min-w-0">
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>
474
- </div>
475
- <span
476
- className="flex-shrink-0 flex items-center justify-center rounded-full bg-surface-strong"
477
- style={{ width: "36px", height: "36px" }}
478
- >
479
- <Icon name="gift-present" className="size-5" />
480
- </span>
481
- </div>
482
- )}
483
-
484
- {/* Upgrade to Pro */}
485
- {showUpgradeCard && (
486
- <UpgradeCard eyebrow="" title="Upgrade to Pro" subtitle="Unlock more features" />
487
- )}
488
- </div>
564
+ {/* Upgrade card — stays mounted during the width transition (clipped by
565
+ the nav's overflow) and is removed only once the width has settled. */}
566
+ {hasFooterPromoContent && !chromeCollapsed && (
567
+ <UpgradeCard
568
+ title={finalUpgradeTitle}
569
+ subtitle={finalUpgradeSubtitle}
570
+ onClick={onUpgradeClick}
571
+ credits={upgradeCredits}
572
+ />
489
573
  )}
490
574
 
491
575
  {/* Bottom bar: user avatar (+ account menu) + inbox + dark mode toggle */}
492
576
  {hasFooterBottomContent && (
493
577
  <div
494
578
  className={[
495
- "flex items-center pt-xs transition-all duration-300",
496
- collapsed ? "justify-center flex-col gap-xs" : "justify-between",
579
+ "flex items-center pt-xs",
580
+ chromeCollapsed ? "justify-center flex-col gap-xs" : "justify-between",
497
581
  ].join(" ")}
498
582
  >
499
583
  {/* 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). */}
584
+ trigger with an email header + User Settings / Logout items as
585
+ soon as either onLogout or onSettings is provided. */}
502
586
  {userInitials && (
503
- onLogout ? (
504
- <AccountMenu userInitials={userInitials} userEmail={userEmail} onLogout={onLogout} />
587
+ hasAccountMenu ? (
588
+ <AccountMenu
589
+ userInitials={userInitials}
590
+ userEmail={userEmail}
591
+ onLogout={onLogout}
592
+ onSettings={onSettings}
593
+ />
505
594
  ) : (
506
595
  <span
507
596
  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"
@@ -513,12 +602,9 @@ export const AppSidebar = React.forwardRef<HTMLElement, AppSidebarProps>(
513
602
  )
514
603
  )}
515
604
 
516
- {/* Inbox — only when onInboxClick provided, fades out when collapsed */}
605
+ {/* Inbox — only when onInboxClick provided, clipped while collapsed */}
517
606
  {onInboxClick && (
518
- <div
519
- className="overflow-hidden transition-all duration-300 ease-in-out"
520
- style={{ maxWidth: collapsed ? "0px" : "40px", opacity: collapsed ? 0 : 1 }}
521
- >
607
+ <div className="overflow-hidden">
522
608
  <Button
523
609
  variant="ghost"
524
610
  size="sm"
@@ -1,2 +1,2 @@
1
1
  export { AppSidebar } from "./AppSidebar";
2
- export type { AppSidebarProps } from "./AppSidebar";
2
+ export type { AppSidebarProps, NavEntry, NavSubItem } from "./AppSidebar";