Replies: 1 comment
-
|
Ah... I think I didn't realise I am hitting: #8 - as documented right at the top of the "known issues" page in the docs (I did look, didn't recognise it until after typing out the above). 🤦 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello folks, apologies if this is something obvious - context: I'm pretty new to this sort of tool and front-end dev practices (i.e. I don't particularly know Storybook.)
I have set up django-pattern-library and this is working. I like how it works and the ideas behind it.
I have a component template similar to the demo's 'accordian' - and it has its YAML file defining the equivalent of 4 'accordians' items, this works great.
I have a page template that includes this component, like the demo 'person_page' - and it has a YAML file that defines 2 items for the 'accordians' (the key difference is it has no 'page' layer in the YAML data, i.e. just 'accordians' not 'page.accordians').
So I have a similar component/page relationship (but in my case a list of "tickets"). I expected that the data context from the including template/page would be used at the included template/component level... but this isn't what happened. What I got is a count of items based on the including page's YAML (count is in the including page template) but then a list of items based on the YAML for the included template.
I noticed the 'with accordians=page.accordians' in the demo template code so tested this out with my example and I can make it work by adding 'with tickets=tickets' to the include line, but this feels a little obtuse (the template does not otherwise need this in deployment, so it feels weird to add it just to support the pattern library?)
Is it a specific design decision for the YAML from the included template to take precedence like this? Would there be a way to have the included template use the value defined in the including page's YAML, only falling back on the included template's YAML if a shadowing value is not defined in the parent YAML?
I noticed that if the component YAML doesn't define 'tickets' then the 'tickets' value from the YAML for the including page does apply in the component, so it does seem to be available at that level, but the included template's version has priority unless the 'with' is used.
Apologies if I have missed something relevant from the docs, or if I need to explain more clearly (or provide an example, I hope ref to the demo is example enough.) Thanks!
Beta Was this translation helpful? Give feedback.
All reactions