Skip to content

Re-architect how ui's are built #811

@bmuenzenmeyer

Description

@bmuenzenmeyer

As a user, I want to be able to generate multple UIs from a single pattern tree.

We will basically support a workflow first described in @bradfrost's article, The Workshop and the Storefront.

Pattern Lab Node needs to change to accept N number of UIs to build. This issue will attempt to capture what is needed for that to be successful.

I think an acceptable way to think of how this would work is to start at the configuration point and move forward from there.

Proposed Solution

patternlab-config.json

 "uikits": [
 {
   "name": "@pattern-lab/uikit-workshop",
   "outputDir": "workshop",
   "enabled": true,
   "excludedPatternStates": [],
   "excludedTags": []
 },
 {
   "name": "@pattern-lab/uikit-storefront",
   "outputDir": "storefront",
   "enabled": true,
   "excludedPatternStates": ["inprogress", "inreview"],
   "excludedTags": []
 },
]  

High-Level Pseudocode build()

  1. Build source patterns
  2. require() all uikits by name
  3. For each uikit in uikits...
    1. Build frontend...
      1. bail if not enabled via config or maybe a runtime flag
      2. exclude patterns as indicated by state and tag exclusions in the config
      3. output to outputDir as root - join to paths.public
    2. Copy assets into frontend

From what I can think about it right now, uikit build could be parallelized. Not sure if it's worth doing that, but may be neat!

Questions

  1. Would all uikits share the same _meta files? That would certainly be easiest, but may be limiting.

Evaluation

index.js

  • headPatternPromise and footPatternPromise decomposed but only used within ui_builder (a good thing from a refactoring standpoint)

patternlab.js

  • The assigment of templates hanging off of patternlabFiles assumes a single uikit

    • header
    • footer
    • patternSection
    • patternSectionSubType
  • writePatternFiles() assumes a single uikit

ui_builder.js

  • assumes a single uikit
  • needs to filter out states and tags not wanted to output

exportData.js

  • assumes a single uikit
  • might be a good extension point for custom logic within a uikit. use events?

copier.js

  • assumes a single uikit

pattern_graph.js

  • exportToDot() assumes a single uikit

✔️ pattern_exporter.js

  • assumes a single location - but I think that is okay

MISC

  1. We need to well-document part of the UI-build process we have previously let slide if we want teams to adopt this approach (or even if we want to easily create uikit-storefront

    • the data schema available to a uikit at render time
    • the expected templates a uikit provides
    • the file locations Pattern Lab will output after build
  2. We need to update Ecosystem documentation to refer to uikits and the ability to have N of them

  3. It's probably revisting in meta patterns are truly optional. We try to fall back to general header and footer but I need to test if this works in practice.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions