Skip to content

Commit a1fd6a4

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request pattern-lab#83 from pattern-lab/plnode1-7
Plnode1 7
2 parents 8494969 + 2e8183a commit a1fd6a4

11 files changed

+104
-27
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

3+
PL-node-v0.1.7
4+
- ADD: pattern export
5+
- CHG: updated devDependencies
6+
- FIX: fixed a type in the README and config
7+
- THX: thanks @seanhussey for the pull request!
8+
39
PL-node-v0.1.6
410
- ADD: media queries found in css added to ish controls
511
- ADD: basic lineage support

Gruntfile.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports = function(grunt) {
3131
patternlab_grunt: {
3232
src: './builder/patternlab_grunt.js',
3333
dest: './builder/patternlab_grunt.js'
34+
},
35+
pattern_exporter: {
36+
src: './builder/pattern_exporter.js',
37+
dest: './builder/pattern_exporter.js'
3438
}
3539
},
3640
copy: {
@@ -83,7 +87,8 @@ module.exports = function(grunt) {
8387
files: {
8488
'./source/css/style.css': './source/css/style.scss',
8589
'./public/styleguide/css/static.css': './public/styleguide/css/static.scss',
86-
'./public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss'
90+
'./public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
91+
'./public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
8792
}
8893
}
8994
},

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The current selection is as follows. It reflects support versus patternlab-php.
4646
"m": true,
4747
"l": true,
4848
"full": true,
49-
"ranndom": true,
49+
"random": true,
5050
"disco": true,
5151
"hay": true,
5252
"mqs": false,
@@ -62,10 +62,6 @@ The current selection is as follows. It reflects support versus patternlab-php.
6262
"tools-docs": true
6363
}
6464
```
65-
66-
##### Verbose Mode
67-
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.
68-
6965
##### Pattern States
7066
You can set the state of a pattern by including it in `config.json` too. The out of the box styles are in progress (orange), in review (yellow), and complete (green).
7167
Pattern states should be lowercase and use hyphens where spaces are present.
@@ -77,6 +73,20 @@ Pattern states should be lowercase and use hyphens where spaces are present.
7773
}
7874
```
7975

76+
##### Pattern Export
77+
`config.json` also has two properties that work together to export completed patterns for use in a production environment. Provide an array of keys and an output directory. Pattern Lab doesn't ship with any pattern export keys, but the default directory is `"./pattern_exports/"` created inside the install directory.
78+
79+
```
80+
"patternExportKeys": ["molecules-primary-nav", "organisms-header", "organisms-header"],
81+
"patternExportDirectory": "./pattern_exports/"
82+
```
83+
84+
Coupled with exported css (much easier to extract with existing tools like [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy)), pattern export can help to maintain the relevancy of the design system by directly placing partials in a directory of your choosing.
85+
86+
87+
##### Verbose Mode
88+
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.
89+
8090
##### Server
8191
Running `grunt serve` will compile the patternlab front end and host it on <a href="http://localhost:9001">http://localhost:9001</a> by default. Page will reload on any saved source code change.
8292

builder/lineage_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.6 - 2014
2+
* patternlab-node - v0.1.7 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.6 - 2014
2+
* patternlab-node - v0.1.7 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.6 - 2014
2+
* patternlab-node - v0.1.7 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -23,6 +23,7 @@
2323
this.patternGroup = name.substring(name.indexOf('-') + 1, name.indexOf('-', 4) + 1 - name.indexOf('-') + 1);
2424
this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);
2525
this.flatPatternPath = subdir.replace(/\//g, '-');
26+
this.key = '';
2627
this.lineage = [];
2728
this.lineageIndex = [];
2829
this.lineageR = [];

builder/pattern_exporter.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* patternlab-node - v0.1.7 - 2015
3+
*
4+
* Brian Muenzenmeyer, and the web community.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8+
*
9+
*/
10+
11+
(function () {
12+
"use strict";
13+
14+
var fs = require('fs-extra'),
15+
path = require('path');
16+
17+
var pattern_exporter = function(){
18+
19+
function exportPatterns(patternlab){
20+
21+
//read the config export options
22+
var exportKeys = patternlab.config.patternExportKeys;
23+
24+
//find the chosen patterns to export
25+
for (var i = 0; i < exportKeys.length; i++){
26+
for (var j = 0; j < patternlab.patterns.length; j++){
27+
if(exportKeys[i] === patternlab.patterns[j].key){
28+
//write matches to the desired location
29+
fs.outputFileSync(patternlab.config.patternExportDirectory + patternlab.patterns[j].key + '.html', patternlab.patterns[j].patternPartial);
30+
}
31+
}
32+
}
33+
34+
35+
36+
}
37+
38+
return {
39+
export_patterns: function(patternlab){
40+
exportPatterns(patternlab);
41+
}
42+
};
43+
44+
};
45+
46+
module.exports = pattern_exporter;
47+
48+
}());

builder/patternlab.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.6 - 2014
2+
* patternlab-node - v0.1.7 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -17,6 +17,7 @@ var patternlab_engine = function(){
1717
pa = require('./pattern_assembler'),
1818
mh = require('./media_hunter'),
1919
lh = require('./lineage_hunter'),
20+
pe = require('./pattern_exporter')
2021
patternlab = {};
2122

2223
patternlab.package =fs.readJSONSync('./package.json');
@@ -89,6 +90,7 @@ var patternlab_engine = function(){
8990
currentPattern = new of.oPattern(flatPatternName, subdir, filename, {});
9091
currentPattern.patternName = patternName.substring(patternName.indexOf('-') + 1);
9192
currentPattern.data = null;
93+
currentPattern.key = currentPattern.patternGroup + '-' + currentPattern.patternName;
9294

9395
//see if this file has a state
9496
if(patternlab.config.patternStates[currentPattern.patternName]){
@@ -115,7 +117,6 @@ var patternlab_engine = function(){
115117
currentPattern.patternPartial = renderPattern(currentPattern.template, patternlab.data, patternlab.partials);
116118
}
117119

118-
//write the compiled template to the public patterns directory
119120
currentPattern.patternLink = currentPattern.name + '/' + currentPattern.name + '.html';;
120121

121122
//find pattern lineage
@@ -148,10 +149,14 @@ var patternlab_engine = function(){
148149
//add footer info before writing
149150
var patternFooter = renderPattern(patternlab.footer, pattern);
150151

152+
//write the compiled template to the public patterns directory
151153
fs.outputFileSync('./public/patterns/' + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter);
152154

153155
});
154156

157+
//export patterns if necessary
158+
var pattern_exporter = new pe();
159+
pattern_exporter.export_patterns(patternlab);
155160

156161
}
157162

builder/patternlab_grunt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.6 - 2014
2+
* patternlab-node - v0.1.7 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

config.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"m": true,
1414
"l": true,
1515
"full": true,
16-
"ranndom": true,
16+
"random": true,
1717
"disco": true,
1818
"hay": true,
1919
"mqs": true,
@@ -29,5 +29,7 @@
2929
"tools-docs": true
3030
},
3131
"patternStates": {
32-
}
33-
}
32+
},
33+
"patternExportKeys": [],
34+
"patternExportDirectory": "./pattern_exports/"
35+
}

0 commit comments

Comments
 (0)