Skip to content

Commit

Permalink
Merge pull request #137 from pattern-lab/dev
Browse files Browse the repository at this point in the history
v0.10.1
  • Loading branch information
Brian Muenzenmeyer committed Aug 10, 2015
2 parents f5219c9 + 1d0fd0b commit bdd5973
Show file tree
Hide file tree
Showing 18 changed files with 438 additions and 57 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
PL-node-v0.10.1
- ADD: Added more unit tests for recently more-modular code
- FIX: Lineage was not working for patterns with pattern parameters

PL-node-v0.10.0
- ADD: Added support for pattern parameters! Resolves #88
- FIX: Data inheritance is now working as advertised. Resolves #127. This turned out to be a MAJOR thing, as I realized the home-page was not passing down any of its json data to partials.
Expand All @@ -7,7 +11,8 @@ PL-node-v0.10.0
- ADD: Added a new comment organism, the sticky comment, to ship an example of pattern parameters
- CHG: Start some JS linting of the project. I don't quite agree with a lot of it, so am trying to set some smart configurations
- CHG: Wrapped some build messages in the patternlab.config.debug flag
- FIX: Allow users to set a base url path. Resolves #125 ([)testing in the while requested)
- FIX: Allow users to set a base url path. Resolves #125 (testing in the wild requested)
- THX: Thanks @scottnath for the proposed base url solution and @jkbyln for discussion on the topic too!

PL-node-v0.9.1
- FIX: Fixed an issue with view all navigation not checking for index out of bounds cases
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);

//travis CI task
grunt.registerTask('travis', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'nodeunit']);
grunt.registerTask('travis', ['nodeunit', 'clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);

grunt.registerTask('serve', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'connect', 'watch']);

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Pattern states should be lowercase and use hyphens where spaces are present.
```

##### Pattern Parameters
attern parameters are a simple mechanism for replacing Mustache variables via attributes on a pattern partial tag rather than having to use a pattern-specific json file. They are especially useful when you want to supply distinct values for Mustache variables in a specific pattern partial instance that may be included multiple times in a molecule, template, or page.
Pattern parameters are a simple mechanism for replacing Mustache variables via attributes on a pattern partial tag rather than having to use a pattern-specific json file. They are especially useful when you want to supply distinct values for Mustache variables in a specific pattern partial instance that may be included multiple times in a molecule, template, or page.

The basic syntax is this:

Expand Down
7 changes: 6 additions & 1 deletion builder/lineage_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -25,6 +25,11 @@
//strip out the template cruft
var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");

// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
if(foundPattern.indexOf('(') > 0){
foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
}

//add if it doesnt exist
if (pattern.lineageIndex.indexOf(foundPattern) === -1){

Expand Down
17 changes: 10 additions & 7 deletions builder/media_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -17,10 +17,10 @@

var media_hunter = function(){

function findMediaQueries(patternlab){
function findMediaQueries(dir, patternlab){
patternlab.mediaQueries = [];

diveSync('./source/css', function(err, file){
diveSync(dir, function(err, file){
if(path.extname(file) === '.css'){
var contents = fs.readFileSync(file, 'utf8');
var safeContents = contents.replace("\r", " ").replace("\n", " ");
Expand All @@ -33,13 +33,16 @@
}
}
});
//alpha sort for now, but should meet most use-cases except greater than 100ems. you are using ems right?
patternlab.mediaQueries.sort();
patternlab.mediaQueries.sort(function(a,b){
var integerPartA = a.match(/(?:\d*\.)?\d+/g);
var integerPartB = b.match(/(?:\d*\.)?\d+/g);
return parseInt(a,10) > parseInt(b,10);
});
}

return {
find_media_queries: function(patternlab){
findMediaQueries(patternlab);
find_media_queries: function(dir, patternlab){
findMediaQueries(dir, patternlab);
}
};

Expand Down
2 changes: 1 addition & 1 deletion builder/object_factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
8 changes: 2 additions & 6 deletions builder/parameter_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down Expand Up @@ -40,15 +40,14 @@
var paramData = eval(paramString);

//compile this partial immeadiately, essentially consuming it.
//TODO: see how this affects lineage. perhaps add manually here.
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
var existingData = pattern.data || patternlab.data;

//merge paramData with any other data that exists.
for (var prop in paramData) {
if (existingData.hasOwnProperty(prop)) {
existingData[prop] = paramData[prop];
}
}
}

//extend pattern data links into link for pattern link shortcuts to work. we do this locally and globally
Expand All @@ -57,9 +56,6 @@

//remove the parameter from the partial and replace it with the rendered partial + paramData
pattern.extendedTemplate = pattern.extendedTemplate.replace(pMatch, renderedPartial);

//TODO: lineage is missing for this pattern

});
}
}
Expand Down
2 changes: 1 addition & 1 deletion builder/pattern_assembler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
12 changes: 6 additions & 6 deletions builder/pattern_exporter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v0.10.0 - 2015
*
/*
* patternlab-node - v0.10.1 - 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.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
4 changes: 2 additions & 2 deletions builder/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down Expand Up @@ -113,7 +113,7 @@ var patternlab_engine = function () {
patternlab.viewAllPaths = {};

//find mediaQueries
media_hunter.find_media_queries(patternlab);
media_hunter.find_media_queries('./source/css', patternlab);

//build the styleguide
var styleguideTemplate = fs.readFileSync('./source/_patternlab-files/styleguide.mustache', 'utf8'),
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.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion builder/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.10.0 - 2015
* patternlab-node - v0.10.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"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.10.0",
"version": "0.10.1",
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-watch": "^0.6.1",
Expand Down
19 changes: 19 additions & 0 deletions test/files/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@media only screen and (min-width: 35em){
body{
color: rebeccapurple;
}
}

@media (min-width:50em){ body{ color: grey;} }

@media only screen and (min-width: 70em) and (max-width: 1600px){
body{
color: green;
}
}

@media only screen and( max-width: 50em){
body{
color: orange;
}
}
167 changes: 165 additions & 2 deletions test/lineage_hunter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,170 @@
test.equals(currentPattern.lineageIndex[2], "molecules-search");

test.done();
}
},

'test lineage hunter finds lineage with spaced pattern parameters' : function(test){
//setup current pattern from what we would have during execution
var currentPattern = {
"name": "01-molecules-01-toast-00-error",
"subdir": "01-molecules\\01-toast",
"filename": "00-error.mustache",
"data": null,
"template": "{{> atoms-error(message: 'That\'s no moon...') }}",
"patternPartial": "{{> atoms-error(message: 'That\'s no moon...') }}",
"patternName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
"flatPatternPath": "01-molecules\\01-toast",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
};
var patternlab = {
patterns: [
{
"name": "01-atoms-05-alerts-00-error",
"subdir": "01-atoms\\05-alerts",
"filename": "00-error.mustache",
"data": null,
"template": "<h1> {{message}} </h1>",
"patternPartial": "<h1> {{message}} </h1>",
"patternName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
"flatPatternPath": "01-atoms\\05-alerts",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
}
]
};

var lineage_hunter = new lh();
lineage_hunter.find_lineage(currentPattern, patternlab);

test.equals(currentPattern.lineageIndex.length, 1);
test.equals(currentPattern.lineageIndex[0], "atoms-error");

test.done();
},

'test lineage hunter finds lineage with unspaced pattern parameters' : function(test){
//setup current pattern from what we would have during execution
var currentPattern = {
"name": "01-molecules-01-toast-00-error",
"subdir": "01-molecules\\01-toast",
"filename": "00-error.mustache",
"data": null,
"template": "{{>atoms-error(message: 'That\'s no moon...')}}",
"patternPartial": "{{>atoms-error(message: 'That\'s no moon...')}}",
"patternName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
"flatPatternPath": "01-molecules\\01-toast",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
};
var patternlab = {
patterns: [
{
"name": "01-atoms-05-alerts-00-error",
"subdir": "01-atoms\\05-alerts",
"filename": "00-error.mustache",
"data": null,
"template": "<h1> {{message}} </h1>",
"patternPartial": "<h1> {{message}} </h1>",
"patternName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
"flatPatternPath": "01-atoms\\05-alerts",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
}
]
};

var lineage_hunter = new lh();
lineage_hunter.find_lineage(currentPattern, patternlab);

test.equals(currentPattern.lineageIndex.length, 1);
test.equals(currentPattern.lineageIndex[0], "atoms-error");
test.equals(patternlab.patterns[0].lineageRIndex.length, 1);
test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error');

test.done();
},

'test lineage hunter does not apply lineage twice' : function(test){
//setup current pattern from what we would have during execution
var currentPattern = {
"name": "01-molecules-01-toast-00-error",
"subdir": "01-molecules\\01-toast",
"filename": "00-error.mustache",
"data": null,
"template": "{{>atoms-error(message: 'That\'s no moon...')}}",
"patternPartial": "{{>atoms-error(message: 'That\'s no moon...')}}",
"patternName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
"flatPatternPath": "01-molecules\\01-toast",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
};
var patternlab = {
patterns: [
{
"name": "01-atoms-05-alerts-00-error",
"subdir": "01-atoms\\05-alerts",
"filename": "00-error.mustache",
"data": null,
"template": "<h1> {{message}} </h1>",
"patternPartial": "<h1> {{message}} </h1>",
"patternName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
"flatPatternPath": "01-atoms\\05-alerts",
"patternState": "",
"lineage": [],
"lineageIndex": [],
"lineageR": [],
"lineageRIndex": []
}
]
};

var lineage_hunter = new lh();
lineage_hunter.find_lineage(currentPattern, patternlab);
lineage_hunter.find_lineage(currentPattern, patternlab);

test.equals(currentPattern.lineageIndex.length, 1);
test.equals(currentPattern.lineageIndex[0], "atoms-error");
test.equals(patternlab.patterns[0].lineageRIndex.length, 1);
test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error');

test.done();
},


};

}());
}());
Loading

0 comments on commit bdd5973

Please sign in to comment.