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
|
@@ -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
|
|
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 '
|
|
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
|
|
450
|
+
function writeFoundationsStories(foundations) {
|
|
447
451
|
const foundationsDir = path.join(STORIES_DIR, "foundations");
|
|
448
452
|
ensureDir(foundationsDir);
|
|
449
453
|
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
"import { Meta } from
|
|
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
|
-
"
|
|
460
|
+
"const meta = { title: \"Foundations/Colors\" } satisfies Meta;",
|
|
461
|
+
"export default meta;",
|
|
462
|
+
"type Story = StoryObj;",
|
|
457
463
|
"",
|
|
458
|
-
|
|
464
|
+
`const colors = ${JSON.stringify(colorEntries)};`,
|
|
459
465
|
"",
|
|
460
|
-
"
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
"
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
"
|
|
492
|
-
"
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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
|
-
"
|
|
527
|
+
"const meta = { title: \"Foundations/Brand\" } satisfies Meta;",
|
|
528
|
+
"export default meta;",
|
|
529
|
+
"type Story = StoryObj;",
|
|
511
530
|
"",
|
|
512
|
-
|
|
531
|
+
`const assets = ${JSON.stringify(assets)};`,
|
|
513
532
|
"",
|
|
514
|
-
"
|
|
515
|
-
"",
|
|
516
|
-
"<
|
|
517
|
-
|
|
518
|
-
"
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
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
|
-
|
|
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 {
|