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
|
@@ -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
|
|
@@ -443,83 +443,106 @@ function getColorEntries(colors) {
|
|
|
443
443
|
return entries;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
function
|
|
446
|
+
function writeFoundationsStories(foundations) {
|
|
447
447
|
const foundationsDir = path.join(STORIES_DIR, "foundations");
|
|
448
448
|
ensureDir(foundationsDir);
|
|
449
449
|
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
"import { Meta } from
|
|
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
|
-
"
|
|
456
|
+
"const meta = { title: \"Foundations/Colors\" } satisfies Meta;",
|
|
457
|
+
"export default meta;",
|
|
458
|
+
"type Story = StoryObj;",
|
|
457
459
|
"",
|
|
458
|
-
|
|
460
|
+
`const colors = ${JSON.stringify(colorEntries)};`,
|
|
459
461
|
"",
|
|
460
|
-
"
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
"
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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
|
-
"
|
|
523
|
+
"const meta = { title: \"Foundations/Brand\" } satisfies Meta;",
|
|
524
|
+
"export default meta;",
|
|
525
|
+
"type Story = StoryObj;",
|
|
511
526
|
"",
|
|
512
|
-
|
|
527
|
+
`const assets = ${JSON.stringify(assets)};`,
|
|
513
528
|
"",
|
|
514
|
-
"
|
|
515
|
-
"",
|
|
516
|
-
"<
|
|
517
|
-
|
|
518
|
-
"
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
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
|
-
|
|
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 {
|