vibe-design-system 2.4.3 → 2.4.6
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/bin/init.js +21 -1
- package/package.json +1 -1
- package/vds-core-template/story-generator.mjs +34 -20
package/bin/init.js
CHANGED
|
@@ -34,8 +34,28 @@ export default config;
|
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
36
|
const STORYBOOK_PREVIEW_TS = `import type { Preview } from "@storybook/react";
|
|
37
|
+
import React from "react";
|
|
37
38
|
import "../src/index.css";
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
const preview: Preview = {
|
|
41
|
+
parameters: {
|
|
42
|
+
backgrounds: {
|
|
43
|
+
default: "dark",
|
|
44
|
+
values: [
|
|
45
|
+
{ name: "light", value: "#ffffff" },
|
|
46
|
+
{ name: "dark", value: "#020617" },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
decorators: [
|
|
51
|
+
(Story) => {
|
|
52
|
+
// Force dark mode for Lovable/shadcn CSS token resolution
|
|
53
|
+
document.documentElement.classList.add("dark");
|
|
54
|
+
return React.createElement(Story, null);
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
|
|
39
59
|
export default preview;
|
|
40
60
|
`;
|
|
41
61
|
|
package/package.json
CHANGED
|
@@ -399,9 +399,10 @@ function detectExportStyle(source, componentName) {
|
|
|
399
399
|
function buildSpecialStories(componentName, variants) {
|
|
400
400
|
const lines = [];
|
|
401
401
|
|
|
402
|
-
// Simple input-like primitives
|
|
402
|
+
// Simple input-like primitives — always render real component with args
|
|
403
403
|
if (componentName === "Input") {
|
|
404
404
|
lines.push(`export const Default: Story = {`);
|
|
405
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
405
406
|
lines.push(` args: {`);
|
|
406
407
|
lines.push(` placeholder: "Enter your email...",`);
|
|
407
408
|
lines.push(` type: "email",`);
|
|
@@ -412,6 +413,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
412
413
|
|
|
413
414
|
if (componentName === "Textarea") {
|
|
414
415
|
lines.push(`export const Default: Story = {`);
|
|
416
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
415
417
|
lines.push(` args: {`);
|
|
416
418
|
lines.push(` placeholder: "Write your message...",`);
|
|
417
419
|
lines.push(` rows: 4,`);
|
|
@@ -422,6 +424,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
422
424
|
|
|
423
425
|
if (componentName === "Label") {
|
|
424
426
|
lines.push(`export const Default: Story = {`);
|
|
427
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
425
428
|
lines.push(` args: {`);
|
|
426
429
|
lines.push(` children: "Email address",`);
|
|
427
430
|
lines.push(` htmlFor: "email",`);
|
|
@@ -432,6 +435,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
432
435
|
|
|
433
436
|
if (componentName === "Slider") {
|
|
434
437
|
lines.push(`export const Default: Story = {`);
|
|
438
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
435
439
|
lines.push(` args: {`);
|
|
436
440
|
lines.push(` defaultValue: [50],`);
|
|
437
441
|
lines.push(` max: 100,`);
|
|
@@ -443,6 +447,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
443
447
|
|
|
444
448
|
if (componentName === "Calendar") {
|
|
445
449
|
lines.push(`export const Default: Story = {`);
|
|
450
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
446
451
|
lines.push(` args: {},`);
|
|
447
452
|
lines.push(`};`);
|
|
448
453
|
return lines.join("\n");
|
|
@@ -450,6 +455,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
450
455
|
|
|
451
456
|
if (componentName === "InputOtp" || componentName === "InputOTP") {
|
|
452
457
|
lines.push(`export const Default: Story = {`);
|
|
458
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
453
459
|
lines.push(` args: {`);
|
|
454
460
|
lines.push(` maxLength: 6,`);
|
|
455
461
|
lines.push(` },`);
|
|
@@ -462,6 +468,7 @@ function buildSpecialStories(componentName, variants) {
|
|
|
462
468
|
vs.forEach((v, idx) => {
|
|
463
469
|
const storyName = capitalize(v);
|
|
464
470
|
lines.push(`export const ${storyName}: Story = {`);
|
|
471
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
465
472
|
lines.push(` args: {`);
|
|
466
473
|
lines.push(` variant: "${v}",`);
|
|
467
474
|
lines.push(` children: "New",`);
|
|
@@ -626,9 +633,10 @@ function buildStoryFileContent(comp) {
|
|
|
626
633
|
return lines.join("\n");
|
|
627
634
|
}
|
|
628
635
|
|
|
629
|
-
// Generic variant-based stories (omit children for img/void
|
|
636
|
+
// Generic variant-based stories — render real component with args (omit children for img/void)
|
|
630
637
|
if (!variants.length) {
|
|
631
638
|
lines.push(`export const Default: Story = {`);
|
|
639
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
632
640
|
lines.push(` args: {`);
|
|
633
641
|
if (!omitChildren) lines.push(` children: "${componentName}",`);
|
|
634
642
|
lines.push(` },`);
|
|
@@ -636,6 +644,7 @@ function buildStoryFileContent(comp) {
|
|
|
636
644
|
} else {
|
|
637
645
|
const defaultVariant = variants[0];
|
|
638
646
|
lines.push(`export const ${capitalize(defaultVariant)}: Story = {`);
|
|
647
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
639
648
|
lines.push(` args: {`);
|
|
640
649
|
lines.push(` variant: "${defaultVariant}",`);
|
|
641
650
|
if (!omitChildren) lines.push(` children: "${componentName}",`);
|
|
@@ -645,6 +654,7 @@ function buildStoryFileContent(comp) {
|
|
|
645
654
|
for (const v of variants.slice(1)) {
|
|
646
655
|
const storyName = capitalize(v);
|
|
647
656
|
lines.push(`export const ${storyName}: Story = {`);
|
|
657
|
+
lines.push(` render: (args) => <ComponentRef {...args} />,`);
|
|
648
658
|
lines.push(` args: {`);
|
|
649
659
|
lines.push(` variant: "${v}",`);
|
|
650
660
|
if (!omitChildren) lines.push(` children: "${storyName}",`);
|
|
@@ -688,12 +698,14 @@ function writeFoundationsStories(foundations) {
|
|
|
688
698
|
"",
|
|
689
699
|
"export const Default: Story = {",
|
|
690
700
|
" render: () => (",
|
|
691
|
-
" <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(
|
|
701
|
+
" <div style={{ display: \"grid\", gridTemplateColumns: \"repeat(auto-fill, minmax(160px, 1fr))\", gap: \"1rem\" }}>",
|
|
692
702
|
" {colors.map(({ name, hex }) => (",
|
|
693
|
-
" <div key={name}>",
|
|
694
|
-
" <div style={{ backgroundColor: hex, height:
|
|
695
|
-
" <
|
|
696
|
-
"
|
|
703
|
+
" <div key={name} style={{ display: \"flex\", alignItems: \"center\", gap: 12, flexWrap: \"wrap\" }}>",
|
|
704
|
+
" <div style={{ backgroundColor: hex, width: 48, height: 48, borderRadius: 8, border: \"1px solid #333\", flexShrink: 0 }} />",
|
|
705
|
+
" <div>",
|
|
706
|
+
" <p style={{ margin: 0, fontSize: 12, fontWeight: 500 }}>{name}</p>",
|
|
707
|
+
" <code style={{ fontSize: 11, color: \"#888\" }}>{hex}</code>",
|
|
708
|
+
" </div>",
|
|
697
709
|
" </div>",
|
|
698
710
|
" ))}",
|
|
699
711
|
" </div>",
|
|
@@ -705,10 +717,12 @@ function writeFoundationsStories(foundations) {
|
|
|
705
717
|
|
|
706
718
|
const typo = foundations?.typography;
|
|
707
719
|
if (typo && typeof typo === "object" && Object.keys(typo).length > 0) {
|
|
708
|
-
const typoRows = Object.entries(typo).map(([k, v]) =>
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
720
|
+
const typoRows = Object.entries(typo).map(([k, v]) => {
|
|
721
|
+
const displayValue = typeof v === "object" && v !== null
|
|
722
|
+
? (v.family || v.value || JSON.stringify(v))
|
|
723
|
+
: Array.isArray(v) ? v.join(", ") : String(v);
|
|
724
|
+
return { token: k, value: displayValue, fontFamily: displayValue };
|
|
725
|
+
});
|
|
712
726
|
const typoContent =
|
|
713
727
|
[
|
|
714
728
|
"import type { Meta, StoryObj } from \"@storybook/react\";",
|
|
@@ -723,14 +737,14 @@ function writeFoundationsStories(foundations) {
|
|
|
723
737
|
" render: () => (",
|
|
724
738
|
" <div>",
|
|
725
739
|
" <h2 style={{ marginBottom: 16 }}>Font family & scale</h2>",
|
|
726
|
-
" <
|
|
727
|
-
"
|
|
728
|
-
"
|
|
729
|
-
"
|
|
730
|
-
" <
|
|
731
|
-
"
|
|
732
|
-
"
|
|
733
|
-
" </
|
|
740
|
+
" <div style={{ display: \"flex\", flexDirection: \"column\", gap: 24 }}>",
|
|
741
|
+
" {typography.map(({ token, value, fontFamily }) => (",
|
|
742
|
+
" <div key={token} style={{ borderBottom: \"1px solid #222\", paddingBottom: 16 }}>",
|
|
743
|
+
" <div style={{ marginBottom: 8 }}><strong>{token}</strong> <code style={{ fontSize: 12, color: \"#888\" }}>{value}</code></div>",
|
|
744
|
+
" <div style={{ fontFamily: fontFamily || \"inherit\", fontSize: 18 }}>Aa — The quick brown fox jumps over the lazy dog.</div>",
|
|
745
|
+
" </div>",
|
|
746
|
+
" ))}",
|
|
747
|
+
" </div>",
|
|
734
748
|
" </div>",
|
|
735
749
|
" ),",
|
|
736
750
|
"};",
|
|
@@ -756,7 +770,7 @@ function writeFoundationsStories(foundations) {
|
|
|
756
770
|
" <div style={{ display: \"flex\", gap: 24, flexWrap: \"wrap\", padding: 24 }}>",
|
|
757
771
|
" {assets.length === 0 ? <p>No brand assets found.</p> : assets.map((a, i) => (",
|
|
758
772
|
" <div key={i} style={{ textAlign: \"center\" }}>",
|
|
759
|
-
" <img src={\"/\" + String(a.path || \"\").replace(\"public/\", \"\")} style={{ maxHeight:
|
|
773
|
+
" <img src={\"/\" + String(a.path || \"\").replace(\"public/\", \"\")} style={{ maxHeight: 100, maxWidth: 200, objectFit: \"contain\" }} alt={a.name || \"\"} />",
|
|
760
774
|
" <div style={{ fontSize: 11, marginTop: 8, color: \"#666\" }}>{a.name || a.type || \"asset\"}</div>",
|
|
761
775
|
" </div>",
|
|
762
776
|
" ))}",
|