Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 4dd2fb9

Browse files
author
blaryjp
authored
Merge pull request #11 from ovh-ux/feat/pl
Feat/pl
2 parents 95127e6 + 44bec87 commit 4dd2fb9

File tree

7 files changed

+401
-0
lines changed

7 files changed

+401
-0
lines changed

docs/features/drupal-drush.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Launch a Drupal command.
77

88
## Config
99

10+
- `config.drupal.themeFile` - The filename of your YOUR_THEME.info.yml (required for PatternLab tasks)
1011
- `config.drupal.dir` - The root directory for Drush
1112
- `config.drupal.command` - The drush command to execute
1213

docs/features/pattern-lab.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
---

docs/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This stack core is to be included in your main project and sets up many Gulp tas
1010

1111
- SCSS => CSS compiling with LibSass, PostCSS, linting, CSScomb(x), and SourceMaps
1212
- JS compiling via Babel, linting and aggregation
13+
- Pattern Lab Twig compiling & BrowserSync live reload and style injection
1314
- WebPack module bundling
1415
- SVG => Font Icons compiling with support for adding mixins and classes to SCSS along with a demo page
1516
- Drupal file watching to trigger Drush cache clears
@@ -40,6 +41,16 @@ $ vi gulpfile.yml
4041
# <set the config that you want, and save it>
4142
```
4243

44+
### IDE/Text Editor Setup
45+
46+
- Install an EditorConfig plugin
47+
- Ignore the indexing of these directories:
48+
- `node_modules/`
49+
- `bower_components/`
50+
- `dest/`
51+
- `pattern-lab/public/`
52+
- `pattern-lab/vendor/`
53+
4354

4455
## Usage
4556

docs/usage.md

+26
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ js:
1313
You can find all the available options and defaults settings inside the `gulpfile.default.yml` file.
1414

1515

16+
## Folders structure
17+
18+
- source/ (only for Pattern Lab)
19+
- _annotations/ ([annotations](http://patternlab.io/docs/pattern-adding-annotations.html) for Patterns)
20+
- _data/ (Global JSON data files available to all Patterns, can add multiple)
21+
- _patterns/ (Twig, Scss, and JS all in here)
22+
- 00-base/ (Twig Namespace: `@base`)
23+
- Contains what all that follows needs: variables, mixins, and grid layouts for examples
24+
- 01-atoms/ (Twig Namespace: `@atoms`)
25+
- 02-molecules (Twig Namespace: `@molecules`)
26+
- 03-organisms (Twig Namespace: `@organisms`)
27+
- 04-templates (Twig Namespace: `@templates`)
28+
- 05-pages (Twig Namespace: `@pages`)
29+
- _meta/ (contains the header and footer Twig templates for PL; add any `<link>` or `<script>` tags here; don't edit in between the `<!-- inject -->` tags though; it'll get overwritten)
30+
- pattern-lab/ (only for Pattern Lab)
31+
- config/config.yml (Pattern Lab configuration)
32+
- public/ (Where Pattern Lab compiles too, it's just static HTML)
33+
- composer.json (run `composer update` next to this to update dependencies)
34+
- scss/ - Sass files that aren't really tied to a component, so not in the above location.
35+
- js/ - all js files here and transpiled by Babel and combined into a single `dest/script.js` file.
36+
- images/icons/src/ - all SVGs here are combined into font icons and have classes and Sass mixins made for each based on file name. See `atoms/images/icons` in Pattern Lab.
37+
- dest/ - Many compiled assets end up in here like CSS, JS, Font Icons, and any doc systems like [SassDoc](http://sassdoc.com).
38+
- templates/ - Drupal twig templates. These often will `include`, `embed`, or `extend` the Twig templates found in Pattern Lab like this: `{% include "@molecules/branding/branding.twig" with { url: path('<front>') } %}`. We keep the components in Pattern Lab "pure" and ignorant of Drupal's data model and use these templates to map the data between the two. Think of these as the Presenter templates in the [Model View Presenter](https://en.wikipedia.org/wiki/Model–view–presenter) approach. Also, Drupal Twig templates that have nothing to do with Pattern Lab go here.
39+
- gulpconfig.yml - Configuration for all the gulp tasks, a ton can be controlled here.
40+
41+
1642
## Commands
1743

1844
- `gulp` - Run all compile tasks, and watch for changes

gulpfile.default.yml

+63
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,67 @@ icons:
8686
- eot
8787
- woff
8888
- svg
89+
patternLab:
90+
enabled: false
91+
configFile: pattern-lab/config/config.yml
92+
watchedExtensions:
93+
- twig
94+
- json
95+
- yaml
96+
- yml
97+
- md
98+
- jpg
99+
- jpeg
100+
- png
101+
extraWatches: []
102+
injectFiles: []
103+
bowerBasePath: ./
104+
twigNamespaces:
105+
addToDrupalThemeFile: true
106+
sets:
107+
- namespace: base
108+
paths:
109+
- 'source/_patterns/00-base'
110+
- namespace: atoms
111+
paths:
112+
- 'source/_patterns/01-atoms'
113+
- namespace: molecules
114+
paths:
115+
- 'source/_patterns/02-molecules'
116+
- namespace: organisms
117+
paths:
118+
- 'source/_patterns/03-organisms'
119+
- namespace: templates
120+
paths:
121+
- 'source/_patterns/04-templates'
122+
- namespace: pages
123+
paths:
124+
- 'source/_patterns/05-pages'
125+
scssToJson: []
126+
# - src: 'source/_patterns/00-base/05-colors/_color-vars.scss'
127+
# dest: 'source/_patterns/00-base/05-colors/colors.json'
128+
# lineStartsWith: '$c-'
129+
# allowVarValues: false
130+
# - src: 'source/_patterns/00-base/15-typography/fonts/_fonts.scss'
131+
# dest: 'source/_patterns/00-base/15-typography/fonts/font-sizes.json'
132+
# lineStartsWith: '$fs--'
133+
# allowVarValues: false
134+
# - src: 'source/_patterns/00-base/15-typography/fonts/_fonts.scss'
135+
# dest: 'source/_patterns/00-base/15-typography/fonts/font-families.json'
136+
# lineStartsWith: '$ff--'
137+
# allowVarValues: false
138+
# - src: 'source/_patterns/00-base/breakpoints/_breakpoints.scss'
139+
# dest: 'source/_patterns/00-base/breakpoints/breakpoints.json'
140+
# lineStartsWith: '$bp--'
141+
# allowVarValues: false
142+
# - src: 'source/_patterns/00-base/10-spacing/_spacing.scss'
143+
# dest: 'source/_patterns/00-base/10-spacing/spacing.json'
144+
# lineStartsWith: '$spacing--'
145+
# allowVarValues: false
146+
# - src: 'source/_patterns/00-base/animations/01-transitions/_transitions.scss'
147+
# dest: 'source/_patterns/00-base/animations/01-transitions/transitions.json'
148+
# lineStartsWith: '$trans-'
149+
# allowVarValues: true
89150
browserSync:
90151
enabled: false
91152
port: 3050
@@ -98,8 +159,10 @@ browserSync:
98159
tunnel: false
99160
reloadDelay: 50
100161
reloadDebounce: 750
162+
rewriteRules: []
101163
drupal:
102164
enabled: false
165+
themeFile: patternlab.info.yml
103166
watch:
104167
- template.php
105168
- templates/**

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ module.exports = (gulp, userConfig, tasks) => {
2727
require('./lib/css')(gulp, config, tasks);
2828
}
2929

30+
if (config.patternLab.enabled) {
31+
require('./lib/pattern-lab--php-twig')(gulp, config, tasks);
32+
}
33+
3034
if (config.drupal.enabled) {
3135
require('./lib/drupal')(gulp, config, tasks);
3236
}

0 commit comments

Comments
 (0)