-
Notifications
You must be signed in to change notification settings - Fork 3
Discussion: Add support for category-level data overrides #31
Comments
Keeping the data under |
@james-nash Thanks for this suggestion. Just so I can wrap my head around this, you're trying to accomplish theming that can (maybe even radically) adjust the skin of the UI? How I've done this in the past is to create pseudo-patterns for theme-specific pages and components. So for instance, I might have a file called
This would add the theme class to to the
I'm less privy to the technical workings of data inheritance and all that, but I just thought I'd chime in with how I accomplish theming in my own work. |
Thanks for your thoughts @bradfrost - it's always appreciated to see how you've tackled use cases in PL. If I understand @james-nash correctly, however, we would have, say, some navigation component:
which is included in:
with an accompanying json file
Of course something like
and expect its data to carry over to the pages data. Users wanting So, I understand the merits of the use case. I don't think strict data-inheritence as people are often requesting resolves it either (above reason). Directory-level json may in fact have a place, then. I don't think this directory json belongs inside I like the idea of putting this data alongside the directory, similar to pattern group markdown.
The hierarchy of data would then be something like:
Thoughts? |
(Essentially, there is contention between templates and pages, because one craves sample data, and the other real data, but they both use the same patterns.) |
@bradfrost Thanks for your comments. As @bmuenzenmeyer says, it's always useful to hear how others tackle things. I think the use-case you outlined is what prompted @tburny to request this feature in the first place. FWIW, my own use-case is slightly different. I think Brian's already covered it, but just for the avoidance of doubt: Let's say I've got a root
I'd use that throughout my atoms, molecules, organisms and templates. However, for my pages, I'd like to substitute realistic data. On my projects, I've ended up with many pages and a lot of the data used for them is identical. For instance, let's say the Right now, I need to repeat that individually for every page I have. However, if I could do this once for the whole pages folder (as per this proposal), it would save me a lot of copy-pasting and also make future updates/corrections that much easier. I could do something like this once to replace the data used across all my pages:
This pain (and potential gain) is even more pronounced when working with For example: A recent project I worked on was for a news site, so most pages featured various lists of links to articles. We were using listitems to provide individual images, titles and blurbs for those link lists. When inserting realistic values for our pages, we had to duplicate those many times over. |
Actually this looks a bit similar to #28. To wrap things up, we have to distinct use cases:
NoteActually it might be good to have this feature for sub-types, too. The real benefit comes in with my original request and what @james-nash said: |
@bradfrost or @dmolsen do you have any additional input? |
I'm still a bit confused as to the need for category-specific data, but if it makes sense by all means don't let me hold everyone up. The above examples appear to be able to be achieved by creating global data values and pattern-specific values, which can even be chunked out into separate files. For instance, our
We defined the default data and then overwrote that data at the pattern and page levels.
For this instance, I'd say that "Home", "About", etc should be the default data if it's being used so many times and is applied to all pages. You can then override that default data at the pattern level. For instance, in
Essentially "Nav link 1" and "Nav link 2" are the overrides and not the default. Does that make sense? Again, it might still make sense to have category-level overrides as another tool in the toolkit, but I just wanted to point out that these scenarios seem to be solvable using existing functionality. Thanks! |
@bradfrost maybe this one final piece of info will help. You could call it an example of this "problem" in the wild. If you look at the you'll notice that these links are the "production links" as in the finished pages. This means that people constructing or view the navigation patterns (which are supposed to be real-content-agnostic® according to atomic design) will be seeing the real-content at the nav level and the template level, not placeholder data. (see http://demo.patternlab.io/?p=templates-homepage page and http://demo.patternlab.io/?p=organisms-header patterns) This is in opposition of a more organic workflow, where one would likely define nav items as junk like you defined above...
only to override with page-level data as it gets built out. Doing this, however, creates the problem this spec enhancement is attempting to solve, by not having to repeat the One solution to this problem is defining the global nav inside It's good to hear that you are open to the idea of having another tool. If this is brought to a vote, your vote is required unless Dave returns to a more active state. |
+1. Seems like an obvious change.
… On Feb 8, 2017, at 1:18 PM, Brian Muenzenmeyer ***@***.***> wrote:
@bradfrost maybe this one final piece of info will help.
If you look at the data.json we define for the demo: https://github.com/pattern-lab/starterkit-mustache-demo/blob/master/dist/_data/data.json#L54-L89
you'll notice that these links are the "production links" as in the finished pages.
This means that people constructing or view the navigation patterns (which are supposed to be real-content-agnostic® according to atomic design) will be seeing the real-content at the nav level and the template level, not placeholder data.
This is in opposition of a more organic workflow, where one would likely define nav items as junk like you defined above...
"navLinks" : [
{ "label" : "Nav link 1" },
{ "label" : "Nav link 2" }
]
only to override with page-level data as it gets built out. Doing this, however, creates the problem this spec enhancement is attempting to solve, by not having to repeat the navLinks override for each page we would create.
One solution to this problem is defining the global nav inside data.json as you and the demo suggest, but then we are back where we started.
It's good to hear that you are open to the idea of having another tool. If this is brought to a vote, your vote is required unless Dave returns to a more active state.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Cool. I will write up a final update and then prompt for a vote. |
Brad and Dave have already weighed in, but here's the more formal writeup. Use caseA user wants to include data on the pattern group level which will be applied to all patterns of that pattern group, so as to provide unique and DRY data System InputConsider the following files underneath
Pattern Lab processing would recognize and load these new files into the library for later output. One pattern group's data does not get inherited into other pattern groups' data. System OutputWhen processing any individual pattern, the hierarchy of data-inheritance is as follows, before being fed in for rendering:
ExtraThe timeline for this feature is determined by the availability of platform maintainers. Tagging This vote will close at 12PM on February 23 or once two voting members have voted yay or nay. /cc @pattern-lab/voting-members |
Vote: 👍 |
👍 |
Vote passes. Thanks for the input @james-nash and @tburny |
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 createpatternName.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:
The expectation would be that to find the data values used when rendering
99-foo.mustache
PatternLab would first look in99-foo.json
(as it already does), then04-pages.json
(this is the new feature) and finallydata.json
.The same technique should also work for listitems. I.e.
99-foo.listitems.json
overrides04-pages.listitems.json
, which in turn overrideslistitems.json
.Note: Some discussion occurred in patternlab-node issue #599 before it was moved here.
/cc @pattern-lab/voting-members
The text was updated successfully, but these errors were encountered: