Discussion: Add support for category-level data overrides #31
Description
As a design system creator using Pattern Lab, I want to be able to override data values at the category level, so that I don't have to manually copy-paste (and maintain) overridden values that are shared by all patterns in that category
@tburny originally enquired on the #patternlab-node Gitter if there was a way to override data.json
for a single directory only. The motivation was for projects where different brands share the same UI components and layout but differ only in the skinning of the UI.
I believe this feature would also be useful for the pages
category, since replacing data values to swap lorem ipsum text and wireframe images for realistic content often needs to be repeated per page (since different pages may be re-using the same data values). Currently the only means to do this is to create patternName.json
files for each pattern under the pages folder and copy-paste the relevant values into each. When you throw listitems overrides into the mix this gets tedious very quickly. Maintenance is also a pain since you need to update multiple copies of the same value.
Being able to have a single file that applies to an entire directory would therefore be a big convenience win in these scenarios.
Perhaps something like this:
|
+- 04-pages/
| |
| +- 99-foo.mustache # Usual stuff...
| +- 99-foo.json
| +- 99-foo.listitems.json
| +- 99-foo.md
|
+- 04-pages.md
+- 04-pages.json # NEW data that can override root data.json for every pattern inside 00-atoms/
+- 04-pages.listitems.json # NEW listitems equivalent of the above
The expectation would be that to find the data values used when rendering 99-foo.mustache
PatternLab would first look in 99-foo.json
(as it already does), then 04-pages.json
(this is the new feature) and finally data.json
.
The same technique should also work for listitems. I.e. 99-foo.listitems.json
overrides 04-pages.listitems.json
, which in turn overrides listitems.json
.
Note: Some discussion occurred in patternlab-node issue #599 before it was moved here.
/cc @pattern-lab/voting-members