storybook-addon-sdc 0.0.13 → 0.0.15
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 +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,36 @@ Drupal Single Directory Components as stories
|
|
|
5
5
|
|
|
6
6
|
This Storybook addon streamlines the integration of Drupal Single Directory Components (SDC) into Storybook. It leverages YAML configurations and Twig templates to dynamically load components and generate stories with minimal configuration.
|
|
7
7
|
|
|
8
|
+
## Why Choose SDC Storybook Over Alternatives?
|
|
9
|
+
|
|
10
|
+
While solutions like [SDC Styleguide](https://www.drupal.org/project/sdc_styleguide) and [Drupal Storybook](https://www.drupal.org/project/storybook) offer useful tools, using SDC with Storybook addon has clear advantages.
|
|
11
|
+
Here’s why:
|
|
12
|
+
|
|
13
|
+
#### 1. Component Independence and Modularity
|
|
14
|
+
- Following the __BEM (Block Element Modifier)__ methodology, a component should work independently across environments.
|
|
15
|
+
- The functionality of your component must not depend on the __Drupal version__, or the active __Drupal theme__ — it should be portable to __any__ system.
|
|
16
|
+
|
|
17
|
+
#### 2. No Complex Drupal Setup Required
|
|
18
|
+
- You don't need to install and configure Drupal with extra dependencies just to develop or test components.
|
|
19
|
+
- __Frontend development becomes faster__ by working in Storybook, without the need to run heavy Drupal environments locally.
|
|
20
|
+
|
|
21
|
+
#### 3. Simplifies DevOps and CI/CD Pipelines
|
|
22
|
+
- Since components are isolated, __testing and deployments__ are simplified.
|
|
23
|
+
- You can __avoid Drupal-specific configuration__ in CI pipelines, leading to more efficient and maintainable workflows.
|
|
24
|
+
|
|
25
|
+
#### 4. Scalability and Flexibility with Faker.js and JSON Schema
|
|
26
|
+
- Storybook allows the use of tools like __Faker.js__ to generate fake data for components. This makes it easy to test different scenarios without needing real content.
|
|
27
|
+
- With __JSON Schema__, components can be defined consistently, ensuring data integrity and clear documentation for developers.
|
|
28
|
+
|
|
29
|
+
#### 5. Industry-Standard Tool for Frontend Development
|
|
30
|
+
- __Storybook is a de facto standard__ for frontend development, making it easier for developers — even those unfamiliar with Drupal — to contribute to the project.
|
|
31
|
+
- JSON Schema allows developers to work on components without needing to understand Drupal’s internals, broadening participation in the project.
|
|
32
|
+
|
|
33
|
+
#### 6. Drupal-Specific Behavior Embedded in Components
|
|
34
|
+
- With __SDC Storybook__, you can embed __Drupal behaviors__ like `Drupal.attachBehaviors()` directly into the component preview. This ensures the component behaves the same way as it would on the actual site.
|
|
35
|
+
- Support for `drupalSettings` and `once.js` within Storybook ensures components behave identically during testing as they will on the Drupal site.
|
|
36
|
+
|
|
37
|
+
|
|
8
38
|
## The addon includes:
|
|
9
39
|
|
|
10
40
|
- A Vite plugin to load YAML-based SDC configurations.
|
|
@@ -54,7 +84,7 @@ const config: StorybookConfig = {
|
|
|
54
84
|
export default config;
|
|
55
85
|
```
|
|
56
86
|
|
|
57
|
-
##
|
|
87
|
+
## Experimental stories:
|
|
58
88
|
|
|
59
89
|
By default addon generates only Basic story for every component.
|
|
60
90
|
|
|
@@ -124,3 +154,13 @@ thirdPartySettings:
|
|
|
124
154
|
|
|
125
155
|
Or you can import yaml in regular storybook *.stories.js
|
|
126
156
|
|
|
157
|
+
### Why stories experimental?
|
|
158
|
+
|
|
159
|
+
The community will have to decide what format the yaml stories should be.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
## Known issues:
|
|
163
|
+
|
|
164
|
+
- UI Patterns stories format not yet [supported](https://www.drupal.org/project/ui_patterns/issues/3480464).
|
|
165
|
+
- Same problem will be with `$ref: json-schema-definitions://` for SDC from Experience Builder.
|
|
166
|
+
|