vibe-design-system 1.9.2 → 1.9.3

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.3",
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
@@ -443,83 +443,106 @@ function getColorEntries(colors) {
443
443
  return entries;
444
444
  }
445
445
 
446
- function writeFoundationsMdx(foundations) {
446
+ function writeFoundationsStories(foundations) {
447
447
  const foundationsDir = path.join(STORIES_DIR, "foundations");
448
448
  ensureDir(foundationsDir);
449
449
 
450
- const colors = foundations?.colors;
451
- const colorEntries = getColorEntries(colors);
452
- if (colorEntries.length > 0) {
453
- const colorLines = [
454
- "import { Meta } from '@storybook/blocks';",
450
+ const colorEntries = getColorEntries(foundations?.colors);
451
+ const colorsContent =
452
+ STORY_CSS_HEADER +
453
+ [
454
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
455
455
  "",
456
- "<Meta title=\"Foundations/Colors\" />",
456
+ "const meta = { title: \"Foundations/Colors\" } satisfies Meta;",
457
+ "export default meta;",
458
+ "type Story = StoryObj;",
457
459
  "",
458
- "# Colors",
460
+ `const colors = ${JSON.stringify(colorEntries)};`,
459
461
  "",
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
- }
462
+ "export const Default: Story = {",
463
+ " render: () => (",
464
+ " <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(140px, 1fr))\", gap: \"1rem\" }}>",
465
+ " {colors.map(({ name, hex }) => (",
466
+ " <div key={name}>",
467
+ " <div style={{ backgroundColor: hex, height: 80, borderRadius: 8, border: \"1px solid #333\" }} />",
468
+ " <p style={{ marginTop: 8, fontSize: 12 }}>{name}</p>",
469
+ " <code style={{ fontSize: 11 }}>{hex}</code>",
470
+ " </div>",
471
+ " ))}",
472
+ " </div>",
473
+ " ),",
474
+ "};",
475
+ ].join("\n");
476
+ fs.writeFileSync(path.join(foundationsDir, "Colors.stories.tsx"), colorsContent, "utf-8");
477
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Colors.stories.tsx")));
470
478
 
471
479
  const typo = foundations?.typography;
472
480
  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")));
481
+ const typoRows = Object.entries(typo).map(([k, v]) => ({
482
+ token: k,
483
+ value: Array.isArray(v) ? v.join(", ") : String(v),
484
+ }));
485
+ const typoContent =
486
+ STORY_CSS_HEADER +
487
+ [
488
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
489
+ "",
490
+ "const meta = { title: \"Foundations/Typography\" } satisfies Meta;",
491
+ "export default meta;",
492
+ "type Story = StoryObj;",
493
+ "",
494
+ `const typography = ${JSON.stringify(typoRows)};`,
495
+ "",
496
+ "export const Default: Story = {",
497
+ " render: () => (",
498
+ " <div>",
499
+ " <h2 style={{ marginBottom: 16 }}>Font family & scale</h2>",
500
+ " <table style={{ borderCollapse: \"collapse\", width: \"100%\" }}>",
501
+ " <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>",
502
+ " <tbody>",
503
+ " {typography.map(({ token, value }) => (",
504
+ " <tr key={token}><td style={{ padding: 8, borderBottom: \"1px solid #222\" }}>{token}</td><td style={{ padding: 8, borderBottom: \"1px solid #222\" }}>{value}</td></tr>",
505
+ " ))}",
506
+ " </tbody>",
507
+ " </table>",
508
+ " </div>",
509
+ " ),",
510
+ "};",
511
+ ].join("\n");
512
+ fs.writeFileSync(path.join(foundationsDir, "Typography.stories.tsx"), typoContent, "utf-8");
513
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Typography.stories.tsx")));
499
514
  }
500
515
 
501
516
  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';",
517
+ const assets = Array.isArray(brandAssets) ? brandAssets : [];
518
+ const brandContent =
519
+ STORY_CSS_HEADER +
520
+ [
521
+ "import type { Meta, StoryObj } from \"@storybook/react\";",
509
522
  "",
510
- "<Meta title=\"Foundations/Brand\" />",
523
+ "const meta = { title: \"Foundations/Brand\" } satisfies Meta;",
524
+ "export default meta;",
525
+ "type Story = StoryObj;",
511
526
  "",
512
- "# Brand",
527
+ `const assets = ${JSON.stringify(assets)};`,
513
528
  "",
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
- }
529
+ "export const Default: Story = {",
530
+ " render: () => (",
531
+ " <div>",
532
+ " <h2 style={{ marginBottom: 16 }}>Logo and favicon paths</h2>",
533
+ " <ul style={{ listStyle: \"none\", padding: 0 }}>",
534
+ " {assets.length === 0 ? <li>No brand assets found.</li> : assets.map((a, i) => (",
535
+ " <li key={i} style={{ padding: \"8px 0\", borderBottom: \"1px solid #222\" }}>",
536
+ " <strong>{a.type || \"asset\"}</strong>: <code>{a.path || a.name || \"\"}</code>",
537
+ " </li>",
538
+ " ))}",
539
+ " </ul>",
540
+ " </div>",
541
+ " ),",
542
+ "};",
543
+ ].join("\n");
544
+ fs.writeFileSync(path.join(foundationsDir, "Brand.stories.tsx"), brandContent, "utf-8");
545
+ console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Brand.stories.tsx")));
523
546
  }
524
547
 
525
548
  function main() {
@@ -536,7 +559,17 @@ function main() {
536
559
 
537
560
  ensureDir(STORIES_DIR);
538
561
  ensureDir(path.join(STORIES_DIR, "foundations"));
539
- writeFoundationsMdx(foundations);
562
+ writeFoundationsStories(foundations);
563
+ try {
564
+ const fd = path.join(STORIES_DIR, "foundations");
565
+ if (fs.existsSync(fd)) {
566
+ for (const name of fs.readdirSync(fd)) {
567
+ if (name.endsWith(".stories.mdx")) fs.unlinkSync(path.join(fd, name));
568
+ }
569
+ }
570
+ } catch {
571
+ // ignore
572
+ }
540
573
 
541
574
  // Clear existing .stories.* files (except foundations/*.mdx) so only VDS-generated stories remain
542
575
  try {