storybook-addon-sdc 0.14.2 → 0.15.1
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 +9 -6
- package/dist/preset.js +12 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,10 +19,10 @@ This addon streamlines the integration of Drupal Single Directory Components (SD
|
|
|
19
19
|
- [Configuration Options](#configuration-options)
|
|
20
20
|
- [Setting Default Values](#setting-default-values)
|
|
21
21
|
- [Story Configuration via thirdPartySettings.sdcStorybook](#story-configuration-via-thirdpartysettingssdcstorybook)
|
|
22
|
+
- [UI Patterns](#ui-patterns)
|
|
22
23
|
- [Why Choose SDC Storybook Over Alternatives?](#why-choose-sdc-storybook-over-alternatives)
|
|
23
24
|
- [Dependencies](#dependencies)
|
|
24
25
|
- [Known Issues](#known-issues)
|
|
25
|
-
- [UI Patterns](#ui-patterns)
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -637,6 +637,14 @@ thirdPartySettings:
|
|
|
637
637
|
|
|
638
638
|
This configuration creates an additional story named **Preview**, rendered using the provided `args` and `parameters`.
|
|
639
639
|
|
|
640
|
+
## UI Patterns
|
|
641
|
+
|
|
642
|
+
Addon supports UI Patterns `library_wrapper` [for wrapping stories](https://project.pages.drupalcode.org/ui_patterns/2-authors/1-stories-and-library/#library-wrappers) in a specific HTML structure.
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
646
|
+
- Custom Twig filters and functions are not supported ([UI Patterns TwigExtension](https://git.drupalcode.org/project/ui_patterns/-/blob/8.x-1.x/src/Template/TwigExtension.php)).
|
|
647
|
+
|
|
640
648
|
## Why Choose SDC Storybook Over Alternatives?
|
|
641
649
|
|
|
642
650
|
While solutions like [SDC Styleguide](https://www.drupal.org/project/sdc_styleguide) and [Drupal Storybook](https://www.drupal.org/project/storybook) are valuable, the SDC Storybook addon offers distinct advantages:
|
|
@@ -690,8 +698,3 @@ While using Drupal to render components offers tighter integration, there are st
|
|
|
690
698
|
## Known Issues
|
|
691
699
|
|
|
692
700
|
- The addon relies on [Experimental indexers](https://storybook.js.org/docs/api/main-config/main-config-indexers).
|
|
693
|
-
|
|
694
|
-
## UI Patterns
|
|
695
|
-
|
|
696
|
-
- Variants are partially supported ([Issue 3390712](https://www.drupal.org/project/drupal/issues/3390712)).
|
|
697
|
-
- Custom Twig filters and functions are not supported ([UI Patterns TwigExtension](https://git.drupalcode.org/project/ui_patterns/-/blob/8.x-1.x/src/Template/TwigExtension.php)).
|
package/dist/preset.js
CHANGED
|
@@ -161,7 +161,8 @@ var storiesGenerator_default = (stories) => Object.entries(stories).map(
|
|
|
161
161
|
slots = {},
|
|
162
162
|
variants = {},
|
|
163
163
|
description = "",
|
|
164
|
-
name = void 0
|
|
164
|
+
name = void 0,
|
|
165
|
+
library_wrapper = ""
|
|
165
166
|
}
|
|
166
167
|
]) => `
|
|
167
168
|
export const ${capitalize(storyKey)} = {
|
|
@@ -173,6 +174,16 @@ export const ${capitalize(storyKey)} = {
|
|
|
173
174
|
${generateArgs2(slots, true)}
|
|
174
175
|
${generateVariants(variants)}
|
|
175
176
|
},
|
|
177
|
+
${library_wrapper ? `decorators: [
|
|
178
|
+
(Story) => {
|
|
179
|
+
const wrapper = ${JSON.stringify(library_wrapper)};
|
|
180
|
+
if (!wrapper) return Story();
|
|
181
|
+
|
|
182
|
+
// Replace {{ _story }} with the actual story component
|
|
183
|
+
const wrappedHtml = wrapper.replace('{{ _story }}', Story());
|
|
184
|
+
return wrappedHtml;
|
|
185
|
+
}
|
|
186
|
+
],` : ""}
|
|
176
187
|
play: async ({ canvasElement }) => {
|
|
177
188
|
Drupal.attachBehaviors(canvasElement, window.drupalSettings);
|
|
178
189
|
},
|