@designa8/vibedesign-v6 1.20.12 → 1.20.14

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,8 +1,9 @@
1
- import React, { useState } from "react";
1
+ import React from "react";
2
2
  import { Modal } from "../Modal";
3
3
  import { Button } from "../Button";
4
4
  import { Chip } from "../Chip";
5
5
  import { Typography } from "../Typography";
6
+ import { Icon } from "../Icon";
6
7
 
7
8
  export type ExportDesignMdSource = "production" | "local";
8
9
 
@@ -24,11 +25,15 @@ export interface ExportDesignMdModalProps {
24
25
  onDownload?: () => void;
25
26
  /** Called when the user copies the preview to the clipboard */
26
27
  onCopy?: () => void;
27
- /** Called every time the user switches the source toggle (tabs or Switch buttons) */
28
+ /**
29
+ * Kept for backwards compatibility. The source is now locked to
30
+ * `defaultSource` for the lifetime of the modal — there is no toggle,
31
+ * so this callback is never invoked.
32
+ */
28
33
  onSourceChange?: (source: ExportDesignMdSource) => void;
29
34
  /** Name of the design system shown in the generated heading */
30
35
  designSystemName?: string;
31
- /** Which source tab is selected by default */
36
+ /** The single source this modal is locked to for its lifetime */
32
37
  defaultSource?: ExportDesignMdSource;
33
38
  /** Lines rendered in the code preview panel */
34
39
  lines?: ExportDesignMdLine[];
@@ -69,101 +74,23 @@ const defaultLines: ExportDesignMdLine[] = [
69
74
  { text: "hairline: {colors.hairline}" },
70
75
  ];
71
76
 
72
- const CloudIcon = () => (
73
- <svg
74
- viewBox="0 0 24 24"
75
- width="16"
76
- height="16"
77
- fill="none"
78
- stroke="currentColor"
79
- strokeWidth="2"
80
- strokeLinecap="round"
81
- strokeLinejoin="round"
82
- aria-hidden="true"
83
- >
84
- <path d="M17.5 19a4.5 4.5 0 0 0 0-9 5.5 5.5 0 0 0-10.8-1.5A4 4 0 0 0 6.5 16" />
85
- <path d="M8 19h9.5" />
86
- </svg>
87
- );
88
-
89
- const LinkIcon = () => (
90
- <svg
91
- viewBox="0 0 24 24"
92
- width="16"
93
- height="16"
94
- fill="none"
95
- stroke="currentColor"
96
- strokeWidth="2"
97
- strokeLinecap="round"
98
- strokeLinejoin="round"
99
- aria-hidden="true"
100
- >
101
- <path d="M9 17H7A5 5 0 0 1 7 7h2" />
102
- <path d="M15 7h2a5 5 0 1 1 0 10h-2" />
103
- <line x1="8" y1="12" x2="16" y2="12" />
104
- </svg>
105
- );
106
-
107
- const CopyIcon = () => (
108
- <svg
109
- viewBox="0 0 24 24"
110
- width="14"
111
- height="14"
112
- fill="none"
113
- stroke="currentColor"
114
- strokeWidth="2"
115
- strokeLinecap="round"
116
- strokeLinejoin="round"
117
- aria-hidden="true"
118
- >
119
- <rect x="9" y="9" width="11" height="11" rx="2" />
120
- <path d="M5 15V5a2 2 0 0 1 2-2h10" />
121
- </svg>
122
- );
123
-
124
- const DownloadIcon = () => (
125
- <svg
126
- viewBox="0 0 24 24"
127
- width="14"
128
- height="14"
129
- fill="none"
130
- stroke="currentColor"
131
- strokeWidth="2"
132
- strokeLinecap="round"
133
- strokeLinejoin="round"
134
- aria-hidden="true"
135
- >
136
- <path d="M12 3v12" />
137
- <path d="M7 10l5 5 5-5" />
138
- <path d="M5 21h14" />
139
- </svg>
140
- );
141
-
142
- const SpinnerIcon = () => (
143
- <svg
144
- viewBox="0 0 24 24"
145
- width="20"
146
- height="20"
147
- fill="none"
148
- className="animate-spin text-primary"
149
- aria-hidden="true"
150
- >
151
- <circle
152
- cx="12"
153
- cy="12"
154
- r="9"
155
- stroke="currentColor"
156
- strokeWidth="2.5"
157
- strokeOpacity="0.25"
158
- />
159
- <path
160
- d="M21 12a9 9 0 0 0-9-9"
161
- stroke="currentColor"
162
- strokeWidth="2.5"
163
- strokeLinecap="round"
164
- />
165
- </svg>
166
- );
77
+ const SOURCE_INFO: Record<
78
+ ExportDesignMdSource,
79
+ { icon: string; title: string; description: string; helper: string }
80
+ > = {
81
+ production: {
82
+ icon: "cloud",
83
+ title: "Production (npm install)",
84
+ description: "Generated for public npm registry consumption.",
85
+ helper: "Consumer apps install from the public npm registry ('npm install').",
86
+ },
87
+ local: {
88
+ icon: "external-link-arrow-up-right",
89
+ title: "Local (npm link)",
90
+ description: "Generated for local development with npm link.",
91
+ helper: "Consumer apps resolve the package via a local 'npm link' during development.",
92
+ },
93
+ };
167
94
 
168
95
  export const ExportDesignMdModal = React.forwardRef<
169
96
  HTMLDivElement,
@@ -176,7 +103,6 @@ export const ExportDesignMdModal = React.forwardRef<
176
103
  onExport,
177
104
  onDownload,
178
105
  onCopy,
179
- onSourceChange,
180
106
  designSystemName = "Design System",
181
107
  defaultSource = "production",
182
108
  lines = defaultLines,
@@ -184,12 +110,8 @@ export const ExportDesignMdModal = React.forwardRef<
184
110
  },
185
111
  ref
186
112
  ) => {
187
- const [source, setSource] = useState<ExportDesignMdSource>(defaultSource);
188
-
189
- const changeSource = (next: ExportDesignMdSource) => {
190
- setSource(next);
191
- onSourceChange?.(next);
192
- };
113
+ const source = defaultSource;
114
+ const info = SOURCE_INFO[source];
193
115
 
194
116
  const handleCopy = () => {
195
117
  const text = lines.map((l) => l.text).join("\n");
@@ -209,7 +131,7 @@ export const ExportDesignMdModal = React.forwardRef<
209
131
  footer={
210
132
  <div className="flex w-full items-center justify-between">
211
133
  <Button variant="secondary" size="sm" onClick={onDownload}>
212
- <DownloadIcon />
134
+ <Icon name="download" />
213
135
  Download .md
214
136
  </Button>
215
137
  <div className="flex items-center gap-sm">
@@ -229,32 +151,24 @@ export const ExportDesignMdModal = React.forwardRef<
229
151
  agents or your team.
230
152
  </Typography>
231
153
 
232
- {/* Source tabs */}
233
- <div className="flex flex-wrap items-center justify-between gap-md">
234
- <div className="inline-flex items-center gap-xs p-xxs bg-surface-soft border border-hairline rounded-md">
235
- <Button
236
- variant={source === "production" ? "primary" : "ghost"}
237
- size="sm"
238
- onClick={() => changeSource("production")}
239
- >
240
- <CloudIcon />
241
- Production
242
- </Button>
243
- <Button
244
- variant={source === "local" ? "primary" : "ghost"}
245
- size="sm"
246
- onClick={() => changeSource("local")}
247
- >
248
- <LinkIcon />
249
- Local (npm link)
250
- </Button>
154
+ {/* Locked source info row */}
155
+ <div className="flex w-full items-center gap-md p-md bg-surface-soft border border-hairline rounded-md">
156
+ <span className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-sm bg-surface border border-hairline text-primary">
157
+ <Icon name={info.icon} />
158
+ </span>
159
+ <div className="min-w-0 flex-1">
160
+ <Typography role="body-md" color="ink" className="font-weight-heading-sm">
161
+ {info.title}
162
+ </Typography>
163
+ <Typography role="body-sm" color="muted">
164
+ {info.description}
165
+ </Typography>
251
166
  </div>
252
- <Typography role="body-sm" color="muted" className="flex-1 min-w-[16rem]">
253
- {source === "production"
254
- ? "Consumer apps install from the public npm registry ('npm install')."
255
- : "Consumer apps resolve the package via a local 'npm link' during development."}
256
- </Typography>
167
+ <Chip label="Active" variant="primary" size="sm" />
257
168
  </div>
169
+ <Typography role="body-sm" color="muted">
170
+ {info.helper}
171
+ </Typography>
258
172
 
259
173
  {/* Preview */}
260
174
  <div>
@@ -273,7 +187,7 @@ export const ExportDesignMdModal = React.forwardRef<
273
187
  onClick={handleCopy}
274
188
  className="absolute top-sm right-sm"
275
189
  >
276
- <CopyIcon />
190
+ <Icon name="copy-clipboard" />
277
191
  Copy
278
192
  </Button>
279
193
  <div className="max-h-64 overflow-y-auto px-md py-sm font-mono text-body-sm">
@@ -302,7 +216,7 @@ export const ExportDesignMdModal = React.forwardRef<
302
216
  aria-label="Loading preview"
303
217
  className="absolute inset-0 flex items-center justify-center gap-sm bg-canvas opacity-90"
304
218
  >
305
- <SpinnerIcon />
219
+ <Icon name="loading-spinner" className="animate-spin text-primary" />
306
220
  <Typography role="body-sm" color="muted">
307
221
  Loading preview…
308
222
  </Typography>
@@ -310,59 +224,6 @@ export const ExportDesignMdModal = React.forwardRef<
310
224
  ) : null}
311
225
  </div>
312
226
  </div>
313
-
314
- {/* Storage options */}
315
- <div className="w-full space-y-sm">
316
- <div className="flex w-full items-center gap-md p-md bg-surface-soft border border-hairline rounded-md">
317
- <span className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-sm bg-surface border border-hairline text-primary">
318
- <CloudIcon />
319
- </span>
320
- <div className="min-w-0 flex-1">
321
- <Typography role="body-md" color="ink" className="font-weight-heading-sm">
322
- Production (npm install)
323
- </Typography>
324
- <Typography role="body-sm" color="muted">
325
- Generated for public npm registry consumption.
326
- </Typography>
327
- </div>
328
- {source === "production" ? (
329
- <Chip label="Active" variant="primary" size="sm" />
330
- ) : (
331
- <Button
332
- variant="secondary"
333
- size="sm"
334
- onClick={() => changeSource("production")}
335
- >
336
- Switch
337
- </Button>
338
- )}
339
- </div>
340
-
341
- <div className="flex w-full items-center gap-md p-md bg-surface-soft border border-hairline rounded-md">
342
- <span className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-sm bg-surface border border-hairline text-muted">
343
- <LinkIcon />
344
- </span>
345
- <div className="min-w-0 flex-1">
346
- <Typography role="body-md" color="ink" className="font-weight-heading-sm">
347
- Local (npm link)
348
- </Typography>
349
- <Typography role="body-sm" color="muted">
350
- Generated for local development with npm link.
351
- </Typography>
352
- </div>
353
- {source === "local" ? (
354
- <Chip label="Active" variant="primary" size="sm" />
355
- ) : (
356
- <Button
357
- variant="secondary"
358
- size="sm"
359
- onClick={() => changeSource("local")}
360
- >
361
- Switch
362
- </Button>
363
- )}
364
- </div>
365
- </div>
366
227
  </div>
367
228
  </Modal>
368
229
  );
@@ -3,7 +3,8 @@ import { ExportDesignMdModal } from "./ExportDesignMdModal";
3
3
  import { Button } from "../Button";
4
4
 
5
5
  export default function ExportDesignMdModalPreview() {
6
- const [open, setOpen] = useState(false);
6
+ const [openProduction, setOpenProduction] = useState(false);
7
+ const [openLocal, setOpenLocal] = useState(false);
7
8
 
8
9
  return (
9
10
  <div className="w-full max-w-3xl mx-auto p-lg space-y-md">
@@ -11,19 +12,34 @@ export default function ExportDesignMdModalPreview() {
11
12
  <h2 className="text-heading-md text-ink">Export DESIGN.md</h2>
12
13
  <p className="text-body-md text-muted mt-xs">
13
14
  Opens a dialog for handing off the design system's token file to an
14
- AI coding agent or teammate, with a source toggle and live preview.
15
+ AI coding agent or teammate. The source is locked per instance —
16
+ no toggle, just a live preview and export/download actions.
15
17
  </p>
16
18
  </div>
17
19
 
18
- <Button variant="primary" onClick={() => setOpen(true)}>
19
- Export DESIGN.md
20
- </Button>
20
+ <div className="flex flex-wrap items-center gap-sm">
21
+ <Button variant="primary" onClick={() => setOpenProduction(true)}>
22
+ Export (production)
23
+ </Button>
24
+ <Button variant="secondary" onClick={() => setOpenLocal(true)}>
25
+ Export (local npm link)
26
+ </Button>
27
+ </div>
28
+
29
+ <ExportDesignMdModal
30
+ isOpen={openProduction}
31
+ onClose={() => setOpenProduction(false)}
32
+ onExport={() => setOpenProduction(false)}
33
+ onDownload={() => {}}
34
+ defaultSource="production"
35
+ />
21
36
 
22
37
  <ExportDesignMdModal
23
- isOpen={open}
24
- onClose={() => setOpen(false)}
25
- onExport={() => setOpen(false)}
38
+ isOpen={openLocal}
39
+ onClose={() => setOpenLocal(false)}
40
+ onExport={() => setOpenLocal(false)}
26
41
  onDownload={() => {}}
42
+ defaultSource="local"
27
43
  />
28
44
  </div>
29
45
  );
@@ -60,6 +60,9 @@ export const ICON_REGISTRY = {
60
60
  "image-photo-picture": { viewBox: "0 0 24 24", paths: ["M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z", "M11 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"] },
61
61
  "video-film-clapperboard": { viewBox: "0 0 24 24", paths: ["M4 6h10a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2Z", "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"] },
62
62
  "minus-indeterminate": { viewBox: "0 0 24 24", paths: ["M5 12h14"] },
63
+ "cloud": { viewBox: "0 0 24 24", paths: ["M17.5 19a4.5 4.5 0 0 0 0-9 5.5 5.5 0 0 0-10.8-1.5A4 4 0 0 0 6.5 16", "M8 19h9.5"] },
64
+ "download": { viewBox: "0 0 24 24", paths: ["M12 3v12", "M7 10l5 5 5-5", "M5 21h14"] },
65
+ "refresh": { viewBox: "0 0 24 24", paths: ["M4 4v5h5", "M20 20v-5h-5", "M5.5 9A7 7 0 0 1 19 12", "M18.5 15A7 7 0 0 1 5 12"] },
63
66
  } as const;
64
67
 
65
68
  export type IconName = keyof typeof ICON_REGISTRY;