mirror of
https://github.com/Lapikud/lapikud.github.io.git
synced 2026-08-08 22:59:14 +00:00
components and tailwind rework
This commit is contained in:
37
generate-stories.js
Normal file
37
generate-stories.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, resolve } from 'path';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const svelteSrc = readFileSync(resolve(__dirname, './src/components/Svg.svelte'), 'utf-8');
|
||||
|
||||
const match = svelteSrc.match(/export const VARIANTS\s*=\s*\[([^\]]+)\]/);
|
||||
if (!match) {
|
||||
console.error('Could not find VARIANTS in Svg.svelte');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const variants = match[1]
|
||||
.split(',')
|
||||
.map(v => v.trim().replace(/['"]/g, ''))
|
||||
.filter(Boolean);
|
||||
|
||||
const stories = variants.map(v => `<Story name="${v}" args={{ type: '${v}' }} />`).join('\n');
|
||||
|
||||
const output = `<script context="module">
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import Svg from '../components/Svg.svelte';
|
||||
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Svg',
|
||||
component: Svg,
|
||||
});
|
||||
</script>
|
||||
|
||||
${stories}
|
||||
`;
|
||||
|
||||
const outPath = resolve(__dirname, './src/stories/Svg.stories.svelte');
|
||||
writeFileSync(outPath, output, 'utf-8');
|
||||
console.log(`✅ Generated ${variants.length} stories: ${variants.join(', ')}`);
|
||||
Reference in New Issue
Block a user