Skip to content

Commit bf29417

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #266 from pattern-lab/217
Support for pattern type view all pages
2 parents faf36a0 + 13ca810 commit bf29417

15 files changed

+64
-21
lines changed

CHANGELOG

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

3+
PL-node-v1.1.3
4+
- FIX: Added pattern type view all pages to the navigation, which users view all 'Atoms/Molecules/Organisms' etc.
5+
- THX: Thanks to @gael-boyenval for originally pointing out the omission.
6+
37
PL-node-v1.1.2
48
- FIX: Greatly improved the browsersync configuration, so that it only fires on the iframe, preventing users from losing their scroll position. Also lightened up the styling and made it less obtrusive.
59
- THX: Thanks to @geoffp for taking the lead on this issue.

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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/list_item_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/parameter_hunter.js

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

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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/pattern_exporter.js

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

builder/patternlab.js

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -207,7 +207,8 @@ var patternlab_engine = function (config) {
207207

208208
//build the viewall pages
209209
var prevSubdir = '',
210-
i;
210+
prevGroup = '',
211+
i;
211212

212213
for (i = 0; i < patternlab.patterns.length; i++) {
213214
// skip underscore-prefixed files
@@ -220,6 +221,35 @@ var patternlab_engine = function (config) {
220221

221222
var pattern = patternlab.patterns[i];
222223

224+
//create the view all for the section
225+
// check if the current section is different from the previous one
226+
if (pattern.patternGroup != prevGroup){
227+
prevGroup = pattern.patternGroup;
228+
229+
var viewAllPatterns = [],
230+
patternPartial = "viewall-" + pattern.patternGroup,
231+
j;
232+
233+
for (j = 0; j < patternlab.patterns.length; j++) {
234+
if (patternlab.patterns[j].patternGroup === pattern.patternGroup) {
235+
//again, skip any sibling patterns to the current one that may have underscores
236+
if(isPatternExcluded(patternlab.patterns[j])){
237+
if(patternlab.config.debug){
238+
console.log('Omitting ' + patternlab.patterns[j].key + " from view all sibling rendering.");
239+
}
240+
continue;
241+
}
242+
243+
viewAllPatterns.push(patternlab.patterns[j]);
244+
}
245+
}
246+
247+
var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'viewall.mustache'), 'utf8');
248+
var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial});
249+
fs.outputFileSync(paths.public.patterns + pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + '/index.html', viewAllHtml);
250+
}
251+
252+
//create the view all for the subsection
223253
// check if the current sub section is different from the previous one
224254
if (pattern.subdir !== prevSubdir) {
225255
prevSubdir = pattern.subdir;
@@ -318,6 +348,14 @@ var patternlab_engine = function (config) {
318348
//add to patternPaths
319349
addToPatternPaths(bucketName, pattern);
320350

351+
//add the navViewAllItem
352+
var navViewAllItem = new of.oNavSubItem("View All");
353+
navViewAllItem.patternPath = pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + "/index.html";
354+
navViewAllItem.patternPartial = "viewall-" + pattern.patternGroup;
355+
356+
bucket.patternItems.push(navViewAllItem);
357+
patternlab.viewAllPaths[bucketName]['viewall'] = pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length);
358+
321359
}
322360

323361
//add the bucket.
@@ -393,14 +431,15 @@ var patternlab_engine = function (config) {
393431
}
394432
}
395433

396-
//add the navViewAllSubItem
397-
var navViewAllSubItem = new of.oNavSubItem("");
398-
navViewAllSubItem.patternName = "View All";
399-
navViewAllSubItem.patternPath = pattern.flatPatternPath + "/index.html";
400-
navViewAllSubItem.patternPartial = "viewall-" + pattern.patternGroup + "-" + pattern.patternSubGroup;
401-
402434
//check if we are moving to a new sub section in the next loop
403435
if (!patternlab.patterns[i + 1] || pattern.patternSubGroup !== patternlab.patterns[i + 1].patternSubGroup) {
436+
437+
//add the navViewAllSubItem
438+
var navViewAllSubItem = new of.oNavSubItem("");
439+
navViewAllSubItem.patternName = "View All";
440+
navViewAllSubItem.patternPath = pattern.flatPatternPath + "/index.html";
441+
navViewAllSubItem.patternPartial = "viewall-" + pattern.patternGroup + "-" + pattern.patternSubGroup;
442+
404443
navItem.navSubItems.push(navViewAllSubItem);
405444
navItem.navSubItemsIndex.push("View All");
406445
}

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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab_gulp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
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 - v1.1.2 - 2016
2+
* patternlab-node - v1.1.3 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/style_modifier_hunter.js

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

package.gulp.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": "1.1.2",
4+
"version": "1.1.3",
55
"main": "./builder/patternlab.js",
66
"dependencies": {
77
"del": "^2.2.0",

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": "1.1.2",
4+
"version": "1.1.3",
55
"main": "./builder/patternlab.js",
66
"dependencies": {
77
"diveSync": "^0.3.0",

0 commit comments

Comments
 (0)