- Issue created by @miiimooo
I ran into the same issue while trying the same thing as Web-Beest.
How did you end up solving/bypassing this issue?
- 🇳🇱Netherlands Web-Beest
So, in hindsight, the args is not the place where you want to do this. It would result (if it worked) in rendered HTML appearing in your controls-pane in Storybook.
I've combined Storybook with SDC and came up with the following solution. I define the arguments I want to use in the args so I can alter them in controls. If you don't need to alter them, just define them as variables in Twig.
In the component I've defined properties and slots. The slots are there so you can embed large blocks as content without it being a property of that component. So for instance a fieldset has a legend and 'children' (which can be anything). This is a place where you can embed a large piece of content.
Fieldset template
<fieldset> <legend>{{ legend_title }}</legend> {% block children %} {{ children }} {% endblock %} </fieldset>
In my story I embed the component with a block:
{% embed 'theme:fieldset' with { legend: 'Fieldset legend' } %} {% block children %} {{ include('theme:component') }} {% endblock %} {% endembed %}
This way you can reuse stories / components in other stories.
- First commit to issue fork.
- Merge request !16a good start, can render an individual story from a collection of stories. → (Open) created by brayn7
- 🇺🇸United States brayn7 Lexington, Ky
I added a small twig extension. Probably be nice to harden validation. I think this will be very helpful in creating stories!
- 🇮🇹Italy tanc Italy
@brayn7 I gave your extension a quick go. It worked nicely in my test but the
findFileInDirectory
function has a hard coded path tocomponents
in the theme or module. Would it be possible for this to be a configurable or at least able to be overridden? We keep our stories in[themename]/stories
so it would be nice to be able to set that path. - 🇺🇸United States brayn7 Lexington, Ky
@tanc I have revised the lookup to include the whole module or theme. Unsure how performant that is looking in the whole directory so someone chime in about the efficiency of that. We could optionally pass one more arg in the twig function to designate what directory to look in with the default being /components.
- 🇳🇱Netherlands tim_dj Netherlands
Patch works as advertised. Does it make sense to search for stories outside of components? Then it's not exactly single direcctory component anymore?
- 🇮🇹Italy tanc Italy
It makes complete sense if you're not using SDCs. I'd like to see a default with the ability to override the path