@designa8/vibedesign-v6 1.8.5 → 1.9.4

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.
@@ -0,0 +1,150 @@
1
+ import React from "react";
2
+
3
+ export type ComponentKind = "Atom" | "Molecule" | "Organism" | "Template";
4
+
5
+ const kindColors: Record<ComponentKind, string> = {
6
+ Atom: "bg-[var(--color-kind-atom-bg)] text-[var(--color-kind-atom-text)] border-[var(--color-kind-atom-border)]",
7
+ Molecule: "bg-[var(--color-kind-molecule-bg)] text-[var(--color-kind-molecule-text)] border-[var(--color-kind-molecule-border)]",
8
+ Organism: "bg-[var(--color-kind-organism-bg)] text-[var(--color-kind-organism-text)] border-[var(--color-kind-organism-border)]",
9
+ Template: "bg-[var(--color-kind-template-bg)] text-[var(--color-kind-template-text)] border-[var(--color-kind-template-border)]",
10
+ };
11
+
12
+ const iconBg: Record<ComponentKind, string> = {
13
+ Atom: "bg-[var(--color-kind-atom-bg)] text-[var(--color-kind-atom-text)]",
14
+ Molecule: "bg-primary text-on-primary",
15
+ Organism: "bg-primary text-on-primary",
16
+ Template: "bg-[var(--color-kind-template-bg)] text-[var(--color-kind-template-text)]",
17
+ };
18
+
19
+ export interface ComponentCardProps
20
+ extends React.HTMLAttributes<HTMLDivElement> {
21
+ /** Component display name */
22
+ name: string;
23
+ /** Kind label shown in the badge */
24
+ kind?: ComponentKind;
25
+ /** Short description below the name */
26
+ description?: string;
27
+ /** Content rendered in the thumbnail preview area */
28
+ thumbnailContent?: React.ReactNode;
29
+ /** Override thumbnail background class */
30
+ thumbnailBg?: string;
31
+ /** Whether the card is in a selected/active state */
32
+ selected?: boolean;
33
+ }
34
+
35
+ export const ComponentCard = React.forwardRef<
36
+ HTMLDivElement,
37
+ ComponentCardProps
38
+ >(
39
+ (
40
+ {
41
+ name,
42
+ kind = "Organism",
43
+ description,
44
+ thumbnailContent,
45
+ thumbnailBg,
46
+ selected = false,
47
+ className,
48
+ ...rest
49
+ },
50
+ ref,
51
+ ) => {
52
+ return (
53
+ <div
54
+ ref={ref}
55
+ className={[
56
+ "group relative flex flex-col rounded-xl bg-surface overflow-hidden",
57
+ "border border-hairline-soft",
58
+ "shadow-card",
59
+ "transition-all duration-200",
60
+ "hover:shadow-md hover:-translate-y-0.5 cursor-pointer",
61
+ selected ? "ring-2 ring-primary" : "",
62
+ className,
63
+ ]
64
+ .filter(Boolean)
65
+ .join(" ")}
66
+ {...rest}
67
+ >
68
+ {/* Thumbnail */}
69
+ <div
70
+ className={[
71
+ "relative flex items-center justify-center",
72
+ "w-full aspect-[4/3] overflow-hidden",
73
+ thumbnailBg ?? "bg-surface-soft",
74
+ ].join(" ")}
75
+ >
76
+ {thumbnailContent ?? <DefaultThumbnail kind={kind} />}
77
+ </div>
78
+
79
+ {/* Footer */}
80
+ <div className="flex items-center justify-between px-md py-sm border-t border-hairline-soft bg-canvas">
81
+ <div className="flex flex-col gap-xxs min-w-0">
82
+ <span className="text-body-sm font-weight-heading-sm text-ink truncate">
83
+ {name}
84
+ </span>
85
+ <span className="text-caption text-muted truncate">
86
+ {description ?? `${kind} \u2022 Generated`}
87
+ </span>
88
+ </div>
89
+
90
+ <span
91
+ className={[
92
+ "ml-sm shrink-0 inline-flex items-center px-sm py-xs",
93
+ "rounded-md text-caption font-weight-heading-sm tracking-wide uppercase",
94
+ "border",
95
+ kindColors[kind],
96
+ ].join(" ")}
97
+ >
98
+ {kind}
99
+ </span>
100
+ </div>
101
+ </div>
102
+ );
103
+ },
104
+ );
105
+
106
+ ComponentCard.displayName = "ComponentCard";
107
+
108
+ /* ── Internal default thumbnail ── */
109
+ function DefaultThumbnail({ kind }: { kind: ComponentKind }) {
110
+ const icons: Record<ComponentKind, React.ReactNode> = {
111
+ Atom: (
112
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
113
+ <circle cx="12" cy="12" r="1" />
114
+ <path d="M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z" />
115
+ <path d="M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z" />
116
+ </svg>
117
+ ),
118
+ Molecule: (
119
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
120
+ <rect x="2" y="2" width="8" height="8" rx="2" />
121
+ <rect x="14" y="2" width="8" height="8" rx="2" />
122
+ <rect x="2" y="14" width="8" height="8" rx="2" />
123
+ </svg>
124
+ ),
125
+ Organism: (
126
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
127
+ <path d="M12 2L2 7l10 5 10-5-10-5z" />
128
+ <path d="M2 17l10 5 10-5" />
129
+ <path d="M2 12l10 5 10-5" />
130
+ </svg>
131
+ ),
132
+ Template: (
133
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
134
+ <rect x="3" y="3" width="18" height="18" rx="2" />
135
+ <path d="M3 9h18M9 21V9" />
136
+ </svg>
137
+ ),
138
+ };
139
+
140
+ return (
141
+ <div
142
+ className={[
143
+ "flex items-center justify-center w-16 h-16 rounded-xl",
144
+ iconBg[kind],
145
+ ].join(" ")}
146
+ >
147
+ {icons[kind]}
148
+ </div>
149
+ );
150
+ }
@@ -0,0 +1,2 @@
1
+ export { ComponentCard } from "./ComponentCard";
2
+ export type { ComponentCardProps, ComponentKind } from "./ComponentCard";
@@ -0,0 +1,111 @@
1
+ import React from "react";
2
+ import { ComponentCard } from "./ComponentCard";
3
+
4
+ /* A minimal mock thumbnail that resembles an auth screen preview */
5
+ function AuthThumbnail() {
6
+ return (
7
+ <div className="w-full h-full flex flex-col items-center justify-center gap-sm p-lg bg-surface-soft">
8
+ {/* Simulated card inside thumbnail */}
9
+ <div className="w-4/5 bg-canvas rounded-xl shadow-card flex flex-col items-center py-lg px-md gap-sm">
10
+ <div className="w-12 h-14 rounded-xl bg-primary flex items-center justify-center">
11
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="white" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
12
+ <path d="M12 2L2 7l10 5 10-5-10-5z" />
13
+ <path d="M2 17l10 5 10-5" />
14
+ <path d="M2 12l10 5 10-5" />
15
+ </svg>
16
+ </div>
17
+ <div className="w-3/4 h-2 rounded-xs bg-ink opacity-20" />
18
+ <div className="w-1/2 h-2 rounded-xs bg-muted opacity-30" />
19
+ </div>
20
+ </div>
21
+ );
22
+ }
23
+
24
+ function InputThumbnail() {
25
+ return (
26
+ <div className="w-full h-full flex items-center justify-center bg-surface-soft p-lg">
27
+ <div className="w-4/5 flex flex-col gap-sm">
28
+ <div className="h-10 rounded-md bg-canvas border border-hairline flex items-center px-sm gap-sm">
29
+ <div className="w-3 h-3 rounded-xs bg-muted opacity-40" />
30
+ <div className="flex-1 h-2 rounded-xs bg-muted opacity-30" />
31
+ </div>
32
+ <div className="h-10 rounded-md bg-canvas border-2 border-primary flex items-center px-sm gap-sm">
33
+ <div className="flex-1 h-2 rounded-xs bg-ink opacity-40" />
34
+ </div>
35
+ </div>
36
+ </div>
37
+ );
38
+ }
39
+
40
+ function ButtonThumbnail() {
41
+ return (
42
+ <div className="w-full h-full flex items-center justify-center gap-md bg-surface-soft p-lg flex-wrap">
43
+ <div className="h-9 px-md rounded-md bg-primary flex items-center">
44
+ <div className="w-16 h-2 rounded-xs bg-on-primary opacity-80" />
45
+ </div>
46
+ <div className="h-9 px-md rounded-md bg-canvas border border-hairline flex items-center">
47
+ <div className="w-12 h-2 rounded-xs bg-ink opacity-30" />
48
+ </div>
49
+ </div>
50
+ );
51
+ }
52
+
53
+ function DashboardThumbnail() {
54
+ return (
55
+ <div className="w-full h-full flex bg-surface-soft overflow-hidden">
56
+ {/* Sidebar */}
57
+ <div className="w-1/4 bg-surface-strong h-full flex flex-col gap-xs p-sm">
58
+ {[1,2,3,4].map(i => (
59
+ <div key={i} className="h-2 rounded-xs bg-muted opacity-30" />
60
+ ))}
61
+ </div>
62
+ {/* Main */}
63
+ <div className="flex-1 p-sm flex flex-col gap-xs">
64
+ <div className="h-3 w-3/4 rounded-xs bg-ink opacity-20 mb-xs" />
65
+ <div className="flex gap-xs flex-1">
66
+ {[1,2,3].map(i => (
67
+ <div key={i} className="flex-1 rounded-md bg-canvas shadow-sm border border-hairline-soft" />
68
+ ))}
69
+ </div>
70
+ </div>
71
+ </div>
72
+ );
73
+ }
74
+
75
+ export default function ComponentCardPreview() {
76
+ return (
77
+ <div className="w-full max-w-3xl mx-auto p-lg">
78
+ <p className="text-caption text-muted uppercase tracking-wide mb-lg">
79
+ Component Card — All kinds
80
+ </p>
81
+
82
+ <div className="grid grid-cols-2 gap-md">
83
+ <ComponentCard
84
+ name="Auth Screen"
85
+ kind="Organism"
86
+ description="Organism • Generated"
87
+ thumbnailContent={<AuthThumbnail />}
88
+ />
89
+ <ComponentCard
90
+ name="Input"
91
+ kind="Atom"
92
+ description="Atom • Generated"
93
+ thumbnailContent={<InputThumbnail />}
94
+ />
95
+ <ComponentCard
96
+ name="Prompt Input Bar"
97
+ kind="Molecule"
98
+ description="Molecule • Generated"
99
+ thumbnailContent={<ButtonThumbnail />}
100
+ />
101
+ <ComponentCard
102
+ name="App Layout"
103
+ kind="Template"
104
+ description="Template • Generated"
105
+ thumbnailContent={<DashboardThumbnail />}
106
+ selected
107
+ />
108
+ </div>
109
+ </div>
110
+ );
111
+ }
@@ -159,16 +159,18 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
159
159
  role="toolbar"
160
160
  aria-label="Preview toolbar"
161
161
  className={[
162
- "inline-flex items-center gap-sm px-sm py-xs",
162
+ // On mobile: flex column direction with wrapping rows; on md+: single inline-flex row
163
+ "flex flex-wrap items-center gap-sm px-sm py-xs",
164
+ "md:inline-flex md:flex-nowrap",
163
165
  "bg-canvas border border-hairline rounded-xl shadow-md",
164
166
  className,
165
167
  ].filter(Boolean).join(" ")}
166
168
  >
167
- {/* ── Viewport toggles ── */}
169
+ {/* ── Viewport toggles — own row on mobile ── */}
168
170
  <div
169
171
  role="group"
170
172
  aria-label="Viewport size"
171
- className="inline-flex items-center gap-xxs bg-surface-soft rounded-lg p-xxs"
173
+ className="inline-flex items-center gap-xxs bg-surface-soft rounded-lg p-xxs w-full md:w-auto"
172
174
  >
173
175
  {VIEWPORT_OPTIONS.map(({ id, Icon, label }) => (
174
176
  <ViewportBtn
@@ -196,65 +198,68 @@ export const PreviewToolbar = React.forwardRef<HTMLDivElement, PreviewToolbarPro
196
198
  </Button>
197
199
  </div>
198
200
 
199
- {/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
200
- <Button
201
- variant={inspecting ? "primary" : "secondary"}
202
- size="sm"
203
- aria-pressed={inspecting}
204
- onClick={onInspectTokens}
205
- className="gap-xs rounded-xl"
206
- >
207
- <InspectIcon />
208
- {inspecting ? "Exit inspect" : "Inspect tokens"}
209
- </Button>
201
+ {/* ── Action buttons — wrap as a group below viewport row on mobile ── */}
202
+ <div className="flex flex-wrap items-center gap-sm">
203
+ {/* ── Inspect tokens button — variant and label driven by `inspecting` prop ── */}
204
+ <Button
205
+ variant={inspecting ? "primary" : "secondary"}
206
+ size="sm"
207
+ aria-pressed={inspecting}
208
+ onClick={onInspectTokens}
209
+ className="gap-xs rounded-xl"
210
+ >
211
+ <InspectIcon />
212
+ {inspecting ? "Exit inspect" : "Inspect tokens"}
213
+ </Button>
210
214
 
211
- <Button
212
- variant={darkMode ? "primary" : "secondary"}
213
- size="sm"
214
- aria-pressed={darkMode}
215
- onClick={onDarkToggle}
216
- className="gap-xs rounded-xl"
217
- >
218
- <MoonIcon />
219
- Dark
220
- </Button>
215
+ <Button
216
+ variant={darkMode ? "primary" : "secondary"}
217
+ size="sm"
218
+ aria-pressed={darkMode}
219
+ onClick={onDarkToggle}
220
+ className="gap-xs rounded-xl"
221
+ >
222
+ <MoonIcon />
223
+ Dark
224
+ </Button>
221
225
 
222
- <Button
223
- variant="secondary"
224
- size="sm"
225
- onClick={onFullscreen}
226
- className="gap-xs rounded-xl"
227
- >
228
- <FullscreenIcon />
229
- Fullscreen
230
- </Button>
226
+ <Button
227
+ variant="secondary"
228
+ size="sm"
229
+ onClick={onFullscreen}
230
+ className="gap-xs rounded-xl"
231
+ >
232
+ <FullscreenIcon />
233
+ Fullscreen
234
+ </Button>
231
235
 
232
- {/* ── Model chip (outlined primary style) ── */}
233
- <Chip
234
- label={modelLabel ?? ""}
235
- variant="default"
236
- size="md"
237
- className="border-primary text-primary bg-canvas cursor-default select-none"
238
- />
236
+ {/* ── Model chip (outlined primary style) ── */}
237
+ <Chip
238
+ label={modelLabel ?? ""}
239
+ variant="default"
240
+ size="md"
241
+ className="border-primary text-primary bg-canvas cursor-default select-none"
242
+ />
239
243
 
240
- {/* ── Kind chip (filled soft primary) ── */}
241
- <Chip
242
- label={kindLabel ?? ""}
243
- variant="default"
244
- size="md"
245
- className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
246
- />
244
+ {/* ── Kind chip (filled soft primary) ── */}
245
+ <Chip
246
+ label={kindLabel ?? ""}
247
+ variant="default"
248
+ size="md"
249
+ className="bg-primary-disabled border-primary-disabled text-primary cursor-default select-none"
250
+ />
247
251
 
248
- {/* ── Overflow ── */}
249
- <Button
250
- variant="ghost"
251
- size="sm"
252
- aria-label="More options"
253
- onClick={onOverflow}
254
- className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
255
- >
256
- <DotsIcon />
257
- </Button>
252
+ {/* ── Overflow ── */}
253
+ <Button
254
+ variant="ghost"
255
+ size="sm"
256
+ aria-label="More options"
257
+ onClick={onOverflow}
258
+ className="!w-8 !h-8 !p-0 rounded-sm text-muted shrink-0"
259
+ >
260
+ <DotsIcon />
261
+ </Button>
262
+ </div>
258
263
  </div>
259
264
  ),
260
265
  );
@@ -18,8 +18,8 @@ export default function PreviewToolbarPreview() {
18
18
  </div>
19
19
 
20
20
  {/* ── Interactive demo ─────────────────────────── */}
21
- <div className="flex flex-col items-center gap-lg">
22
- <div className="flex items-center justify-center w-full bg-surface-soft rounded-xl p-xl border border-hairline">
21
+ <div className="flex flex-col gap-lg">
22
+ <div className="flex items-start justify-center w-full bg-surface-soft rounded-xl p-xl border border-hairline">
23
23
  <PreviewToolbar
24
24
  viewport={viewport}
25
25
  onViewportChange={setViewport}
@@ -42,10 +42,32 @@ export default function PreviewToolbarPreview() {
42
42
  </p>
43
43
  </div>
44
44
 
45
+ {/* ── Mobile-wrap demo ─────────────────────────── */}
46
+ <div className="space-y-sm">
47
+ <p className="text-body-sm text-muted font-weight-heading-sm">Responsive wrap — narrow container (simulates mobile)</p>
48
+ <p className="text-body-sm text-muted-soft">
49
+ At widths below md/768px the viewport toggle group sits on its own row and the action buttons wrap below it.
50
+ </p>
51
+ {/* Full-width outer frame. The toolbar itself has className="w-full" so it fills its parent. */}
52
+ <div className="w-full max-w-3xl mx-auto p-lg bg-surface-soft rounded-xl border border-hairline flex justify-start">
53
+ {/* Inner phone-width frame to force wrapping in the preview */}
54
+ <div className="w-72 bg-canvas rounded-lg p-sm border border-hairline-soft">
55
+ <PreviewToolbar
56
+ viewport="mobile"
57
+ darkMode
58
+ inspecting
59
+ modelLabel="Sonnet 4.6"
60
+ kindLabel="ATOM"
61
+ className="w-full"
62
+ />
63
+ </div>
64
+ </div>
65
+ </div>
66
+
45
67
  {/* ── Variant: expanded=true ───────────────────── */}
46
68
  <div className="space-y-sm">
47
69
  <p className="text-body-sm text-muted font-weight-heading-sm">Expanded active (expanded=true) — viewport buttons deselected</p>
48
- <div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
70
+ <div className="flex items-start justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
49
71
  <PreviewToolbar
50
72
  viewport="desktop"
51
73
  expanded
@@ -58,7 +80,7 @@ export default function PreviewToolbarPreview() {
58
80
  {/* ── Variant: inspecting=true ─────────────────── */}
59
81
  <div className="space-y-sm">
60
82
  <p className="text-body-sm text-muted font-weight-heading-sm">Inspecting active (inspecting=true)</p>
61
- <div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
83
+ <div className="flex items-start justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
62
84
  <PreviewToolbar
63
85
  viewport="desktop"
64
86
  inspecting
@@ -68,22 +90,10 @@ export default function PreviewToolbarPreview() {
68
90
  </div>
69
91
  </div>
70
92
 
71
- {/* ── Variant: mobile active ──────────────────── */}
72
- <div className="space-y-sm">
73
- <p className="text-body-sm text-muted font-weight-heading-sm">Mobile active</p>
74
- <div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
75
- <PreviewToolbar
76
- viewport="mobile"
77
- modelLabel="Opus 4"
78
- kindLabel="MOLECULE"
79
- />
80
- </div>
81
- </div>
82
-
83
93
  {/* ── Variant: dark mode on ───────────────────── */}
84
94
  <div className="space-y-sm">
85
95
  <p className="text-body-sm text-muted font-weight-heading-sm">Dark mode active</p>
86
- <div className="flex items-center justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
96
+ <div className="flex items-start justify-center w-full bg-canvas rounded-xl p-xl border border-hairline">
87
97
  <PreviewToolbar
88
98
  viewport="sidebar"
89
99
  darkMode
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./atoms/AuthScreen";
6
6
  export * from "./atoms/Button";
7
7
  export * from "./atoms/ChatScreen";
8
8
  export * from "./atoms/Chip";
9
+ export * from "./atoms/ComponentCard";
9
10
  export * from "./atoms/FilterTabBar";
10
11
  export * from "./atoms/Input";
11
12
  export * from "./atoms/Modal";
package/src/tokens.css CHANGED
@@ -36,6 +36,18 @@
36
36
  --color-semantic-success-soft: #dcfce7;
37
37
  --color-semantic-warning-soft: #fef9c3;
38
38
  --color-semantic-error-soft: #fee2e2;
39
+ --color-kind-atom-bg: #E8F4FD;
40
+ --color-kind-atom-text: #2878C0;
41
+ --color-kind-atom-border: #B8D9F0;
42
+ --color-kind-molecule-bg: #F0EEFF;
43
+ --color-kind-molecule-text: #6B63D6;
44
+ --color-kind-molecule-border: #C8C3F5;
45
+ --color-kind-organism-bg: #E9F9EF;
46
+ --color-kind-organism-text: #15803D;
47
+ --color-kind-organism-border: #A7E0BE;
48
+ --color-kind-template-bg: #FEF3C7;
49
+ --color-kind-template-text: #B45309;
50
+ --color-kind-template-border: #FBD98A;
39
51
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
40
52
  --font-heading: var(--font-body);
41
53
  --font-display-lg: var(--font-body);