storybook-addon-sdc 0.7.7 → 0.7.8
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/README.md +34 -0
- package/dist/preset.js +15 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ This addon streamlines the integration of Drupal Single Directory Components (SD
|
|
|
14
14
|
- [Configuration](#configuration)
|
|
15
15
|
- [Setting Default Values](#setting-default-values)
|
|
16
16
|
- [Creating Experimental Stories](#creating-experimental-stories)
|
|
17
|
+
- [Support for Single Story Files (\*.story.yml)](#support-for-single-story-files-storyyml)
|
|
17
18
|
- [Regular Storybook](#regular-storybook)
|
|
18
19
|
- [Configuration Options](#configuration-options)
|
|
19
20
|
- [Dependencies](#dependencies)
|
|
@@ -244,6 +245,39 @@ The addon dynamically renders the components and stories as defined:
|
|
|
244
245
|
|
|
245
246
|
[](https://gyazo.com/7212a3f44052ebde34b59a1555d96afe)
|
|
246
247
|
|
|
248
|
+
## Support for Single Story Files (`*.story.yml`)
|
|
249
|
+
|
|
250
|
+
In addition to stories defined inside `*.component.yml` files, the addon now supports standalone story files with the `.story.yml` extension.
|
|
251
|
+
|
|
252
|
+
This means you can create independent stories for your components by simply adding a `.story.yml` file in your component directory. These files are automatically discovered and indexed by Storybook, allowing you to organize and share stories outside of the main component YAML.
|
|
253
|
+
|
|
254
|
+
**Example:**
|
|
255
|
+
|
|
256
|
+
```yaml
|
|
257
|
+
# components/slider/slider.badges.story.yml
|
|
258
|
+
name: Badges
|
|
259
|
+
props:
|
|
260
|
+
slides:
|
|
261
|
+
- type: component
|
|
262
|
+
component: 'umami:badge'
|
|
263
|
+
props:
|
|
264
|
+
icon: timer
|
|
265
|
+
slots:
|
|
266
|
+
text: Hola
|
|
267
|
+
- type: component
|
|
268
|
+
component: 'umami:badge'
|
|
269
|
+
props:
|
|
270
|
+
icon: serves
|
|
271
|
+
slots:
|
|
272
|
+
text: Bonjour
|
|
273
|
+
- type: component
|
|
274
|
+
component: 'umami:badge'
|
|
275
|
+
props:
|
|
276
|
+
icon: difficulty
|
|
277
|
+
slots:
|
|
278
|
+
text: Ciao
|
|
279
|
+
```
|
|
280
|
+
|
|
247
281
|
### Why stories experimental?
|
|
248
282
|
|
|
249
283
|
The [community will have to decide](https://docs.google.com/document/d/1wCQLXrK1lrV2gYlqmqD2pybTql6_H1dByWIKB5xQFcQ/edit?tab=t.0#heading=h.3949vjfiqczr) what format the YAML stories should be.
|
package/dist/preset.js
CHANGED
|
@@ -181,7 +181,9 @@ var readSDC = (filePath, defs, validate) => {
|
|
|
181
181
|
}
|
|
182
182
|
return sdcSchema;
|
|
183
183
|
};
|
|
184
|
-
var generateImports = (directory) => readdirSync2(directory).filter(
|
|
184
|
+
var generateImports = (directory) => readdirSync2(directory).filter(
|
|
185
|
+
(file) => [".css", ".js", ".mjs", ".twig", ".yml"].includes(extname(file))
|
|
186
|
+
).map((file) => {
|
|
185
187
|
const filePath = `./${file}`;
|
|
186
188
|
return extname(file) === ".twig" ? `import COMPONENT from '${filePath}';` : `import '${filePath}';`;
|
|
187
189
|
}).join("\n");
|
|
@@ -251,9 +253,7 @@ var vite_plugin_storybook_yaml_stories_default = ({
|
|
|
251
253
|
...content.thirdPartySettings?.sdcStorybook?.stories || {},
|
|
252
254
|
...loadStoryFilesSync(id)
|
|
253
255
|
};
|
|
254
|
-
const storiesImports = dynamicImports(
|
|
255
|
-
previewsStories
|
|
256
|
-
);
|
|
256
|
+
const storiesImports = dynamicImports(previewsStories);
|
|
257
257
|
const metadata = componentMetadata_default(id, content);
|
|
258
258
|
const argTypes = {
|
|
259
259
|
componentMetadata: { table: { disable: true } },
|
|
@@ -325,14 +325,17 @@ var yamlStoriesIndexer = {
|
|
|
325
325
|
var loadStoryFilesSync = (fileName) => {
|
|
326
326
|
const folderPath = dirname2(fileName);
|
|
327
327
|
const storyFiles = globSync(join2(folderPath, "*.story.yml"));
|
|
328
|
-
return storyFiles.reduce(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
328
|
+
return storyFiles.reduce(
|
|
329
|
+
(acc, file) => {
|
|
330
|
+
const content = readFileSync(file, "utf8");
|
|
331
|
+
const key = basename(file).split(".")[1];
|
|
332
|
+
return {
|
|
333
|
+
...acc,
|
|
334
|
+
[key]: parseYaml(content)
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
{}
|
|
338
|
+
);
|
|
336
339
|
};
|
|
337
340
|
|
|
338
341
|
// src/preset.ts
|