-
Notifications
You must be signed in to change notification settings - Fork 3
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
Seeking Input: Pattern "Collection" Metadata/Overrides #31
Comments
It's hard to say because I can't think of a real-world (not hypothetical) scenario where I'd want to do this. Usually I base my recommendations on how to accomplish something based on my experience trying to do it, but in this case I've got nothing. 😕 |
@tylersticka But thanks for your input! That's valuable, too. Maybe this really is a feature to worry about later. |
Another example, if it helps: pattern collections as of now will always be given a
Perhaps that's OK, but I thought I'd raise it. |
Hmm, okay. In that case, I think I'd lean more toward the I dunno. Maybe it makes more sense to keep the formatting consistent with the patterns themselves. Or maybe that's more confusing because they differ. Yeah, I'm talking myself out of every opinion I start to have. I'm gonna bow out of this one. 😅 |
I'm fine with the |
FYIses, before I forget...I'm leaning toward using the |
I'd rather there be an Also, if we do move pattern order out of the filename and into frontmatter, I think we should do the same for hidden patterns... using a frontmatter property instead of a leading underscore. Basically, I'm fine with ordering via filename or via frontmatter properties, as long as we're consistent. |
The reason I'd argue for using a Would like to get other opinions... @erikjung @mrgerardorodriguez @saralohr @nicolemors ?
I think this can be done! Though again I'd almost argue for the |
I respectfully disagree with this reasoning, for a few reasons:
I'm happy to be overruled if I'm in the minority. It just seems to me that preferences associated with individual patterns will be more portable if they're stored with the patterns themselves.
I disagree, for the same reasons as above. 😬
Not sure about data, but yes... hide from listings, but still available as partials. More info: #17 |
On collection ordering, I prefer the discussed solutions in this order:
If we use a single file, how would the order be annotated? As an array of IDs? I also should mention that consistency is more important to me than the chosen solution. I've never felt that the arbitrary ordering of things like patterns (which should have a pretty flat hierarchy IMO) is that important. |
I disagree. In our last big ol' billable project, the client had some pretty specific challenges directly related to patterns being ordered in a counter-intuitive (though alphabetical!) way. While that issue would have been partially alleviated by more granular pattern collections, I still think being able to prioritize patterns within a collection is really important. |
@lyzadanger @tylersticka Something to consider: Could we handle ordering by specifying "dependencies" in the pattern front matter? For example: ---
# input-group.hbs
dependencies: [input, arrange]
--- ---
# forms.hbs
dependencies: [input-group]
--- ...and using their dependency graph to determine the ordering? Which, in the above example would be:
|
I like the idea of trying to keep as much collection-related metadata out of the individual pattern files. I've given one argument above (it seems easier to edit one file instead of each pattern in a collection), but this doesn't seem to be the case for Tyler. I'd also add the technical argument that adding more and more "magical" properties to individual pattern file front matter introduces more likelihood for namespace collisions and makes traversal and object construction more challenging. I like the technical cleanliness of having all collection metadata in one place. One of the things that has been hardest to understand and untangle in the origin code source is the distinction between patterns and collections. I'd like not to run into those pitfalls again. For the most part I've been acting the part of the "customer" to the design folks on the requirements for this project, but I have a slightly-stronger-than-average opinion on this one—I'd prefer to keep the collection metadata with the collection. I want to be clear that ordering will be supported! The discussion here is just about implementation/methodology for that. I'm not abandoning the feature.
I feel like I need to do a Phd to understand that 😄 |
var tree = {a: [], b: ['c', 'd'], c: ['d'], d: ['a']};
var resolved = DepResolver(tree);
console.log(resolved);//['a','d','c','b' ] https://www.npmjs.com/package/dependency-tree-resolver#examples FWIW, this way we'd actually be specifying data that does relate to each pattern. Just a 💭 |
I see ups and downs for both ordering via front matter and ordering via yaml, but don't have a strong preference either way (I may after using it for a while, but alas, foresight often doesn't serve as well as hindsight).
Does this apply to ordering of immediate children of the patterns directory, ie ordering of collections and freestanding patterns, as well? |
If I'm understanding the question correctly...any pattern files that are immediate children to the top-level |
To be a touch pedantic, front matter is also YAML. The drizzle builder is already happily capable of parsing JSON as well as YAML, so there's no reason the |
Same. It's an interesting idea, @erikjung, but it feels to me like over-engineering... an opinion reinforced by your follow-up example. 😬
Maybe we're misunderstanding what I'm after with pattern ordering, which may not be apparent based on our previous, filename-based solutions. Let's take a hypothetical collection of button patterns:
For the most part, it's fine that these are ordered alphabetically. But maybe I want to make extra sure that If I had an
The filename prefixes were always just a hack to get these sorts of optional, Flexbox-style order shifts. I won't argue that storing |
I don't have much to add to the conversation, but @tylersticka's last message cleared up (for me) what this conversation is trying to solve/manage.
FWIW, I used this hack. 😅 |
@tylersticka Your version:
Would be a somewhat challenging algorithm to write. |
From the looks of it, defining dependencies is what we're already attempting to do with
Does this not reflect a sequence of dependencies? Anyway, my two cents. I'll be fine with whatever we decide on. |
I realized I'm not doing a great service to anyone by splitting my attention between this and my book. Everyone always loses when I multitask too much :). I've been brainstorming a bit over lunch, but I'll return to this tomorrow with more focused attention. |
It does, but that's not why I'm specifying order. I want the pattern higher up on the page so newcomers will have an easier time reading the section. In this case, saying "I want that because these patterns are dependent on the other" is accurate, but makes the feature less understandable.
Here's a small pen I whipped up to possibly help clarify my ideas: http://codepen.io/tylersticka/pen/BKdOYo?editors=0012 |
I've always understood (correctly or otherwise) the manual ordering of our pattern library as something we do to illustrate a linear progression from the "basics" to more complex, less foundational patterns that depend on those basics. Example: typography before components. There are probably outliers, but I feel like most of the time we tend to order things in a way that coincidentally reflects their perceived dependencies (opposed to literal: CSS source order). That's the only reason I thought I'd toss in the idea of using "dependency" annotations to achieve sorting. I think the example of using a relative |
Someone should start counting the agendas in this thread 😆 I'm not innocent, either! |
@erikjung That proof of concept is helpful to see, but it also confirms my assumption that this would be more difficult to use day to day. It's just way more verbose to achieve the same thing, y'know? Instead of specifying a single integer value in the three patterns that should be ordered differently, you're specifying arrays of one or more keys in all but one of the patterns. (That tonic output is sexy, though!)
I'm not sure what this means. 😕 I just want the thing I use every day to be easy to use. 🦄 |
I was just joking. It's fun to see so many different opinions and approaches! Agenda was a dumb word to use. Ideas may have been better. |
Here's the direction this has gone...I feel like this is a solid solution; hope it doesn't infuriate anyone too badly... One can add an optional file to any pattern-containing directory. That file is called
If an Hidden patterns are parsed and available for other parts of the build, but are not rendered on the pattern collection page. An example
|
I guess I've been overruled. Maybe in the future I'll write a PR to make stuff work the way I'd like it to. I stand by my previous arguments. |
Maybe we could try to find a compromise? Right now I'm trying to get this done, and implementing it on a per-pattern basis would be a more challenging algorithm to write, and would cause more potential for namespace collisions. I can see if I can find a way to do it the Tyler way this week. |
I think this can be done now. |
Hullo!
The way that things are shaping up,
drizzle
will continue to treatpage
frontmatter similarly tofabricator
—e.g. you can override the defaulttemplate
by using a frontmatter property. This is straightforward because there is a one-to-one relationship ofpage
source files tohtml
output files.With
patterns
, it's a different relationship. Any subdirectory of thepatterns
directory with any immediate-children pattern files is considered acollection
and an HTML page will be generated for that collection (patterns
subdirectories with no pattern files in them—e.g. a directory holding only more directories—will not cause a page to be generated).Thus, for pattern collections, there is no current single point of metadata if one wanted to accomplish something like overriding the default template used to generate pattern-collection pages. There may be also other metadata we wish to associate with a collection of patterns in the future.
One plausible way to manage this would be to have an optional file in a given pattern directory that could contain this metadata. Naming options for this file include:
_index.md
collection.json
orcollection.yaml
...or really any number of things.
On the one hand, this feels a tad like overengineering as the only immediate application I can think of is overriding the default pattern-collection page template. But I feel like not thinking this through could leave us in the lurch later.
Any thoughts or ideas on this?
/cc @mrgerardorodriguez @erikjung @tylersticka @saralohr @nicolemors
The text was updated successfully, but these errors were encountered: