Skip to content

Commit

Permalink
Merge pull request #83 from pattern-lab/plnode1-7
Browse files Browse the repository at this point in the history
Plnode1 7
  • Loading branch information
Brian Muenzenmeyer committed Jan 9, 2015
2 parents 8494969 + 2e8183a commit a1fd6a4
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.

PL-node-v0.1.7
- ADD: pattern export
- CHG: updated devDependencies
- FIX: fixed a type in the README and config
- THX: thanks @seanhussey for the pull request!

PL-node-v0.1.6
- ADD: media queries found in css added to ish controls
- ADD: basic lineage support
Expand Down
7 changes: 6 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ module.exports = function(grunt) {
patternlab_grunt: {
src: './builder/patternlab_grunt.js',
dest: './builder/patternlab_grunt.js'
},
pattern_exporter: {
src: './builder/pattern_exporter.js',
dest: './builder/pattern_exporter.js'
}
},
copy: {
Expand Down Expand Up @@ -83,7 +87,8 @@ module.exports = function(grunt) {
files: {
'./source/css/style.css': './source/css/style.scss',
'./public/styleguide/css/static.css': './public/styleguide/css/static.scss',
'./public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss'
'./public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
'./public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
}
}
},
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The current selection is as follows. It reflects support versus patternlab-php.
"m": true,
"l": true,
"full": true,
"ranndom": true,
"random": true,
"disco": true,
"hay": true,
"mqs": false,
Expand All @@ -62,10 +62,6 @@ The current selection is as follows. It reflects support versus patternlab-php.
"tools-docs": true
}
```

##### Verbose Mode
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.

##### Pattern States
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).
Pattern states should be lowercase and use hyphens where spaces are present.
Expand All @@ -77,6 +73,20 @@ Pattern states should be lowercase and use hyphens where spaces are present.
}
```

##### Pattern Export
`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.

```
"patternExportKeys": ["molecules-primary-nav", "organisms-header", "organisms-header"],
"patternExportDirectory": "./pattern_exports/"
```

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.


##### Verbose Mode
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.

##### Server
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.

Expand Down
2 changes: 1 addition & 1 deletion builder/lineage_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.1.6 - 2014
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion builder/media_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.1.6 - 2014
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
3 changes: 2 additions & 1 deletion builder/object_factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.1.6 - 2014
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -23,6 +23,7 @@
this.patternGroup = name.substring(name.indexOf('-') + 1, name.indexOf('-', 4) + 1 - name.indexOf('-') + 1);
this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);
this.flatPatternPath = subdir.replace(/\//g, '-');
this.key = '';
this.lineage = [];
this.lineageIndex = [];
this.lineageR = [];
Expand Down
48 changes: 48 additions & 0 deletions builder/pattern_exporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

(function () {
"use strict";

var fs = require('fs-extra'),
path = require('path');

var pattern_exporter = function(){

function exportPatterns(patternlab){

//read the config export options
var exportKeys = patternlab.config.patternExportKeys;

//find the chosen patterns to export
for (var i = 0; i < exportKeys.length; i++){
for (var j = 0; j < patternlab.patterns.length; j++){
if(exportKeys[i] === patternlab.patterns[j].key){
//write matches to the desired location
fs.outputFileSync(patternlab.config.patternExportDirectory + patternlab.patterns[j].key + '.html', patternlab.patterns[j].patternPartial);
}
}
}



}

return {
export_patterns: function(patternlab){
exportPatterns(patternlab);
}
};

};

module.exports = pattern_exporter;

}());
9 changes: 7 additions & 2 deletions builder/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.1.6 - 2014
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -17,6 +17,7 @@ var patternlab_engine = function(){
pa = require('./pattern_assembler'),
mh = require('./media_hunter'),
lh = require('./lineage_hunter'),
pe = require('./pattern_exporter')
patternlab = {};

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

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

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

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

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

});

//export patterns if necessary
var pattern_exporter = new pe();
pattern_exporter.export_patterns(patternlab);

}

Expand Down
2 changes: 1 addition & 1 deletion builder/patternlab_grunt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.1.6 - 2014
* patternlab-node - v0.1.7 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
8 changes: 5 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"m": true,
"l": true,
"full": true,
"ranndom": true,
"random": true,
"disco": true,
"hay": true,
"mqs": true,
Expand All @@ -29,5 +29,7 @@
"tools-docs": true
},
"patternStates": {
}
}
},
"patternExportKeys": [],
"patternExportDirectory": "./pattern_exports/"
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "patternlab-node",
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
"version": "0.1.6",
"version": "0.1.7",
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-sass": "~0.2.2",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-jshint": "~0.4.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-nodeunit": "~0.3.0",
"grunt-contrib-connect": "^0.8.0",
"mustache": "~0.8.1",
"matchdep": "~0.3.0",
"fs-extra": "^0.10.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-nodeunit": "^0.4.1",
"grunt-contrib-connect": "^0.9.0",
"mustache": "^1.0.0",
"matchdep": "^0.3.0",
"fs-extra": "^0.14.0",
"diveSync": "^0.2.1"
},
"keywords": [
Expand Down

0 comments on commit a1fd6a4

Please sign in to comment.