vibe-design-system 2.8.58 → 2.8.59
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 +2 -1
- package/package.json +1 -1
- package/vds-core-template/story-generator.mjs +44 -5
package/bin/init.js
CHANGED
|
@@ -278,8 +278,9 @@ export default config;
|
|
|
278
278
|
// vite (default) & remix
|
|
279
279
|
// For fullstack projects (client/src, frontend/src, etc.), add staticDirs for public assets
|
|
280
280
|
const frontendDir = srcPrefix.split("/")[0]; // e.g. "client" from "client/src"
|
|
281
|
+
// Map public/ to "/" so components can load /images/... /figmaAssets/... etc. without prefix
|
|
281
282
|
const staticDirsLine = srcPrefix !== "src"
|
|
282
|
-
? `\n staticDirs: [
|
|
283
|
+
? `\n staticDirs: ["../${frontendDir}/public"],`
|
|
283
284
|
: "";
|
|
284
285
|
|
|
285
286
|
return `import type { StorybookConfig } from "@storybook/react-vite";
|
package/package.json
CHANGED
|
@@ -2365,8 +2365,47 @@ function writeFoundationsStories(foundations) {
|
|
|
2365
2365
|
console.log("[VDS] Wrote " + path.relative(PROJECT_ROOT, path.join(foundationsDir, "Typography.stories.tsx")));
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
|
+
// Collect brand assets: prefer scan data, fallback to scanning public/ directories
|
|
2368
2369
|
const brandAssets = foundations?.brand?.assets;
|
|
2369
|
-
|
|
2370
|
+
let assets = Array.isArray(brandAssets) ? brandAssets : [];
|
|
2371
|
+
|
|
2372
|
+
// Also scan public/ dirs directly — scan.mjs may miss most project image assets
|
|
2373
|
+
{
|
|
2374
|
+
const publicDirs = [
|
|
2375
|
+
path.join(PROJECT_ROOT, "public"),
|
|
2376
|
+
path.join(PROJECT_ROOT, "client", "public"),
|
|
2377
|
+
path.join(PROJECT_ROOT, "frontend", "public"),
|
|
2378
|
+
path.join(PROJECT_ROOT, "src", "assets"),
|
|
2379
|
+
path.join(PROJECT_ROOT, "client", "src", "assets"),
|
|
2380
|
+
];
|
|
2381
|
+
const IMAGE_EXT = /\.(svg|png|jpg|jpeg|webp|gif)$/i;
|
|
2382
|
+
const existingUrls = new Set(assets.map((a) => a.url || a.path || ""));
|
|
2383
|
+
|
|
2384
|
+
for (const pubDir of publicDirs) {
|
|
2385
|
+
if (!fs.existsSync(pubDir)) continue;
|
|
2386
|
+
const newAssets = [];
|
|
2387
|
+
const scanDir = (dir, baseUrl) => {
|
|
2388
|
+
let entries;
|
|
2389
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
2390
|
+
for (const e of entries) {
|
|
2391
|
+
const urlPath = baseUrl + "/" + e.name;
|
|
2392
|
+
if (e.isDirectory()) {
|
|
2393
|
+
scanDir(path.join(dir, e.name), urlPath);
|
|
2394
|
+
} else if (IMAGE_EXT.test(e.name) && !existingUrls.has(urlPath)) {
|
|
2395
|
+
newAssets.push({ name: e.name.replace(/\.[^.]+$/, ""), url: urlPath });
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
scanDir(pubDir, "");
|
|
2400
|
+
if (newAssets.length > 0) {
|
|
2401
|
+
assets = [...assets, ...newAssets];
|
|
2402
|
+
break; // Use first matching public dir only
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
// Limit to 40 assets to keep story file size reasonable
|
|
2406
|
+
assets = assets.slice(0, 40);
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2370
2409
|
const brandContent =
|
|
2371
2410
|
[
|
|
2372
2411
|
"import type { Meta, StoryObj } from \"@storybook/react\";",
|
|
@@ -2380,10 +2419,10 @@ function writeFoundationsStories(foundations) {
|
|
|
2380
2419
|
"export const Default: Story = {",
|
|
2381
2420
|
" render: () => (",
|
|
2382
2421
|
" <div style={{ display: \"flex\", gap: 24, flexWrap: \"wrap\", padding: 24 }}>",
|
|
2383
|
-
" {assets.length === 0 ? <p>No brand assets found
|
|
2384
|
-
" <div key={i} style={{ textAlign: \"center\" }}>",
|
|
2385
|
-
" <img src={\"/\" + String(a.path || \"\").replace(
|
|
2386
|
-
" <div style={{ fontSize: 11, marginTop: 8, color: \"#666\" }}>{a.name || a.type || \"asset\"}</div>",
|
|
2422
|
+
" {assets.length === 0 ? <p style={{ color: '#888', fontFamily: 'monospace' }}>No brand assets found — add images to public/ or client/public/</p> : assets.map((a, i) => (",
|
|
2423
|
+
" <div key={i} style={{ textAlign: \"center\", background: '#f8f8f8', borderRadius: 8, padding: 12, minWidth: 120 }}>",
|
|
2424
|
+
" <img src={a.url || (\"/\" + String(a.path || \"\").replace(/^public\\//, \"\"))} style={{ maxHeight: 100, maxWidth: 180, objectFit: \"contain\", display: 'block', margin: '0 auto' }} alt={a.name || \"\"} />",
|
|
2425
|
+
" <div style={{ fontSize: 11, marginTop: 8, color: \"#666\", wordBreak: 'break-all' }}>{a.name || a.type || \"asset\"}</div>",
|
|
2387
2426
|
" </div>",
|
|
2388
2427
|
" ))}",
|
|
2389
2428
|
" </div>",
|