@designa8/vibedesign-v6 1.10.4 → 1.10.6

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
  },
@@ -4,7 +4,7 @@ import type { NavEntry } from "../AppSidebar";
4
4
  import { AppSidebarMobile } from "../AppSidebarMobile";
5
5
  import { PromptInputBar } from "../PromptInputBar";
6
6
  import { Button } from "../Button";
7
- import type { PromptMode } from "../PromptInputBar";
7
+ import type { PromptMode, PromptInputBarModel } from "../PromptInputBar";
8
8
 
9
9
  /* ─── Icons ─────────────────────────────────────────────────────────────── */
10
10
 
@@ -53,6 +53,15 @@ const SuggestionChip: React.FC<SuggestionChipProps> = ({ label, onClick }) => (
53
53
  </Button>
54
54
  );
55
55
 
56
+ /* ─── Default model list ─────────────────────────────────────────────────── */
57
+ const DEFAULT_MODELS: PromptInputBarModel[] = [
58
+ { id: "claude-sonnet", name: "Claude Sonnet 4.6" },
59
+ { id: "claude-haiku", name: "Claude Haiku 3.5", tier: "Fast" },
60
+ { id: "claude-opus", name: "Claude Opus 4", tier: "Pro" },
61
+ ];
62
+
63
+ const DEFAULT_SELECTED_MODEL_ID = "claude-sonnet";
64
+
56
65
  /* ─── Types ──────────────────────────────────────────────────────────────── */
57
66
 
58
67
  export interface HomePageTemplateProps {
@@ -103,6 +112,20 @@ export interface HomePageTemplateProps {
103
112
  * Forwarded to both AppSidebar and AppSidebarMobile.
104
113
  */
105
114
  onDarkModeToggle?: () => void;
115
+ /**
116
+ * List of available AI models forwarded to PromptInputBar.
117
+ * When omitted, the built-in DEFAULT_MODELS list is used.
118
+ */
119
+ models?: PromptInputBarModel[];
120
+ /**
121
+ * Currently selected model id forwarded to PromptInputBar.
122
+ * When omitted, defaults to "claude-sonnet".
123
+ */
124
+ selectedModelId?: string;
125
+ /**
126
+ * Called when the user picks a different model in PromptInputBar.
127
+ */
128
+ onModelChange?: (modelId: string) => void;
106
129
  className?: string;
107
130
  style?: React.CSSProperties;
108
131
  }
@@ -158,6 +181,9 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
158
181
  onSubSelect,
159
182
  darkMode,
160
183
  onDarkModeToggle,
184
+ models,
185
+ selectedModelId,
186
+ onModelChange,
161
187
  className,
162
188
  style,
163
189
  },
@@ -174,6 +200,10 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
174
200
 
175
201
  const textValue = promptValue !== undefined ? promptValue : internalPrompt;
176
202
 
203
+ // Resolve model list and selected model id, falling back to hardcoded defaults.
204
+ const resolvedModels = models !== undefined ? models : DEFAULT_MODELS;
205
+ const resolvedSelectedModelId = selectedModelId !== undefined ? selectedModelId : DEFAULT_SELECTED_MODEL_ID;
206
+
177
207
  const handleChange = (val: string) => {
178
208
  if (promptValue === undefined) setInternalPrompt(val);
179
209
  onPromptChange?.(val);
@@ -314,12 +344,9 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
314
344
  onModeChange={onModeChange}
315
345
  onSend={handleSend}
316
346
  onMic={() => {}}
317
- models={[
318
- { id: "claude-sonnet", name: "Claude Sonnet 4.6" },
319
- { id: "claude-haiku", name: "Claude Haiku 3.5", tier: "Fast" },
320
- { id: "claude-opus", name: "Claude Opus 4", tier: "Pro" },
321
- ]}
322
- selectedModelId="claude-sonnet"
347
+ models={resolvedModels}
348
+ selectedModelId={resolvedSelectedModelId}
349
+ onModelChange={onModelChange}
323
350
  />
324
351
  </div>
325
352
 
@@ -1,2 +1,3 @@
1
1
  export { HomePageTemplate } from "./HomePageTemplate";
2
2
  export type { HomePageTemplateProps } from "./HomePageTemplate";
3
+ export type { PromptInputBarModel } from "../PromptInputBar";