storybook-addon-sdc 0.0.17 → 0.0.19

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.
Files changed (2) hide show
  1. package/README.md +41 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Storybook SDC Addon Documentation
2
- Drupal Single Directory Components schema as stories.
2
+ This Storybook addon streamlines the integration of Drupal Single Directory Components(SDC) defined in YAML files (specifically *.component.yml) as stories.
3
3
 
4
- [![Image from Gyazo](https://i.gyazo.com/408dbe8cd2b02688e2ebaaee82d6b282.png)](https://gyazo.com/408dbe8cd2b02688e2ebaaee82d6b282)
4
+ [![Image from Gyazo](https://i.gyazo.com/2dcfa650c961679430d45eef24a82ab8.gif)](https://gyazo.com/2dcfa650c961679430d45eef24a82ab8)
5
5
 
6
6
  ## Overview:
7
7
 
@@ -36,6 +36,12 @@ Here’s why:
36
36
  - 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.
37
37
  - Support for `drupalSettings` and `once.js` within Storybook ensures components behave identically during testing as they will on the Drupal site.
38
38
 
39
+ #### 7. Twig.js vs Drupal Twig
40
+ While using Drupal to render components offers tighter integration, there are strong reasons to continue using Twig.js in many scenarios:
41
+
42
+ - Many Components __Don’t Need Full Drupal Logic__. Basic components (buttons, cards, lists) rely on simple HTML and CSS, not on complex template logic. For such components, Twig.js provides sufficient rendering without the need for full Drupal preprocessing.
43
+ - Twig.js Works Well for Frontend-Focused Use Cases.
44
+ - Styling and Behavior Mismatches Can Be Managed Separately in Drupal implelentation phase.
39
45
 
40
46
  ## The addon includes:
41
47
 
@@ -46,24 +52,23 @@ Here’s why:
46
52
 
47
53
  ## This addon uses:
48
54
 
49
- - https://github.com/larowlan/vite-plugin-twig-drupal for load Twig with Drupal functions.
55
+ - https://github.com/larowlan/vite-plugin-twig-drupal for loads Twig with Drupal functions.
50
56
  - https://github.com/json-schema-faker/json-schema-faker for generation missed props and slots.
51
57
 
52
58
  ## Installation:
53
59
 
60
+ In `@storybook/html-vite`:
61
+ https://storybook.js.org/docs/builders/vite
62
+
54
63
  ```
55
64
  npm i storybook-addon-sdc
56
65
  ```
57
66
 
58
- ## Configuration:
67
+ ### Configuration:
59
68
 
60
- In vite-html storybook https://storybook.js.org/docs/builders/vite
61
-
62
- main.ts
69
+ .storybook/main.js
63
70
  ```
64
- import type { StorybookConfig } from "@storybook/html-vite";
65
-
66
- const config: StorybookConfig = {
71
+ const config = {
67
72
  stories: ["../components/**/*.component.yml"], // Your components directory.
68
73
  addons: [
69
74
  {
@@ -86,6 +91,31 @@ const config: StorybookConfig = {
86
91
  export default config;
87
92
  ```
88
93
 
94
+ ### Default values
95
+
96
+ json-schema-faker not always generate good data. For optimal results, use `default` or `examples` for SDC schema:
97
+ ```
98
+ props:
99
+ type: object
100
+ properties:
101
+ html_tag:
102
+ type: string
103
+ enum:
104
+ - article
105
+ - div
106
+ default: article
107
+ slots:
108
+ content:
109
+ title: Content
110
+ examples:
111
+ - Hello! I'm card content
112
+ ```
113
+
114
+ - https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components/annotated-example-componentyml
115
+ - https://json-schema.org/understanding-json-schema/reference/annotations
116
+
117
+
118
+
89
119
  ## Experimental stories:
90
120
 
91
121
  By default addon generates only Basic story for every component.
@@ -158,7 +188,7 @@ Or you can import yaml in regular storybook *.stories.js
158
188
 
159
189
  ### Why stories experimental?
160
190
 
161
- The community will have to decide what format the yaml stories should be.
191
+ 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.
162
192
 
163
193
 
164
194
  ## Known issues:
@@ -166,7 +196,4 @@ The community will have to decide what format the yaml stories should be.
166
196
  - UI Patterns stories format not yet [supported](https://www.drupal.org/project/ui_patterns/issues/3480464).
167
197
  - Same problem will be with `$ref: json-schema-definitions://` for SDC from Experience Builder.
168
198
  - Plugin uses [Experimental indexers](https://storybook.js.org/docs/api/main-config/main-config-indexers)
169
- - json-schema-faker not always generate good data. Better to use `default` or `examples` for SDC schema
170
- https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components/annotated-example-componentyml
171
- https://json-schema.org/understanding-json-schema/reference/annotations
172
199
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-sdc",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Drupal Single Directory Components as stories",
5
5
  "keywords": [
6
6
  "SDC",