A pattern library generator.
This repo is a documentation, testing, and development platform for your project's front-end assets. These assets are typically stored in a separate repo, and symlinked to this repo so they can be 'dogfooded'.
There are two distinct sets of assets used within this pattern library:
- those used explicitly for rendering this pattern library, and its layout.
- those used to render examples of each pattern in its intended way. These examples are sandboxed in
<iframe>
s.
- Node.js (v16.10+)
- NPM (v8.1+)
Make sure you have the dependencies installed before proceeding.
npm i
The dev server can be started uisng npm start
.
- Add a
.yml
file tosrc/_data/patterns
, using thepattern_model.yml
as a reference. - Assign the new pattern to a group, by setting the
group_id
to an existingsrc/_data/pattern_group/*
. (If it's a new pattern group, see below.) - Add the details to your new pattern:
- Give it a hierarchical id:
[group]-[identifier]
, e.g.button-primary
- Give it a memorable name, preferably in a hierarchical manner too, e.g.
Button Primary
- Describe what makes this pattern unique, or why you would use this pattern over others.
- In the
example
section, supply somecode
that is free of modifiers / variants, etc. - Write any implementation notes or reminders when using this pattern
- Associate this pattern with its corresponding asset source code, e.g. JS, SCSS, Images, etc.
Your new pattern should be available at the following URL:
/patterns/[GROUP_ID]/[ID]/
, e.g. /patterns/buttons/button-primary/
- assets – the front-end artefacts such as CSS, JavaScript, images, icons, and fonts. These are typically found in a separate repo, that the pattern library consumes and uses.
- pattern – A distinct block of HTML and its corresponding assets. Each pattern typically uses a
class
attribute. - pattern group – A collection of similar patterns, typically grouped by function. e.g. buttons, or lists, or…
- example – The pattern library renders a pattern's example in an
<iframe>
. Each example uses the project's assets.
npm i
– Install dependenciesnpm start
– Run pttrnr in dev modenpm run build
– Static build to thedist
folder