@designa8/vibedesign-v6 1.10.3 → 1.10.5

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.
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import ReactDOM from "react-dom";
2
3
  import { Button } from "../Button";
3
4
  import { NavItem } from "../NavItem";
4
5
  import { WorkspaceMenu } from "../WorkspaceMenu";
@@ -174,6 +175,202 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
174
175
  /* ── Whether the footer row should be rendered at all ── */
175
176
  const showFooterRow = !!(userInitials || onInboxClick || onDarkModeToggle);
176
177
 
178
+ /* ── Overlay JSX — lifted out so it can be portalled ── */
179
+ const overlayContent = mounted ? (
180
+ <div
181
+ role="dialog"
182
+ aria-modal="true"
183
+ aria-label="Navigation menu"
184
+ style={{
185
+ position: "fixed",
186
+ inset: 0,
187
+ zIndex: 9999,
188
+ }}
189
+ >
190
+ {/* Scrim */}
191
+ <div
192
+ aria-hidden="true"
193
+ onClick={() => setOpen(false)}
194
+ style={{
195
+ position: "absolute",
196
+ inset: 0,
197
+ backgroundColor: "var(--color-scrim)",
198
+ opacity: visible ? 0.5 : 0,
199
+ transition: "opacity 0.25s ease",
200
+ }}
201
+ />
202
+
203
+ {/* Drawer panel */}
204
+ <div
205
+ style={{
206
+ position: "absolute",
207
+ top: 0,
208
+ left: 0,
209
+ bottom: 0,
210
+ width: "min(280px, 85vw)",
211
+ display: "flex",
212
+ flexDirection: "column",
213
+ backgroundColor: "var(--color-canvas)",
214
+ borderRight: "1px solid var(--color-hairline)",
215
+ boxShadow: "var(--shadow-lg)",
216
+ transform: visible ? "translateX(0)" : "translateX(-100%)",
217
+ transition: "transform 0.28s cubic-bezier(0.32,0,0.15,1)",
218
+ overflowY: "auto",
219
+ overflowX: "hidden",
220
+ }}
221
+ >
222
+ {/* Header */}
223
+ <div
224
+ className="flex items-center justify-between px-md pt-md pb-sm flex-shrink-0"
225
+ style={{ backgroundColor: "var(--color-canvas)" }}
226
+ >
227
+ <div className="flex items-center gap-sm">
228
+ <LogoIcon />
229
+ <span className="text-body-sm font-weight-heading-sm text-ink truncate">{brandName}</span>
230
+ </div>
231
+ <Button
232
+ variant="ghost"
233
+ size="sm"
234
+ aria-label="Close navigation"
235
+ onClick={() => setOpen(false)}
236
+ className="!p-xs !rounded-md"
237
+ >
238
+ <CloseIcon />
239
+ </Button>
240
+ </div>
241
+
242
+ {/* Workspace switcher */}
243
+ {workspaceName && (
244
+ <div
245
+ className="px-sm pb-sm"
246
+ style={{ backgroundColor: "var(--color-canvas)" }}
247
+ >
248
+ <WorkspaceMenu
249
+ workspaceName={workspaceName}
250
+ initials={workspaceName.charAt(0).toUpperCase()}
251
+ />
252
+ </div>
253
+ )}
254
+
255
+ {/* Nav entries */}
256
+ <div
257
+ className="flex-1 overflow-y-auto px-sm pb-sm"
258
+ style={{ backgroundColor: "var(--color-canvas)" }}
259
+ >
260
+ <ul className="space-y-xxs" role="list">
261
+ {entries.map((entry) => {
262
+ const isActive = activeId === entry.id;
263
+ const hasSubItems = !!(entry.subItems?.length);
264
+ const isExpanded = expandedIds.has(entry.id);
265
+
266
+ const mappedSubItems: NavItemSubItem[] | undefined = hasSubItems
267
+ ? entry.subItems!.map((sub) => ({
268
+ id: sub.id,
269
+ label: sub.label,
270
+ onDelete: sub.onDelete,
271
+ onClick: onSubSelect
272
+ ? (_id: string) => { onSubSelect(_id); setOpen(false); }
273
+ : undefined,
274
+ }))
275
+ : undefined;
276
+
277
+ return (
278
+ <NavItem
279
+ key={entry.id}
280
+ icon={entry.icon}
281
+ label={entry.label}
282
+ active={isActive}
283
+ subItems={mappedSubItems}
284
+ expanded={hasSubItems ? isExpanded : undefined}
285
+ onExpandToggle={hasSubItems ? () => toggleExpanded(entry.id) : undefined}
286
+ onClick={(e) => {
287
+ onSelect?.(entry.id);
288
+ if (!hasSubItems) setOpen(false);
289
+ else e.preventDefault();
290
+ }}
291
+ />
292
+ );
293
+ })}
294
+ </ul>
295
+ </div>
296
+
297
+ {/* Footer */}
298
+ <div
299
+ className="flex-shrink-0 px-sm pb-lg space-y-sm"
300
+ style={{ backgroundColor: "var(--color-canvas)" }}
301
+ >
302
+ {showShareCard && (
303
+ <div className="rounded-xl border border-hairline bg-surface px-md py-sm flex items-center justify-between gap-md">
304
+ <div className="flex flex-col gap-xxs min-w-0">
305
+ <span className="text-body-sm font-weight-heading-sm text-ink">Share &amp; earn</span>
306
+ <span className="text-caption text-muted">100 credits per paid referral</span>
307
+ </div>
308
+ <span
309
+ className="flex-shrink-0 flex items-center justify-center rounded-full bg-surface-strong"
310
+ style={{ width: "36px", height: "36px" }}
311
+ >
312
+ <GiftIcon />
313
+ </span>
314
+ </div>
315
+ )}
316
+
317
+ {showUpgradeCard && (
318
+ <UpgradeCard eyebrow="" title="Upgrade to Pro" subtitle="Unlock more features" />
319
+ )}
320
+
321
+ {showFooterRow && (
322
+ <div className="flex items-center justify-between pt-xs">
323
+ {/* User avatar */}
324
+ {userInitials && (
325
+ <span
326
+ 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"
327
+ style={{ width: "36px", height: "36px" }}
328
+ aria-label="User profile"
329
+ >
330
+ {userInitials}
331
+ </span>
332
+ )}
333
+
334
+ {/* Right-side icon group */}
335
+ <div className="flex items-center gap-xs ml-auto">
336
+ {/* Dark mode toggle — only rendered when callback is provided */}
337
+ {onDarkModeToggle && (
338
+ <Button
339
+ variant="ghost"
340
+ size="sm"
341
+ aria-label={darkMode ? "Switch to light mode" : "Switch to dark mode"}
342
+ onClick={onDarkModeToggle}
343
+ className="!p-xs !rounded-sm"
344
+ >
345
+ {darkMode ? <SunIcon /> : <MoonIcon />}
346
+ </Button>
347
+ )}
348
+
349
+ {/* Inbox button */}
350
+ {onInboxClick && (
351
+ <Button
352
+ variant="ghost"
353
+ size="sm"
354
+ aria-label="Inbox"
355
+ onClick={onInboxClick}
356
+ className="!p-xs !rounded-sm relative"
357
+ >
358
+ <InboxIcon />
359
+ <span
360
+ className="absolute rounded-full bg-semantic-error"
361
+ aria-label="New notifications"
362
+ style={{ width: "8px", height: "8px", top: "4px", right: "4px" }}
363
+ />
364
+ </Button>
365
+ )}
366
+ </div>
367
+ </div>
368
+ )}
369
+ </div>
370
+ </div>
371
+ </div>
372
+ ) : null;
373
+
177
374
  return (
178
375
  <>
179
376
  {/* ── Trigger ── */}
@@ -190,205 +387,15 @@ export const AppSidebarMobile = React.forwardRef<HTMLDivElement, AppSidebarMobil
190
387
  </Button>
191
388
  </div>
192
389
 
193
- {/* ── Overlay — rendered as a sibling in the same DOM tree,
194
- uses fixed positioning so it covers the full viewport.
195
- No portal needed — fixed elements always escape overflow clipping.
196
- The drawer panel gets an EXPLICIT inline background-color so it
197
- can never inherit transparency from any ancestor. ── */}
198
- {mounted && (
199
- <div
200
- role="dialog"
201
- aria-modal="true"
202
- aria-label="Navigation menu"
203
- style={{
204
- position: "fixed",
205
- inset: 0,
206
- zIndex: 9999,
207
- }}
208
- >
209
- {/* Scrim */}
210
- <div
211
- aria-hidden="true"
212
- onClick={() => setOpen(false)}
213
- style={{
214
- position: "absolute",
215
- inset: 0,
216
- backgroundColor: "var(--color-scrim)",
217
- opacity: visible ? 0.5 : 0,
218
- transition: "opacity 0.25s ease",
219
- }}
220
- />
221
-
222
- {/* Drawer panel */}
223
- <div
224
- style={{
225
- position: "absolute",
226
- top: 0,
227
- left: 0,
228
- bottom: 0,
229
- width: "min(280px, 85vw)",
230
- display: "flex",
231
- flexDirection: "column",
232
- backgroundColor: "var(--color-canvas)",
233
- borderRight: "1px solid var(--color-hairline)",
234
- boxShadow: "var(--shadow-lg)",
235
- transform: visible ? "translateX(0)" : "translateX(-100%)",
236
- transition: "transform 0.28s cubic-bezier(0.32,0,0.15,1)",
237
- overflowY: "auto",
238
- overflowX: "hidden",
239
- }}
240
- >
241
- {/* Header */}
242
- <div
243
- className="flex items-center justify-between px-md pt-md pb-sm flex-shrink-0"
244
- style={{ backgroundColor: "var(--color-canvas)" }}
245
- >
246
- <div className="flex items-center gap-sm">
247
- <LogoIcon />
248
- <span className="text-body-sm font-weight-heading-sm text-ink truncate">{brandName}</span>
249
- </div>
250
- <Button
251
- variant="ghost"
252
- size="sm"
253
- aria-label="Close navigation"
254
- onClick={() => setOpen(false)}
255
- className="!p-xs !rounded-md"
256
- >
257
- <CloseIcon />
258
- </Button>
259
- </div>
260
-
261
- {/* Workspace switcher */}
262
- {workspaceName && (
263
- <div
264
- className="px-sm pb-sm"
265
- style={{ backgroundColor: "var(--color-canvas)" }}
266
- >
267
- <WorkspaceMenu
268
- workspaceName={workspaceName}
269
- initials={workspaceName.charAt(0).toUpperCase()}
270
- />
271
- </div>
272
- )}
273
-
274
- {/* Nav entries */}
275
- <div
276
- className="flex-1 overflow-y-auto px-sm pb-sm"
277
- style={{ backgroundColor: "var(--color-canvas)" }}
278
- >
279
- <ul className="space-y-xxs" role="list">
280
- {entries.map((entry) => {
281
- const isActive = activeId === entry.id;
282
- const hasSubItems = !!(entry.subItems?.length);
283
- const isExpanded = expandedIds.has(entry.id);
284
-
285
- const mappedSubItems: NavItemSubItem[] | undefined = hasSubItems
286
- ? entry.subItems!.map((sub) => ({
287
- id: sub.id,
288
- label: sub.label,
289
- onDelete: sub.onDelete,
290
- onClick: onSubSelect
291
- ? (_id: string) => { onSubSelect(_id); setOpen(false); }
292
- : undefined,
293
- }))
294
- : undefined;
295
-
296
- return (
297
- <NavItem
298
- key={entry.id}
299
- icon={entry.icon}
300
- label={entry.label}
301
- active={isActive}
302
- subItems={mappedSubItems}
303
- expanded={hasSubItems ? isExpanded : undefined}
304
- onExpandToggle={hasSubItems ? () => toggleExpanded(entry.id) : undefined}
305
- onClick={(e) => {
306
- onSelect?.(entry.id);
307
- if (!hasSubItems) setOpen(false);
308
- else e.preventDefault();
309
- }}
310
- />
311
- );
312
- })}
313
- </ul>
314
- </div>
315
-
316
- {/* Footer */}
317
- <div
318
- className="flex-shrink-0 px-sm pb-lg space-y-sm"
319
- style={{ backgroundColor: "var(--color-canvas)" }}
320
- >
321
- {showShareCard && (
322
- <div className="rounded-xl border border-hairline bg-surface px-md py-sm flex items-center justify-between gap-md">
323
- <div className="flex flex-col gap-xxs min-w-0">
324
- <span className="text-body-sm font-weight-heading-sm text-ink">Share &amp; earn</span>
325
- <span className="text-caption text-muted">100 credits per paid referral</span>
326
- </div>
327
- <span
328
- className="flex-shrink-0 flex items-center justify-center rounded-full bg-surface-strong"
329
- style={{ width: "36px", height: "36px" }}
330
- >
331
- <GiftIcon />
332
- </span>
333
- </div>
334
- )}
335
-
336
- {showUpgradeCard && (
337
- <UpgradeCard eyebrow="" title="Upgrade to Pro" subtitle="Unlock more features" />
338
- )}
339
-
340
- {showFooterRow && (
341
- <div className="flex items-center justify-between pt-xs">
342
- {/* User avatar */}
343
- {userInitials && (
344
- <span
345
- 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"
346
- style={{ width: "36px", height: "36px" }}
347
- aria-label="User profile"
348
- >
349
- {userInitials}
350
- </span>
351
- )}
352
-
353
- {/* Right-side icon group */}
354
- <div className="flex items-center gap-xs ml-auto">
355
- {/* Dark mode toggle — only rendered when callback is provided */}
356
- {onDarkModeToggle && (
357
- <Button
358
- variant="ghost"
359
- size="sm"
360
- aria-label={darkMode ? "Switch to light mode" : "Switch to dark mode"}
361
- onClick={onDarkModeToggle}
362
- className="!p-xs !rounded-sm"
363
- >
364
- {darkMode ? <SunIcon /> : <MoonIcon />}
365
- </Button>
366
- )}
367
-
368
- {/* Inbox button */}
369
- {onInboxClick && (
370
- <Button
371
- variant="ghost"
372
- size="sm"
373
- aria-label="Inbox"
374
- onClick={onInboxClick}
375
- className="!p-xs !rounded-sm relative"
376
- >
377
- <InboxIcon />
378
- <span
379
- className="absolute rounded-full bg-semantic-error"
380
- aria-label="New notifications"
381
- style={{ width: "8px", height: "8px", top: "4px", right: "4px" }}
382
- />
383
- </Button>
384
- )}
385
- </div>
386
- </div>
387
- )}
388
- </div>
389
- </div>
390
- </div>
391
- )}
390
+ {/*
391
+ ── Overlay — rendered via ReactDOM.createPortal into document.body.
392
+ This ensures the fixed-position overlay always escapes any ancestor
393
+ stacking context created by `position: relative` + `z-index` on a
394
+ parent element. The typeof window guard makes it safe in SSR.
395
+ */}
396
+ {typeof window !== "undefined"
397
+ ? ReactDOM.createPortal(overlayContent, document.body)
398
+ : overlayContent}
392
399
  </>
393
400
  );
394
401
  },
@@ -93,6 +93,16 @@ export interface HomePageTemplateProps {
93
93
  activeSubId?: string;
94
94
  /** Forwarded to AppSidebar as `onSubSelect`. */
95
95
  onSubSelect?: (id: string) => void;
96
+ /**
97
+ * Whether dark mode is currently active. Forwarded to both AppSidebar and
98
+ * AppSidebarMobile so they can show the correct sun/moon icon.
99
+ */
100
+ darkMode?: boolean;
101
+ /**
102
+ * Called when the user clicks the dark/light mode toggle in either sidebar.
103
+ * Forwarded to both AppSidebar and AppSidebarMobile.
104
+ */
105
+ onDarkModeToggle?: () => void;
96
106
  className?: string;
97
107
  style?: React.CSSProperties;
98
108
  }
@@ -146,6 +156,8 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
146
156
  onSelect,
147
157
  activeSubId,
148
158
  onSubSelect,
159
+ darkMode,
160
+ onDarkModeToggle,
149
161
  className,
150
162
  style,
151
163
  },
@@ -204,6 +216,8 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
204
216
  showUpgradeCard={true}
205
217
  userInitials={userInitials}
206
218
  onInboxClick={() => {}}
219
+ darkMode={darkMode}
220
+ onDarkModeToggle={onDarkModeToggle}
207
221
  style={{ height: "100%" }}
208
222
  />
209
223
  </div>
@@ -234,6 +248,8 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
234
248
  showUpgradeCard={true}
235
249
  userInitials={userInitials}
236
250
  onInboxClick={() => {}}
251
+ darkMode={darkMode}
252
+ onDarkModeToggle={onDarkModeToggle}
237
253
  />
238
254
  <div className="flex items-center gap-xs">
239
255
  <LogoIcon />
@@ -2,6 +2,8 @@ import React from "react";
2
2
  import { HomePageTemplate } from "./HomePageTemplate";
3
3
 
4
4
  export default function Preview() {
5
+ const [darkMode, setDarkMode] = React.useState(false);
6
+
5
7
  return (
6
8
  /* w-full satisfies the linter; the inner style drives the true 100vh fill. */
7
9
  <div className="w-full" style={{ height: "100vh", overflow: "hidden" }}>
@@ -14,6 +16,8 @@ export default function Preview() {
14
16
  "Type scale",
15
17
  "Card molecule",
16
18
  ]}
19
+ darkMode={darkMode}
20
+ onDarkModeToggle={() => setDarkMode((d) => !d)}
17
21
  style={{ width: "100%", height: "100%" }}
18
22
  />
19
23
  </div>