|
| 1 | +Build and run a Pattern Lab project. |
| 2 | + |
| 3 | +## Commands |
| 4 | + |
| 5 | +- `gulp pl` - Build Pattern Lab files |
| 6 | +- `gulp watch:pl` - Watch files and launch `gulp pl` |
| 7 | + |
| 8 | +## Config |
| 9 | + |
| 10 | +@todo |
| 11 | + |
| 12 | +## Drupal 8 Integration |
| 13 | + |
| 14 | +From your Drupal Twig templates in `templates/` you can `{% include %}`, `{% extends %}`, and `{% embed %}` your Pattern Lab Twig template files. Each of the top level folders has a Twig Namespace like `@organisms` and then you append the path down to the file like below. |
| 15 | + |
| 16 | +```twig |
| 17 | +{% include "@organisms/path/to/file.twig" with { |
| 18 | + title: label, |
| 19 | + largeCTA: true |
| 20 | +} %} |
| 21 | +``` |
| 22 | + |
| 23 | +For a demonstration in a sample codebase of how exactly to integrate templates, see the [`drupal-lab`](https://github.com/phase2/drupal-lab) repo; in particular note how both a [node teaser template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/templates/content/node--article--teaser.html.twig) and a [views field template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/templates/views/views-view-fields--newspage--page.html.twig) in the Drupal `templates/` folder can embed the [card template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/pattern-lab/source/_patterns/02-molecules/cards/card.twig) from Pattern Lab while formatting the data. |
| 24 | + |
| 25 | + |
| 26 | +## Additional features |
| 27 | + |
| 28 | +### Asset Injection |
| 29 | + |
| 30 | +If you use `--save` or `--save-dev` on `bower install` it will inject them in Pattern Lab |
| 31 | + |
| 32 | +It adds it to these locations in Pattern Lab: |
| 33 | + |
| 34 | +- `source/_meta/_00-head.twig` |
| 35 | +- `source/_meta/_01-foot.twig` |
| 36 | + |
| 37 | +### Dummy data using `Faker` |
| 38 | + |
| 39 | +[`Faker`](https://github.com/fzaninotto/Faker) generates fake data and the [Faker plugin for Pattern Lab](https://github.com/pattern-lab/plugin-php-faker) is used here. This generates *different* fake content for each compile, and allows [translated content](https://github.com/pattern-lab/plugin-php-faker#locales) as well. |
| 40 | + |
| 41 | +**Faker only works in the global data files** found in `source/_data/` currently until [this bug](https://github.com/pattern-lab/plugin-php-faker/issues/2) is fixed. |
| 42 | + |
| 43 | +Use it like this in `source/_data/data.json`: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "description": "Faker.paragraph", |
| 48 | + "text": "Faker.words(3, true)", |
| 49 | + "byline": "Faker.sentence", |
| 50 | + "intro": "Faker.sentences(2, true)" |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +The formatters (things like `.paragraph`, `.words`, etc) can accept options, when you see `Faker.words(3, true)` that means give me 3 random words and I'd like them as a string and not an array of strings. All the [formatters and their options are documented here](https://github.com/fzaninotto/Faker#formatters) - there's tons: numbers, address, names, dates, and more. |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## Pattern Lab documentation |
| 59 | + |
| 60 | +### Pattern Lab Terms |
| 61 | + |
| 62 | +- **Atoms** are basic tags, such as form labels, inputs or buttons. They also include more abstract elements like color palettes, fonts, and animations. |
| 63 | +- **Molecules** are groups of elements that function together as a unit. For example, a form label, search input, and button atom can combine them together to form a search form molecule. |
| 64 | +- **Organisms** can consist of similar and/or disparate molecule types. For example, a masthead organism might consist of a logo, navigation, and search form, while a “product grid” organism might consist of the same product info molecule repeated over and over. |
| 65 | +- **Templates** are comprised mostly of organisms combined together to form page-level objects. Templates mostly focus on content structure (such as character length, image size, etc) rather than the actual content. |
| 66 | +- **Pages** are specific instances of templates and swap out placeholder content with real representative content. |
| 67 | + |
| 68 | +[More info](http://patternlab.io/about.html) |
| 69 | + |
| 70 | +#### Advanced Pattern Lab Concepts |
| 71 | + |
| 72 | +- [Including Patterns in Patterns](http://patternlab.io/docs/pattern-including.html) |
| 73 | +- [Introduction to JSON & Mustache Variables](http://patternlab.io/docs/data-json-mustache.html) |
| 74 | + - [Creating Pattern-specific Values](http://patternlab.io/docs/data-pattern-specific.html) |
| 75 | + - [Creating Lists with `listItems` Variable](http://patternlab.io/docs/data-listitems.html) |
| 76 | +- [Linking to Patterns](http://patternlab.io/docs/data-link-variable.html) |
| 77 | +- [Adding Annotations](http://patternlab.io/docs/pattern-adding-annotations.html) |
| 78 | +- [Pattern Lab's Special Query String Variables](http://patternlab.io/docs/pattern-linking.html) |
| 79 | +- [Using styleModifiers](http://patternlab.io/docs/pattern-stylemodifier.html) |
| 80 | +- [Using Pattern States](http://patternlab.io/docs/pattern-states.html) |
| 81 | +- [Using Pattern Parameters](http://patternlab.io/docs/pattern-parameters.html) |
| 82 | +- [Keyboard Shortcuts](http://patternlab.io/docs/advanced-keyboard-shortcuts.html) |
| 83 | +- [Editing the config.ini Options](http://patternlab.io/docs/advanced-config-options.html) |
| 84 | + |
| 85 | +### More Info |
| 86 | + |
| 87 | +#### About Pattern Lab |
| 88 | + |
| 89 | +- [Pattern Lab Website](http://patternlab.io/) |
| 90 | +- [About Pattern Lab](http://patternlab.io/about.html) |
| 91 | +- [Documentation](http://patternlab.io/docs/index.html) |
| 92 | +- [Demo](http://demo.patternlab.io/) |
| 93 | + |
| 94 | +--- |
0 commit comments