vibe-design-system 1.9.2 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Reads vds-output.json and generates:
6
6
  * - Storybook .stories.tsx files under src/stories for each component
7
- * - Foundations MDX: Colors, Typography, Brand under src/stories/foundations/
7
+ * - Foundations .stories.tsx: Colors, Typography, Brand under src/stories/foundations/
8
8
  *
9
9
  * Usage:
10
10
  * node vds-core/story-generator.mjs # generate for all components
@@ -22,7 +22,7 @@ const STORIES_DIR = path.join(SRC_DIR, "stories");
22
22
 
23
23
  // Top of every story file for CSS variables
24
24
  const STORY_CSS_HEADER = `// @ts-ignore
25
- import '../../index.css'
25
+ import '../index.css'
26
26
 
27
27
  `;
28
28
 
@@ -42,6 +42,10 @@ const SKIP_LIST = [
42
42
  "ToggleGroup",
43
43
  "Sidebar",
44
44
  "TestComponent",
45
+ "Chart",
46
+ "InputOtp",
47
+ "Resizable",
48
+ "Sonner",
45
49
  ];
46
50
 
47
51
  function ensureDir(dir) {
@@ -443,83 +447,106 @@ function getColorEntries(colors) {
443
447
  return entries;
444
448
  }
445
449
 
446
- function writeFoundationsMdx(foundations) {
450
+ function writeFoundationsStories(foundations) {
447
451
  const foundationsDir = path.join(STORIES_DIR, "foundations");
448
452
  ensureDir(foundationsDir);
449
453
 
450
- const colors = foundations?.colors;
451
- const colorEntries = getColorEntries(colors);
452
- if (colorEntries.length > 0) {
453
- const colorLines = [
454
- "import { Meta } from '@storybook/blocks';",
454
+ const colorEntries = getColorEntries(foundations?.colors);
455
+ const colorsContent =
456
+ STORY_CSS_HEADER +
457
+ [
458
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
455
459
  "",
456
- "<Meta title=\"Foundations/Colors\" />",
460
+ "const meta = { title: \"Foundations/Colors\" } satisfies Meta;",
461
+ "export default meta;",
462
+ "type Story = StoryObj;",
457
463
  "",
458
- "# Colors",
464
+ `const colors = ${JSON.stringify(colorEntries)};`,
459
465
  "",
460
- "<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))', gap: '1rem' }}>",
461
- ...colorEntries.map(
462
- (e) =>
463
- ` <div key="${e.name}"><div style={{ backgroundColor: '${e.hex.replace(/'/g, "\\'")}', height: 80, borderRadius: 8, border: '1px solid #333' }} /><p style={{ marginTop: 8, fontSize: 12 }}>${e.name}</p><code style={{ fontSize: 11 }}>${e.hex}</code></div>`,
464
- ),
465
- "</div>",
466
- ];
467
- fs.writeFileSync(path.join(foundationsDir, "Colors.stories.mdx"), colorLines.join("\n"), "utf-8");
468
- console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Colors.stories.mdx")));
469
- }
466
+ "export const Default: Story = {",
467
+ " render: () => (",
468
+ " <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(140px, 1fr))\", gap: \"1rem\" }}>",
469
+ " {colors.map(({ name, hex }) => (",
470
+ " <div key={name}>",
471
+ " <div style={{ backgroundColor: hex, height: 80, borderRadius: 8, border: \"1px solid #333\" }} />",
472
+ " <p style={{ marginTop: 8, fontSize: 12 }}>{name}</p>",
473
+ " <code style={{ fontSize: 11 }}>{hex}</code>",
474
+ " </div>",
475
+ " ))}",
476
+ " </div>",
477
+ " ),",
478
+ "};",
479
+ ].join("\n");
480
+ fs.writeFileSync(path.join(foundationsDir, "Colors.stories.tsx"), colorsContent, "utf-8");
481
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Colors.stories.tsx")));
470
482
 
471
483
  const typo = foundations?.typography;
472
484
  if (typo && typeof typo === "object" && Object.keys(typo).length > 0) {
473
- const bodyVal = typo.body || typo.bodyFontFamily || "";
474
- const monoVal = typo.mono || typo.tailwindMono;
475
- const monoStr = Array.isArray(monoVal) ? monoVal.join(", ") : String(monoVal || "");
476
- const typoContent = [
477
- "import { Meta } from '@storybook/blocks';",
478
- "",
479
- "<Meta title=\"Foundations/Typography\" />",
480
- "",
481
- "# Typography",
482
- "",
483
- "## Font family & scale",
484
- "",
485
- "| Token | Value |",
486
- "| --- | --- |",
487
- ...Object.entries(typo).map(([k, v]) => {
488
- const val = Array.isArray(v) ? v.join(", ") : String(v);
489
- return `| ${k} | ${val} |`;
490
- }),
491
- "",
492
- "## Preview",
493
- "",
494
- `<p style={{ fontFamily: ${JSON.stringify(bodyVal)}, fontSize: 16 }}>The quick brown fox jumps over the lazy dog.</p>`,
495
- `<p style={{ fontFamily: ${JSON.stringify(monoStr)}, fontSize: 14 }}>Code: 0123456789</p>`,
496
- ];
497
- fs.writeFileSync(path.join(foundationsDir, "Typography.stories.mdx"), typoContent.join("\n"), "utf-8");
498
- console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Typography.stories.mdx")));
485
+ const typoRows = Object.entries(typo).map(([k, v]) => ({
486
+ token: k,
487
+ value: Array.isArray(v) ? v.join(", ") : String(v),
488
+ }));
489
+ const typoContent =
490
+ STORY_CSS_HEADER +
491
+ [
492
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
493
+ "",
494
+ "const meta = { title: \"Foundations/Typography\" } satisfies Meta;",
495
+ "export default meta;",
496
+ "type Story = StoryObj;",
497
+ "",
498
+ `const typography = ${JSON.stringify(typoRows)};`,
499
+ "",
500
+ "export const Default: Story = {",
501
+ " render: () => (",
502
+ " <div>",
503
+ " <h2 style={{ marginBottom: 16 }}>Font family & scale</h2>",
504
+ " <table style={{ borderCollapse: \"collapse\", width: \"100%\" }}>",
505
+ " <thead><tr><th style={{ textAlign: \"left\", padding: 8, borderBottom: \"1px solid #333\" }}>Token</th><th style={{ textAlign: \"left\", padding: 8, borderBottom: \"1px solid #333\" }}>Value</th></tr></thead>",
506
+ " <tbody>",
507
+ " {typography.map(({ token, value }) => (",
508
+ " <tr key={token}><td style={{ padding: 8, borderBottom: \"1px solid #222\" }}>{token}</td><td style={{ padding: 8, borderBottom: \"1px solid #222\" }}>{value}</td></tr>",
509
+ " ))}",
510
+ " </tbody>",
511
+ " </table>",
512
+ " </div>",
513
+ " ),",
514
+ "};",
515
+ ].join("\n");
516
+ fs.writeFileSync(path.join(foundationsDir, "Typography.stories.tsx"), typoContent, "utf-8");
517
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Typography.stories.tsx")));
499
518
  }
500
519
 
501
520
  const brandAssets = foundations?.brand?.assets;
502
- if (Array.isArray(brandAssets) && brandAssets.length > 0) {
503
- const assetRows = brandAssets.map(
504
- (a) =>
505
- ` <tr key="${(a.path || a.name || "").replace(/"/g, '\\"')}"><td>${a.type || "asset"}</td><td><code>${a.path || a.name || ""}</code></td><td>${a.name || ""}</td></tr>`,
506
- );
507
- const brandContent = [
508
- "import { Meta } from '@storybook/blocks';",
521
+ const assets = Array.isArray(brandAssets) ? brandAssets : [];
522
+ const brandContent =
523
+ STORY_CSS_HEADER +
524
+ [
525
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
509
526
  "",
510
- "<Meta title=\"Foundations/Brand\" />",
527
+ "const meta = { title: \"Foundations/Brand\" } satisfies Meta;",
528
+ "export default meta;",
529
+ "type Story = StoryObj;",
511
530
  "",
512
- "# Brand",
531
+ `const assets = ${JSON.stringify(assets)};`,
513
532
  "",
514
- "Logo and favicon paths from the project.",
515
- "",
516
- "<table><thead><tr><th>Type</th><th>Path</th><th>Name</th></tr></thead><tbody>",
517
- ...assetRows,
518
- "</tbody></table>",
519
- ];
520
- fs.writeFileSync(path.join(foundationsDir, "Brand.stories.mdx"), brandContent.join("\n"), "utf-8");
521
- console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Brand.stories.mdx")));
522
- }
533
+ "export const Default: Story = {",
534
+ " render: () => (",
535
+ " <div>",
536
+ " <h2 style={{ marginBottom: 16 }}>Logo and favicon paths</h2>",
537
+ " <ul style={{ listStyle: \"none\", padding: 0 }}>",
538
+ " {assets.length === 0 ? <li>No brand assets found.</li> : assets.map((a, i) => (",
539
+ " <li key={i} style={{ padding: \"8px 0\", borderBottom: \"1px solid #222\" }}>",
540
+ " <strong>{a.type || \"asset\"}</strong>: <code>{a.path || a.name || \"\"}</code>",
541
+ " </li>",
542
+ " ))}",
543
+ " </ul>",
544
+ " </div>",
545
+ " ),",
546
+ "};",
547
+ ].join("\n");
548
+ fs.writeFileSync(path.join(foundationsDir, "Brand.stories.tsx"), brandContent, "utf-8");
549
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Brand.stories.tsx")));
523
550
  }
524
551
 
525
552
  function main() {
@@ -536,7 +563,17 @@ function main() {
536
563
 
537
564
  ensureDir(STORIES_DIR);
538
565
  ensureDir(path.join(STORIES_DIR, "foundations"));
539
- writeFoundationsMdx(foundations);
566
+ writeFoundationsStories(foundations);
567
+ try {
568
+ const fd = path.join(STORIES_DIR, "foundations");
569
+ if (fs.existsSync(fd)) {
570
+ for (const name of fs.readdirSync(fd)) {
571
+ if (name.endsWith(".stories.mdx")) fs.unlinkSync(path.join(fd, name));
572
+ }
573
+ }
574
+ } catch {
575
+ // ignore
576
+ }
540
577
 
541
578
  // Clear existing .stories.* files (except foundations/*.mdx) so only VDS-generated stories remain
542
579
  try {