Skip to content

Commit bdd5973

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request pattern-lab#137 from pattern-lab/dev
v0.10.1
2 parents f5219c9 + 1d0fd0b commit bdd5973

18 files changed

+438
-57
lines changed

CHANGELOG

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
2+
PL-node-v0.10.1
3+
- ADD: Added more unit tests for recently more-modular code
4+
- FIX: Lineage was not working for patterns with pattern parameters
5+
26
PL-node-v0.10.0
37
- ADD: Added support for pattern parameters! Resolves #88
48
- 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.
@@ -7,7 +11,8 @@ PL-node-v0.10.0
711
- ADD: Added a new comment organism, the sticky comment, to ship an example of pattern parameters
812
- 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
913
- CHG: Wrapped some build messages in the patternlab.config.debug flag
10-
- FIX: Allow users to set a base url path. Resolves #125 ([)testing in the while requested)
14+
- FIX: Allow users to set a base url path. Resolves #125 (testing in the wild requested)
15+
- THX: Thanks @scottnath for the proposed base url solution and @jkbyln for discussion on the topic too!
1116

1217
PL-node-v0.9.1
1318
- FIX: Fixed an issue with view all navigation not checking for index out of bounds cases

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ module.exports = function(grunt) {
133133
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
134134

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

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Pattern states should be lowercase and use hyphens where spaces are present.
7474
```
7575

7676
##### Pattern Parameters
77-
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.
77+
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.
7878

7979
The basic syntax is this:
8080

builder/lineage_hunter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -25,6 +25,11 @@
2525
//strip out the template cruft
2626
var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
2727

28+
// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
29+
if(foundPattern.indexOf('(') > 0){
30+
foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
31+
}
32+
2833
//add if it doesnt exist
2934
if (pattern.lineageIndex.indexOf(foundPattern) === -1){
3035

builder/media_hunter.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -17,10 +17,10 @@
1717

1818
var media_hunter = function(){
1919

20-
function findMediaQueries(patternlab){
20+
function findMediaQueries(dir, patternlab){
2121
patternlab.mediaQueries = [];
2222

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

4043
return {
41-
find_media_queries: function(patternlab){
42-
findMediaQueries(patternlab);
44+
find_media_queries: function(dir, patternlab){
45+
findMediaQueries(dir, patternlab);
4346
}
4447
};
4548

builder/object_factory.js

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

builder/parameter_hunter.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -40,15 +40,14 @@
4040
var paramData = eval(paramString);
4141

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

4746
//merge paramData with any other data that exists.
4847
for (var prop in paramData) {
4948
if (existingData.hasOwnProperty(prop)) {
5049
existingData[prop] = paramData[prop];
51-
}
50+
}
5251
}
5352

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

5857
//remove the parameter from the partial and replace it with the rendered partial + paramData
5958
pattern.extendedTemplate = pattern.extendedTemplate.replace(pMatch, renderedPartial);
60-
61-
//TODO: lineage is missing for this pattern
62-
6359
});
6460
}
6561
}

builder/pattern_assembler.js

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

builder/pattern_exporter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v0.10.1 - 2015
3+
*
44
* 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.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

builder/patternlab.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -113,7 +113,7 @@ var patternlab_engine = function () {
113113
patternlab.viewAllPaths = {};
114114

115115
//find mediaQueries
116-
media_hunter.find_media_queries(patternlab);
116+
media_hunter.find_media_queries('./source/css', patternlab);
117117

118118
//build the styleguide
119119
var styleguideTemplate = fs.readFileSync('./source/_patternlab-files/styleguide.mustache', 'utf8'),

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.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/pseudopattern_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.10.0 - 2015
2+
* patternlab-node - v0.10.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternlab-node",
33
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4-
"version": "0.10.0",
4+
"version": "0.10.1",
55
"devDependencies": {
66
"grunt": "~0.4.0",
77
"grunt-contrib-watch": "^0.6.1",

test/files/test.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@media only screen and (min-width: 35em){
2+
body{
3+
color: rebeccapurple;
4+
}
5+
}
6+
7+
@media (min-width:50em){ body{ color: grey;} }
8+
9+
@media only screen and (min-width: 70em) and (max-width: 1600px){
10+
body{
11+
color: green;
12+
}
13+
}
14+
15+
@media only screen and( max-width: 50em){
16+
body{
17+
color: orange;
18+
}
19+
}

test/lineage_hunter_tests.js

Lines changed: 165 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,170 @@
9393
test.equals(currentPattern.lineageIndex[2], "molecules-search");
9494

9595
test.done();
96-
}
96+
},
97+
98+
'test lineage hunter finds lineage with spaced pattern parameters' : function(test){
99+
//setup current pattern from what we would have during execution
100+
var currentPattern = {
101+
"name": "01-molecules-01-toast-00-error",
102+
"subdir": "01-molecules\\01-toast",
103+
"filename": "00-error.mustache",
104+
"data": null,
105+
"template": "{{> atoms-error(message: 'That\'s no moon...') }}",
106+
"patternPartial": "{{> atoms-error(message: 'That\'s no moon...') }}",
107+
"patternName": "error",
108+
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
109+
"patternGroup": "molecules",
110+
"patternSubGroup": "molecules\\01-toast",
111+
"flatPatternPath": "01-molecules\\01-toast",
112+
"patternState": "",
113+
"lineage": [],
114+
"lineageIndex": [],
115+
"lineageR": [],
116+
"lineageRIndex": []
117+
};
118+
var patternlab = {
119+
patterns: [
120+
{
121+
"name": "01-atoms-05-alerts-00-error",
122+
"subdir": "01-atoms\\05-alerts",
123+
"filename": "00-error.mustache",
124+
"data": null,
125+
"template": "<h1> {{message}} </h1>",
126+
"patternPartial": "<h1> {{message}} </h1>",
127+
"patternName": "error",
128+
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
129+
"patternGroup": "atoms",
130+
"patternSubGroup": "atoms\\05-alerts",
131+
"flatPatternPath": "01-atoms\\05-alerts",
132+
"patternState": "",
133+
"lineage": [],
134+
"lineageIndex": [],
135+
"lineageR": [],
136+
"lineageRIndex": []
137+
}
138+
]
139+
};
140+
141+
var lineage_hunter = new lh();
142+
lineage_hunter.find_lineage(currentPattern, patternlab);
143+
144+
test.equals(currentPattern.lineageIndex.length, 1);
145+
test.equals(currentPattern.lineageIndex[0], "atoms-error");
146+
147+
test.done();
148+
},
149+
150+
'test lineage hunter finds lineage with unspaced pattern parameters' : function(test){
151+
//setup current pattern from what we would have during execution
152+
var currentPattern = {
153+
"name": "01-molecules-01-toast-00-error",
154+
"subdir": "01-molecules\\01-toast",
155+
"filename": "00-error.mustache",
156+
"data": null,
157+
"template": "{{>atoms-error(message: 'That\'s no moon...')}}",
158+
"patternPartial": "{{>atoms-error(message: 'That\'s no moon...')}}",
159+
"patternName": "error",
160+
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
161+
"patternGroup": "molecules",
162+
"patternSubGroup": "molecules\\01-toast",
163+
"flatPatternPath": "01-molecules\\01-toast",
164+
"patternState": "",
165+
"lineage": [],
166+
"lineageIndex": [],
167+
"lineageR": [],
168+
"lineageRIndex": []
169+
};
170+
var patternlab = {
171+
patterns: [
172+
{
173+
"name": "01-atoms-05-alerts-00-error",
174+
"subdir": "01-atoms\\05-alerts",
175+
"filename": "00-error.mustache",
176+
"data": null,
177+
"template": "<h1> {{message}} </h1>",
178+
"patternPartial": "<h1> {{message}} </h1>",
179+
"patternName": "error",
180+
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
181+
"patternGroup": "atoms",
182+
"patternSubGroup": "atoms\\05-alerts",
183+
"flatPatternPath": "01-atoms\\05-alerts",
184+
"patternState": "",
185+
"lineage": [],
186+
"lineageIndex": [],
187+
"lineageR": [],
188+
"lineageRIndex": []
189+
}
190+
]
191+
};
192+
193+
var lineage_hunter = new lh();
194+
lineage_hunter.find_lineage(currentPattern, patternlab);
195+
196+
test.equals(currentPattern.lineageIndex.length, 1);
197+
test.equals(currentPattern.lineageIndex[0], "atoms-error");
198+
test.equals(patternlab.patterns[0].lineageRIndex.length, 1);
199+
test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error');
200+
201+
test.done();
202+
},
203+
204+
'test lineage hunter does not apply lineage twice' : function(test){
205+
//setup current pattern from what we would have during execution
206+
var currentPattern = {
207+
"name": "01-molecules-01-toast-00-error",
208+
"subdir": "01-molecules\\01-toast",
209+
"filename": "00-error.mustache",
210+
"data": null,
211+
"template": "{{>atoms-error(message: 'That\'s no moon...')}}",
212+
"patternPartial": "{{>atoms-error(message: 'That\'s no moon...')}}",
213+
"patternName": "error",
214+
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
215+
"patternGroup": "molecules",
216+
"patternSubGroup": "molecules\\01-toast",
217+
"flatPatternPath": "01-molecules\\01-toast",
218+
"patternState": "",
219+
"lineage": [],
220+
"lineageIndex": [],
221+
"lineageR": [],
222+
"lineageRIndex": []
223+
};
224+
var patternlab = {
225+
patterns: [
226+
{
227+
"name": "01-atoms-05-alerts-00-error",
228+
"subdir": "01-atoms\\05-alerts",
229+
"filename": "00-error.mustache",
230+
"data": null,
231+
"template": "<h1> {{message}} </h1>",
232+
"patternPartial": "<h1> {{message}} </h1>",
233+
"patternName": "error",
234+
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
235+
"patternGroup": "atoms",
236+
"patternSubGroup": "atoms\\05-alerts",
237+
"flatPatternPath": "01-atoms\\05-alerts",
238+
"patternState": "",
239+
"lineage": [],
240+
"lineageIndex": [],
241+
"lineageR": [],
242+
"lineageRIndex": []
243+
}
244+
]
245+
};
246+
247+
var lineage_hunter = new lh();
248+
lineage_hunter.find_lineage(currentPattern, patternlab);
249+
lineage_hunter.find_lineage(currentPattern, patternlab);
250+
251+
test.equals(currentPattern.lineageIndex.length, 1);
252+
test.equals(currentPattern.lineageIndex[0], "atoms-error");
253+
test.equals(patternlab.patterns[0].lineageRIndex.length, 1);
254+
test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error');
255+
256+
test.done();
257+
},
258+
259+
97260
};
98261

99-
}());
262+
}());

0 commit comments

Comments
 (0)