pattern-lab / patternlab-php-core

This repository provides the core functionality for Pattern Lab. It is meant to be used from within an Edition with a PatternEngine and StarterKit.
http://patternlab.io/
MIT License
43 stars 62 forks source link

Reorder Patterns, Folders in Pattern Lab Nav Based On `Order` Config #149

Open sghoweri opened 6 years ago

sghoweri commented 6 years ago

Specifically, allow Pattern Lab users to manually adjust the visual ordering of any navigation items in the Pattern Lab main menu based on the configurable order property that's set in a pattern's config file (ie. a corresponding pattern markdown file with the order key set.) -- without needing to make any physical filename / folder name changes or prefixes.

Ex. given a fonts.twig file, the default 0 zero order value could get overwritten (pushed up or down the list) in the cooresponding fonts.md file:

---
order: 4
---

This PR also updates all top level Pattern Types, Pattern SubTypes, Patterns, & Pattern Items top inherit a default order value set in case a manually-entered value isn't set.

In short, this PR tries to take a crack at attempting to address the bulk of the use cases and details mentioned in #138 without having to go too far off the deep end for this one. Oh - and this also manages to get top level Pattern Types to be configurable now via markdown files as well! =)

Author's sidenote(s):

  1. This PR covers the across the board data updates needed to let us set an order property (with an inherited default), updates to the Documentation rule so top level Pattern Types can be sorted via markdown files, and the sorting of Pattern Types, Pattern SubTypes, Pattern Items, and Pattern SubTypeItems in the top level Pattern Lab dropdown navigation but this PR does NOT unfortunately cover reordering the styleguide / viewall ordering as well (just yet). Way too much work already had to go into this so I figure to get this up here first so we can iterate vs having this get help up too much.

  2. I had originally tried (and failed) to reorder everything at the central pattern data $store however I inevitably ran into major issues with getting things to render correctly and consistently (if at all) so this implementation tackles reordering "downstream" when the final data structure is getting ready to be exported (ie. exported as the top level navigation). This might be something to take another look into down the road, or by someone who speaks PHP as a first language...

Example test w/ Order Output for Debugging

Configuring the Organisms top level Pattern Type order to -1, Buttons and Images Pattern SubTypes to 2 and 10, and nested Animations and Fonts patterns to -1 and 4 respectfully. Huzzah!

pattern_lab_-_all

CC @bradfrost @aleksip @christophersmith262

bradfrost commented 6 years ago

Awesome work, @sghoweri!