Skip to content
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

Allow data.json inheritance at pattern group level #599

Open
tburny opened this issue Jan 18, 2017 · 16 comments
Open

Allow data.json inheritance at pattern group level #599

tburny opened this issue Jan 18, 2017 · 16 comments
Labels
data / parsing 🎰 pinned 📌 Don't let stalebot clean this up spec 🔬

Comments

@tburny
Copy link

tburny commented Jan 18, 2017

I am using Pattern Lab Node v2.7.1 on Linux, with Node v4.6.2, using the Grunt Edition.

Expected Behavior

Especially for patterns in the pages category it should be possible to override the global data.json with category-specific values. Pattern data can still override the data, so the chain should be _data/data.json_source/patterns/pages/data.json_source/patterns/pages/my-page.json where → means overridden by.
A use case is that there might be homepages with different brands. For instance there are (München Ticket) (http://muenchenticket.de) and Sueddeutsche Tickets (SZ) which share the same layout, but brands should be interchangable in the PL based on the data.json.
The advantage is that for SZ pages the JSON doesn't have to be defined for each and every SZ page.

Actual Behavior

Placing a data.json in a subfolder of patterns has no effect (unless there is a pattern named data.html of course).

@james-nash
Copy link
Contributor

As you point out, there could be an (admittedly unlikely) naming clash if someone happens to have a pattern called data.

To avoid that, how about having the category-specific JSON file one level up like this:

|
+- 00-atoms/
|     |
|     +- 99-foo.mustache  # Usual stuff...
|     +- 99-foo.json
|     +- 99-foo.listitems.json
|     +- 99-foo.md
|
+- 00-atoms.json  # NEW data that can override root data.json for every pattern inside 00-atoms/
+- 00-atoms.listitems.json # NEW listitems equivalent of the above

This approach sort of mimics how per-pattern JSON files live next to the Mustache files they relate to, in that it puts the per-category JSON files next to the folder they relate to.

@bmuenzenmeyer
Copy link
Member

To me, this is the sort of thing that, if we were to support it, we should build it correctly across platforms, or at least get it voted across both.

@tburny
Copy link
Author

tburny commented Jan 18, 2017

You mean for both PHP and Node?

@bmuenzenmeyer
Copy link
Member

correct. I understand the utility, but wish to adhere to the conventions Dave and I put in place for making significant changes to the core experience.

https://github.com/pattern-lab/the-spec is the right place to debate this, in my opinion

@tburny
Copy link
Author

tburny commented Jan 18, 2017

@james-nash Maybe it would be a good idea to simply mimic the structure of _source/patterns subfolders in _data, e.g. _data/00-atoms/data.json (plus listitems). This way we still can have a _source/patterns/00-atoms/data.html pattern with no clashes.

@bmuenzenmeyer
Copy link
Member

This approach sort of mimics how per-pattern JSON files live next to the Mustache files they relate to, in that it puts the per-category JSON files next to the folder they relate to.

worth noting, this is how markdown works too for sub-categories

@james-nash
Copy link
Contributor

Seems sensible.

FWIW, an additional scenario where this is useful is the pages category, if you're (strictly?) following Atomic Design. For atoms, molecules, organisms and templates you might want to use lorem ipsum text and wireframe-like boxes as image placeholders - that's easily done via the root data.json and listitems.json. However, on pages you want to substitute those for example text and images. Since several things are often shared across several pages, having to copy-paste them into many individual patternName.json files is a chore.

This would be a more elegant solution IMHO since you'd override what you need to once, at the category level.

@james-nash
Copy link
Contributor

@bmuenzenmeyer @tburny Happy to raise an issue for this over on the spec project, unless one of you is already doing that

@tburny
Copy link
Author

tburny commented Jan 18, 2017

Go for it 👍

@james-nash
Copy link
Contributor

@bmuenzenmeyer Am I allowed to? It looks like all spec issues so far came from Dave Olsen or yourself. Don't want to be treading on anyone's toes :-)

@bmuenzenmeyer
Copy link
Member

others are encouraged. only him or I may call a vote on the topic once we've figured out the details.
you will see the format of other spec enhancements

@james-nash
Copy link
Contributor

Ok cool. Doing it now.

@james-nash
Copy link
Contributor

@bmuenzenmeyer Done: pattern-lab/the-spec#31

I wasn't sure what to put for the timeline and tagging stuff at the bottom, so I've commented those bits out for now. Feel free to edit as you see fit (or tell me what to put in there).

gergan pushed a commit to gergan/patternlab-node that referenced this issue Aug 11, 2017
@stale
Copy link

stale bot commented Oct 2, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the needs response label Oct 2, 2017
@bmuenzenmeyer bmuenzenmeyer added the hacktoberfest 🌾 https://hacktoberfest.digitalocean.com label Oct 2, 2017
@stale stale bot removed the needs response label Oct 2, 2017
@bmuenzenmeyer bmuenzenmeyer removed the hacktoberfest 🌾 https://hacktoberfest.digitalocean.com label Nov 10, 2017
@stale
Copy link

stale bot commented Jan 9, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the needs response label Jan 9, 2018
@stale stale bot closed this as completed Jan 16, 2018
@bmuenzenmeyer bmuenzenmeyer added the pinned 📌 Don't let stalebot clean this up label Jan 16, 2018
@bmuenzenmeyer bmuenzenmeyer reopened this Jan 16, 2018
@stale
Copy link

stale bot commented Mar 17, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data / parsing 🎰 pinned 📌 Don't let stalebot clean this up spec 🔬
Projects
None yet
Development

No branches or pull requests

3 participants