@designa8/vibedesign-v6 2.2.6 → 2.3.0

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.
@@ -26,14 +26,23 @@ const SuggestionChip: React.FC<SuggestionChipProps> = ({ label, onClick }) => (
26
26
  );
27
27
 
28
28
  /* ─── Default model list ─────────────────────────────────────────────────── */
29
+ /*
30
+ * Ordered strongest → lightest, which is also how the model menu reads. The
31
+ * default selection (see DEFAULT_SELECTED_MODEL_ID) sits in the middle of the
32
+ * list, so the first row of the menu is a model that is genuinely NOT the
33
+ * current one — picking it visibly moves the check mark and updates the
34
+ * reported model instead of re-selecting what was already selected.
35
+ */
29
36
  const DEFAULT_MODELS: PromptInputBarModel[] = [
37
+ { id: "claude-opus", name: "Claude Opus 4", tier: "Pro" },
30
38
  { id: "claude-sonnet", name: "Claude Sonnet 4.6" },
31
39
  { id: "claude-haiku", name: "Claude Haiku 3.5", tier: "Fast" },
32
- { id: "claude-opus", name: "Claude Opus 4", tier: "Pro" },
33
40
  ];
34
41
 
35
42
  const DEFAULT_SELECTED_MODEL_ID = "claude-sonnet";
36
43
 
44
+ const DEFAULT_MODE: PromptMode = "Build";
45
+
37
46
  /* ─── Default prompt placeholder ─────────────────────────────────────────── */
38
47
  const DEFAULT_PLACEHOLDER = "Describe an atom or design token to create...";
39
48
 
@@ -548,9 +557,16 @@ export interface HomePageTemplateProps {
548
557
  * "Describe an atom or design token to create...".
549
558
  */
550
559
  placeholder?: string;
551
- /** Current build mode */
560
+ /**
561
+ * Controlled build mode shown in the prompt bar. When omitted the template
562
+ * manages the mode itself, so picking Chat or Design in the mode list
563
+ * updates the trigger immediately.
564
+ */
552
565
  mode?: PromptMode;
553
- /** Called when mode changes */
566
+ /**
567
+ * Called when mode changes. Fired in addition to the internal mode update
568
+ * when `mode` is omitted (uncontrolled).
569
+ */
554
570
  onModeChange?: (mode: PromptMode) => void;
555
571
  /** Called when the send button is clicked */
556
572
  onSend?: (value: string) => void;
@@ -627,12 +643,15 @@ export interface HomePageTemplateProps {
627
643
  */
628
644
  models?: PromptInputBarModel[];
629
645
  /**
630
- * Currently selected model id forwarded to PromptInputBar.
631
- * When omitted, defaults to "claude-sonnet".
646
+ * Controlled selected model id forwarded to PromptInputBar. When omitted
647
+ * the template manages the selection itself, so picking a model in the
648
+ * prompt bar's model list updates the current model immediately.
632
649
  */
633
650
  selectedModelId?: string;
634
651
  /**
635
- * Called when the user picks a different model in PromptInputBar.
652
+ * Called when the user picks a different model in PromptInputBar. Fired in
653
+ * addition to the internal selection update when `selectedModelId` is
654
+ * omitted (uncontrolled).
636
655
  */
637
656
  onModelChange?: (modelId: string) => void;
638
657
  /**
@@ -855,7 +874,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
855
874
  promptValue,
856
875
  onPromptChange,
857
876
  placeholder = DEFAULT_PLACEHOLDER,
858
- mode = "Build",
877
+ mode: modeProp,
859
878
  onModeChange,
860
879
  onSend,
861
880
  suggestions = DEFAULT_SUGGESTIONS,
@@ -874,7 +893,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
874
893
  upgradeSubtitle,
875
894
  upgradeCredits,
876
895
  models,
877
- selectedModelId,
896
+ selectedModelId: selectedModelIdProp,
878
897
  onModelChange,
879
898
  onUnavailableModelClick,
880
899
  onMic,
@@ -902,6 +921,8 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
902
921
  ) => {
903
922
  const [internalPrompt, setInternalPrompt] = React.useState("");
904
923
  const [internalActiveId, setInternalActiveId] = React.useState("home");
924
+ const [internalMode, setInternalMode] = React.useState<PromptMode>(DEFAULT_MODE);
925
+ const [internalModelId, setInternalModelId] = React.useState(DEFAULT_SELECTED_MODEL_ID);
905
926
 
906
927
  // When activeIdProp is provided it controls the active entry; otherwise use internal state.
907
928
  const resolvedActiveId = activeIdProp !== undefined ? activeIdProp : internalActiveId;
@@ -911,9 +932,13 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
911
932
 
912
933
  const textValue = promptValue !== undefined ? promptValue : internalPrompt;
913
934
 
914
- // Resolve model list and selected model id, falling back to hardcoded defaults.
935
+ // Resolve model list, selected model id and mode, falling back to the
936
+ // internally-tracked values so picking a model or a mode updates what the
937
+ // prompt bar shows even when the consumer passes no handler.
915
938
  const resolvedModels = models !== undefined ? models : DEFAULT_MODELS;
916
- const resolvedSelectedModelId = selectedModelId !== undefined ? selectedModelId : DEFAULT_SELECTED_MODEL_ID;
939
+ const resolvedSelectedModelId =
940
+ selectedModelIdProp !== undefined ? selectedModelIdProp : internalModelId;
941
+ const resolvedMode = modeProp !== undefined ? modeProp : internalMode;
917
942
 
918
943
  // The mesh-blob composition renders whenever animatedBackground is on; under
919
944
  // prefers-reduced-motion the same composition stays but the CSS above freezes
@@ -930,6 +955,16 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
930
955
  if (promptValue === undefined) setInternalPrompt("");
931
956
  };
932
957
 
958
+ const handleModeChange = (next: PromptMode) => {
959
+ if (modeProp === undefined) setInternalMode(next);
960
+ onModeChange?.(next);
961
+ };
962
+
963
+ const handleModelChange = (modelId: string) => {
964
+ if (selectedModelIdProp === undefined) setInternalModelId(modelId);
965
+ onModelChange?.(modelId);
966
+ };
967
+
933
968
  // Composes the prompt from a suggestion label and WRITES it into the
934
969
  // prompt input — it never calls onSend. Used by both the "wrap" chip row
935
970
  // and the marquee rows. The label's casing is always preserved as-is;
@@ -978,7 +1013,14 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
978
1013
  >
979
1014
  <style>{HOME_TEMPLATE_STYLES}</style>
980
1015
 
981
- {/* ── Desktop sidebar — hidden on mobile ── */}
1016
+ {/* ── Desktop sidebar — hidden on mobile ──
1017
+ NOTE: `onInboxClick` is intentionally NOT passed. AppSidebar only
1018
+ renders its inbox button (and the permanent red notification dot
1019
+ that ships with it) when a click handler is supplied, and this
1020
+ screen has no inbox to open and no notifications to report. With
1021
+ the prop omitted neither the button nor the dot is rendered, and
1022
+ no replacement control is added. The avatar and the dark-mode
1023
+ toggle are unaffected. ── */}
982
1024
  <div className="hidden md:flex flex-shrink-0" style={{ height: "100%" }}>
983
1025
  <AppSidebar
984
1026
  workspaceName={userName}
@@ -989,7 +1031,6 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
989
1031
  onSubSelect={onSubSelect}
990
1032
  userInitials={userInitials}
991
1033
  userEmail={userEmail}
992
- onInboxClick={() => {}}
993
1034
  darkMode={darkMode}
994
1035
  onDarkModeToggle={onDarkModeToggle}
995
1036
  onLogout={onLogout}
@@ -1021,7 +1062,9 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
1021
1062
  )}
1022
1063
 
1023
1064
  {/* ── Mobile top bar — AppSidebarMobile IS the whole bar (brand left,
1024
- menu button right, menu expands downward). Visible only below md. ── */}
1065
+ menu button right, menu expands downward). Visible only below md.
1066
+ `onInboxClick` is likewise omitted so the drawer footer shows no
1067
+ inbox button and no notification dot. ── */}
1025
1068
  <AppSidebarMobile
1026
1069
  className="md:hidden relative z-10"
1027
1070
  brandName="Atoms"
@@ -1120,8 +1163,8 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
1120
1163
  placeholder={placeholder}
1121
1164
  value={textValue}
1122
1165
  onChange={handleChange}
1123
- mode={mode}
1124
- onModeChange={onModeChange}
1166
+ mode={resolvedMode}
1167
+ onModeChange={handleModeChange}
1125
1168
  onSend={handleSend}
1126
1169
  onMic={onMic}
1127
1170
  recording={recording}
@@ -1131,7 +1174,7 @@ export const HomePageTemplate = React.forwardRef<HTMLDivElement, HomePageTemplat
1131
1174
  onRecordingCancel={onRecordingCancel}
1132
1175
  models={resolvedModels}
1133
1176
  selectedModelId={resolvedSelectedModelId}
1134
- onModelChange={onModelChange}
1177
+ onModelChange={handleModelChange}
1135
1178
  onUnavailableModelClick={onUnavailableModelClick}
1136
1179
  showModeSelector={showModeSelector}
1137
1180
  suggestDesigns={suggestDesigns}
@@ -1,29 +1,52 @@
1
1
  import React from "react";
2
2
  import { HomePageTemplate } from "./HomePageTemplate";
3
+ import type { NavEntry } from "../AppSidebar";
4
+ import { Icon } from "../Icon";
5
+
6
+ /* A flat nav set for the demo: Home + All projects, so the canvas stays focused
7
+ * on the hero and prompt bar rather than a long project tree. */
8
+ const DEMO_NAV: NavEntry[] = [
9
+ { id: "home", label: "Home", icon: <Icon name="home" className="size-[18px]" /> },
10
+ { id: "projects", label: "All projects", icon: <Icon name="folder" className="size-[18px]" /> },
11
+ ];
3
12
 
4
13
  export default function Preview() {
5
14
  const [darkMode, setDarkMode] = React.useState(false);
15
+ const [prompt, setPrompt] = React.useState("");
16
+ const [lastSent, setLastSent] = React.useState<string | null>(null);
6
17
 
7
18
  return (
8
- <div className="w-full" style={{ height: "640px", overflow: "hidden" }}>
9
- <HomePageTemplate
10
- userName="Hello Designer"
11
- userInitials="N"
12
- suggestions={[
13
- "Primary button atom",
14
- "Brand color palette",
15
- "Type scale",
16
- "Card molecule",
17
- "Navbar organism",
18
- "Settings template",
19
- ]}
20
- suggestionsVariant="marquee"
21
- animatedBackground={true}
22
- darkMode={darkMode}
23
- onDarkModeToggle={() => setDarkMode((d) => !d)}
24
- onLogout={() => window.alert("Logged out")}
25
- style={{ width: "100%", height: "100%" }}
26
- />
19
+ <div className="w-full max-w-6xl mx-auto p-lg space-y-md">
20
+ <div
21
+ className="w-full rounded-xl border border-hairline overflow-hidden bg-canvas"
22
+ style={{ height: "640px" }}
23
+ >
24
+ <HomePageTemplate
25
+ userName="Hello Designer"
26
+ userInitials="N"
27
+ navEntries={DEMO_NAV}
28
+ suggestions={[
29
+ "Primary button atom",
30
+ "Brand color palette",
31
+ "Type scale",
32
+ "Card molecule",
33
+ "Navbar organism",
34
+ "Settings template",
35
+ ]}
36
+ suggestionsVariant="marquee"
37
+ animatedBackground={true}
38
+ darkMode={darkMode}
39
+ onDarkModeToggle={() => setDarkMode((d) => !d)}
40
+ promptValue={prompt}
41
+ onPromptChange={setPrompt}
42
+ onSend={(value) => setLastSent(value)}
43
+ style={{ width: "100%", height: "100%" }}
44
+ />
45
+ </div>
46
+
47
+ <p className="text-body-sm text-muted">
48
+ {lastSent ? `Sent: ${lastSent}` : "Pick a suggestion chip, change the mode, or send a prompt."}
49
+ </p>
27
50
  </div>
28
51
  );
29
52
  }
@@ -97,6 +97,9 @@ export const ICON_REGISTRY = {
97
97
  "landmark": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M10 18v-7" }, { tag: "path", d: "M11.12 2.198a2 2 0 0 1 1.76.006l7.866 3.847c.476.233.31.949-.22.949H3.474c-.53 0-.695-.716-.22-.949z" }, { tag: "path", d: "M14 18v-7" }, { tag: "path", d: "M18 18v-7" }, { tag: "path", d: "M3 22h18" }, { tag: "path", d: "M6 18v-7" }] },
98
98
  "circle-user": { viewBox: "0 0 24 24", nodes: [{ tag: "circle", cx: "12", cy: "12", r: "10" }, { tag: "circle", cx: "12", cy: "10", r: "3" }, { tag: "path", d: "M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662" }] },
99
99
  "pencil": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }, { tag: "path", d: "m15 5 4 4" }] },
100
+ "circle-dot": { viewBox: "0 0 24 24", nodes: [{ tag: "circle", cx: "12", cy: "12", r: "10" }, { tag: "circle", cx: "12", cy: "12", r: "1" }] },
101
+ "bot": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 8V4H8" }, { tag: "rect", width: "16", height: "12", x: "4", y: "8", rx: "2" }, { tag: "path", d: "M2 14h2" }, { tag: "path", d: "M20 14h2" }, { tag: "path", d: "M15 13v2" }, { tag: "path", d: "M9 13v2" }] },
102
+ "x": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M18 6 6 18" }, { tag: "path", d: "m6 6 12 12" }] },
100
103
  } as const;
101
104
 
102
105
  export type IconName = keyof typeof ICON_REGISTRY;
@@ -42,6 +42,9 @@ export interface PromptInputBarProps {
42
42
  /**
43
43
  * Called when "Upload file" is chosen in the + menu.
44
44
  * When onFilesSelected is also provided, onFilesSelected takes priority.
45
+ * When NEITHER is provided the bar cannot accept files, so the "Upload
46
+ * file" row is not rendered at all and the + menu opens straight onto the
47
+ * model list (a dead upload row is never shown).
45
48
  */
46
49
  onAttach?: () => void;
47
50
  /**
@@ -224,12 +227,20 @@ export const PromptInputBar = React.forwardRef<
224
227
  },
225
228
  ref,
226
229
  ) => {
230
+ /* Whether this bar can actually take a file. When it cannot, the
231
+ "Upload file" row is not rendered — a menu option that silently does
232
+ nothing is worse than no option at all. The + menu then opens straight
233
+ onto the model list, so its first row is a real selection. */
234
+ const hasUploadPath = Boolean(onFilesSelected || onAttach);
235
+
227
236
  const uid = React.useId();
228
237
  const [internalValue, setInternalValue] = React.useState("");
229
238
  const [internalImages, setInternalImages] = React.useState<PastedImage[]>([]);
230
239
  const [modeOpen, setModeOpen] = React.useState(false);
231
240
  const [menuOpen, setMenuOpen] = React.useState(false);
232
- const [menuView, setMenuView] = React.useState<"root" | "models">("root");
241
+ const [menuView, setMenuView] = React.useState<"root" | "models">(
242
+ hasUploadPath ? "root" : "models",
243
+ );
233
244
  const [internalSuggestDesigns, setInternalSuggestDesigns] = React.useState(false);
234
245
  const [internalRecording, setInternalRecording] = React.useState(false);
235
246
  const [seconds, setSeconds] = React.useState(0);
@@ -253,8 +264,8 @@ export const PromptInputBar = React.forwardRef<
253
264
 
254
265
  const closeMenu = React.useCallback(() => {
255
266
  setMenuOpen(false);
256
- setMenuView("root");
257
- }, []);
267
+ setMenuView(hasUploadPath ? "root" : "models");
268
+ }, [hasUploadPath]);
258
269
 
259
270
  useClickOutside(modeRef, React.useCallback(() => setModeOpen(false), []), modeOpen);
260
271
  useClickOutside(menuWrapRef, closeMenu, menuOpen);
@@ -465,7 +476,7 @@ export const PromptInputBar = React.forwardRef<
465
476
  return;
466
477
  }
467
478
  if (e.key === "ArrowLeft" || e.key === "Backspace") {
468
- if (menuView === "models") {
479
+ if (menuView === "models" && hasUploadPath) {
469
480
  e.preventDefault();
470
481
  setMenuView("root");
471
482
  }
@@ -484,7 +495,7 @@ export const PromptInputBar = React.forwardRef<
484
495
  const next = idx === -1 ? 0 : (idx + delta + items.length) % items.length;
485
496
  items[next]?.focus();
486
497
  }
487
- if (e.key === "ArrowRight" && menuView === "root" && hasModels) {
498
+ if (e.key === "ArrowRight" && menuView === "root" && hasModels && hasUploadPath) {
488
499
  const el = document.activeElement as HTMLElement | null;
489
500
  if (el?.dataset.menuItem === "models") {
490
501
  e.preventDefault();
@@ -649,23 +660,25 @@ export const PromptInputBar = React.forwardRef<
649
660
  inert={menuView !== "root"}
650
661
  className={`${VIEW} ${menuView === "root" ? "" : "-translate-x-2"}`}
651
662
  >
652
- <button
653
- type="button"
654
- role="menuitem"
655
- data-menu-item="upload"
656
- onClick={handleUploadClick}
657
- className={ROW}
658
- >
659
- <span className="flex size-9 flex-shrink-0 items-center justify-center rounded-md bg-surface-soft text-ink">
660
- <Icon name="upload" size={18} />
661
- </span>
662
- <span className="flex min-w-0 flex-1 flex-col">
663
- <span className="text-body-md text-ink">Upload file</span>
664
- <span className="text-caption text-muted">Images, PDFs and docs</span>
665
- </span>
666
- </button>
667
-
668
- {hasModels && (
663
+ {hasUploadPath && (
664
+ <button
665
+ type="button"
666
+ role="menuitem"
667
+ data-menu-item="upload"
668
+ onClick={handleUploadClick}
669
+ className={ROW}
670
+ >
671
+ <span className="flex size-9 flex-shrink-0 items-center justify-center rounded-md bg-surface-soft text-ink">
672
+ <Icon name="upload" size={18} />
673
+ </span>
674
+ <span className="flex min-w-0 flex-1 flex-col">
675
+ <span className="text-body-md text-ink">Upload file</span>
676
+ <span className="text-caption text-muted">Images, PDFs and docs</span>
677
+ </span>
678
+ </button>
679
+ )}
680
+
681
+ {hasModels && hasUploadPath && (
669
682
  <>
670
683
  <div role="separator" className="mx-sm my-xs h-px bg-hairline-soft" />
671
684
  <button
@@ -694,6 +707,67 @@ export const PromptInputBar = React.forwardRef<
694
707
  </button>
695
708
  </>
696
709
  )}
710
+
711
+ {/* No upload path: the root view IS the model list, so the
712
+ first row the menu offers is a real selection. */}
713
+ {hasModels && !hasUploadPath && (
714
+ <div role="group" aria-label="Model" className="flex flex-col">
715
+ {models?.map((m, i) => {
716
+ const isAvailable = m.available !== false;
717
+ const isSelected = isAvailable && m.id === currentModel?.id;
718
+ return (
719
+ <React.Fragment key={m.id}>
720
+ {i > 0 && (
721
+ <div role="separator" className="mx-sm h-px bg-hairline-soft" />
722
+ )}
723
+ <button
724
+ type="button"
725
+ role="menuitemradio"
726
+ aria-checked={isSelected}
727
+ aria-disabled={!isAvailable}
728
+ data-menu-item="model"
729
+ onClick={() => handleModelSelect(m)}
730
+ className={[
731
+ ROW,
732
+ "py-sm",
733
+ isSelected ? "bg-primary-soft hover:bg-primary-soft" : "",
734
+ !isAvailable ? "opacity-60" : "",
735
+ ].join(" ")}
736
+ >
737
+ <span className="flex min-w-0 flex-1 flex-col">
738
+ <span className="flex items-center gap-sm">
739
+ <span
740
+ className={`text-body-md ${isAvailable ? "text-ink" : "text-muted"}`}
741
+ >
742
+ {m.name}
743
+ </span>
744
+ {m.tier && (
745
+ <span className="rounded-full bg-surface-soft px-sm py-xxs text-caption text-body">
746
+ {m.tier}
747
+ </span>
748
+ )}
749
+ </span>
750
+ {m.description && isAvailable && (
751
+ <span className="text-caption text-muted">{m.description}</span>
752
+ )}
753
+ {!isAvailable && (
754
+ <span className="text-caption text-muted-soft">Unavailable</span>
755
+ )}
756
+ </span>
757
+ {isSelected && (
758
+ <Icon
759
+ name="check-checkmark"
760
+ size={18}
761
+ strokeWidth={2.25}
762
+ className="flex-shrink-0 text-primary"
763
+ />
764
+ )}
765
+ </button>
766
+ </React.Fragment>
767
+ );
768
+ })}
769
+ </div>
770
+ )}
697
771
  </div>
698
772
 
699
773
  {/* Model view (drill-in) */}
@@ -706,15 +780,17 @@ export const PromptInputBar = React.forwardRef<
706
780
  className={`${VIEW} ${menuView === "models" ? "" : "translate-x-2"}`}
707
781
  >
708
782
  <div className="flex items-center gap-sm px-xs pb-xs pt-xs">
709
- <button
710
- type="button"
711
- data-menu-item="back"
712
- onClick={() => setMenuView("root")}
713
- aria-label="Back"
714
- className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border border-hairline bg-surface-soft text-ink hover:bg-surface-strong ${PRESS} ${FOCUS}`}
715
- >
716
- <Icon name="arrow-left" size={16} />
717
- </button>
783
+ {hasUploadPath && (
784
+ <button
785
+ type="button"
786
+ data-menu-item="back"
787
+ onClick={() => setMenuView("root")}
788
+ aria-label="Back"
789
+ className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border border-hairline bg-surface-soft text-ink hover:bg-surface-strong ${PRESS} ${FOCUS}`}
790
+ >
791
+ <Icon name="arrow-left" size={16} />
792
+ </button>
793
+ )}
718
794
  <span className="text-body-md text-ink">Model</span>
719
795
  </div>
720
796
 
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import "../dist/styles.css";
2
2
 
3
+ export * from "./atoms/AgentActivityPanel";
3
4
  export * from "./atoms/AgentQuestionCard";
4
5
  export * from "./atoms/AppLayout";
5
6
  export * from "./atoms/AppSidebar";