-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use decorators when this addon is enabled #40
Comments
+1 to needing decorators. Since components are often constrained by layouts that are external to the component, this plugin should offer a way to wrap components in additional markup only when previewed in storybook. This would also be useful for allowing storybook to demonstrate how multiple components would look when displayed together, for example a grid of cards. After looking into this with @pjudge and @jkaeser today and here's what we've learned: This add-on is blowing away everything storybook rendersfetchStorybookHtml is set as a global server parameter, and when called does the following:
createNewBody in turn does the following:
This configuration essentially bypasses all the rendering & plugin capabilities of storybook, and leaves you with it as simply a way to catalog all the components. Since the "server" parameter in use doesn't ever look for decorators, they will never be applied. How this plugin could add in this functionalityThere are two paths that I can imagine this plugin/cl_server combo taking here: 1. The "storybook" or "javascript" wayIn storybook, decorators are functions that wrap a story's markup in additional markup. These can be added globally, per-component, or per-story. While a 1-to-1 implementation probably isn't likely, I could envision a scenario where the fetchStorybookHtml function described above ends it's process by emitting a new event from export default {
component: Button,
decorators: [
(Story) => {
window.addEventListener('cl_component_rendered', () => {
// do some custom DOM manipulation here after Drupal has returned the rendered component
})
}
],
}; This method has the downside of not being usable with 2. The "Drupal" wayAdd support for a new <div class="grid">
{% include 'component.html.twig' %}
</div> |
I am use SDC with Storybook using CL server. When trying to use a decorator to give a wrapper around the story, there seems to be an issue with the modified story. The story comes as undefined.
My layout.stories.js file:
Result of console.log on browser
I also tried using makeDecorator function but got the same issue
Can we pass in the custom user decorators somehow so that there can be some wrappers above Drupal generated code too?
The text was updated successfully, but these errors were encountered: