Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 558ecab

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/dev' into pattern-engines
2 parents 6db7cb1 + c53440a commit 558ecab

20 files changed

+373
-93
lines changed

.gitignore

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
node_modules/
22
.DS_Store
3-
public/index.html
4-
public/styleguide.html
5-
public/styleguide/html/styleguide.html
6-
public/css/*
7-
public/data/*
8-
public/fonts/*
9-
public/js/*
10-
public/images/*
11-
public/patterns/*
123
latest-change.txt
134
patternlab.json
145
.sass-cache/*
156
/sass-cache
16-
source/images/Thumbs.db
17-
public/styleguide/css/static.css.map
18-
public/styleguide/css/styleguide-specific.css.map
19-
public/styleguide/css/styleguide.css.map
7+
Thumbs.db
208
source/css/style.css.map
219
.idea/
22-
public/styleguide/
10+
public

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ module.exports = function (grunt) {
8787
path.resolve(paths().source.patterns + '**/*'),
8888
path.resolve(paths().source.fonts + '/*'),
8989
path.resolve(paths().source.images + '/*'),
90-
path.resolve(paths().source.data + '*.json')
90+
path.resolve(paths().source.data + '*.json'),
91+
path.resolve(paths().source.js + '/*.js')
9192
],
9293
tasks: ['default', 'bsReload:css']
9394
}

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,50 @@ The current selection is as follows.
144144
}
145145
```
146146
##### Pattern States
147-
You can set the state of a pattern by including it in `patternlab-config.json` too. The out of the box styles are in progress (orange), in review (yellow), and complete (green).
148-
Pattern states should be lowercase and use hyphens where spaces are present.
147+
You can set the state of a pattern by including its key in the `patternStates` object in `patternlab-config.json`, along with a style defined inside `patternStateCascade`. The out of the box styles are in progress (orange), in review (yellow), and complete (green).
149148
```
150149
"patternStates": {
151-
"colors" : "inprogress",
152-
"fonts" : "inreview",
153-
"three-up" : "complete"
150+
"atoms-colors" : "complete",
151+
"molecules-primary-nav" : "inreview",
152+
"organisms-header" : "inprogress"
153+
}
154+
```
155+
156+
Note that patterns inherit the lowest common denominator pattern state of their lineage.
157+
Consider:
158+
```
159+
"patternStates": {
160+
"molecules-single-comment" : "complete",
161+
"organisms-sticky-comment" : "inreview",
162+
"templates-article" : "complete"
163+
}
164+
```
165+
In this case, two things are of note:
166+
167+
* templates-article will display inreview since it inherits `organisms-sticky-comment`
168+
* pages-article will not display any pattern state, as it does not define one
169+
170+
The `patternStateCascade` array is important in that the order is hierarchical.
171+
The default is below:
172+
173+
```
174+
"patternStateCascade": ["inprogress", "inreview", "complete"],
175+
```
176+
177+
which correspond to classes defined inside `./core/styleguide/css/styleguide.css`
178+
179+
```
180+
/* pattern states */
181+
.inprogress:before {
182+
color: #FF4136 !important;
183+
}
184+
185+
.inreview:before {
186+
color: #FFCC00 !important;
187+
}
188+
189+
.complete:before {
190+
color: #2ECC40 !important;
154191
}
155192
```
156193

core/lib/lineage_hunter.js

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
/*
2-
* patternlab-node - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
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

1111
"use strict";
1212

1313
var lineage_hunter = function () {
1414

15+
var pa = require('./pattern_assembler');
16+
1517
function findlineage(pattern, patternlab) {
1618

17-
var pa = require('./pattern_assembler');
1819
var pattern_assembler = new pa();
1920

2021
//find the {{> template-name }} within patterns
@@ -33,7 +34,11 @@ var lineage_hunter = function () {
3334
"lineagePattern": ancestorPattern.key,
3435
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
3536
};
36-
pattern.lineage.push(JSON.stringify(l));
37+
if (ancestorPattern.patternState) {
38+
l.lineageState = ancestorPattern.patternState;
39+
}
40+
41+
pattern.lineage.push(l);
3742

3843
//also, add the lineageR entry if it doesn't exist
3944
if (ancestorPattern.lineageRIndex.indexOf(pattern.key) === -1) {
@@ -44,16 +49,90 @@ var lineage_hunter = function () {
4449
"lineagePattern": pattern.key,
4550
"lineagePath": "../../patterns/" + pattern.patternLink
4651
};
47-
ancestorPattern.lineageR.push(JSON.stringify(lr));
52+
if (pattern.patternState) {
53+
lr.lineageState = pattern.patternState;
54+
}
55+
56+
ancestorPattern.lineageR.push(lr);
4857
}
4958
}
5059
});
5160
}
5261
}
5362

63+
function setPatternState(direction, pattern, targetPattern) {
64+
// if the request came from the past, apply target pattern state to current pattern lineage
65+
if (direction === 'fromPast') {
66+
for (var i = 0; i < pattern.lineageIndex.length; i++) {
67+
if (pattern.lineageIndex[i] === targetPattern.key) {
68+
pattern.lineage[i].lineageState = targetPattern.patternState;
69+
}
70+
}
71+
} else {
72+
//the request came from the future, apply target pattern state to current pattern reverse lineage
73+
for (var i = 0; i < pattern.lineageRIndex.length; i++) {
74+
if (pattern.lineageRIndex[i] === targetPattern.key) {
75+
pattern.lineageR[i].lineageState = targetPattern.patternState;
76+
}
77+
}
78+
}
79+
}
80+
81+
82+
function cascadePatternStates(patternlab) {
83+
84+
var pattern_assembler = new pa();
85+
86+
for (var i = 0; i < patternlab.patterns.length; i++) {
87+
var pattern = patternlab.patterns[i];
88+
89+
//for each pattern with a defined state
90+
if (pattern.patternState) {
91+
92+
if (pattern.lineageIndex && pattern.lineageIndex.length > 0) {
93+
94+
//find all lineage - patterns being consumed by this one
95+
for (var h = 0; h < pattern.lineageIndex.length; h++) {
96+
var lineagePattern = pattern_assembler.get_pattern_by_key(pattern.lineageIndex[h], patternlab);
97+
setPatternState('fromFuture', lineagePattern, pattern);
98+
}
99+
}
100+
101+
if (pattern.lineageRIndex && pattern.lineageRIndex.length > 0) {
102+
103+
//find all reverse lineage - that is, patterns consuming this one
104+
for (var j = 0; j < pattern.lineageRIndex.length; j++) {
105+
106+
var lineageRPattern = pattern_assembler.get_pattern_by_key(pattern.lineageRIndex[j], patternlab);
107+
108+
//only set patternState if pattern.patternState "is less than" the lineageRPattern.patternstate
109+
//this makes patternlab apply the lowest common ancestor denominator
110+
if (patternlab.config.patternStateCascade.indexOf(pattern.patternState)
111+
< patternlab.config.patternStateCascade.indexOf(lineageRPattern.patternState)) {
112+
113+
if (patternlab.config.debug) {
114+
console.log('Found a lower common denominator pattern state: ' + pattern.patternState + ' on ' + pattern.key + '. Setting reverse lineage pattern ' + lineageRPattern.key + ' from ' + lineageRPattern.patternState);
115+
}
116+
117+
lineageRPattern.patternState = pattern.patternState;
118+
119+
//take this opportunity to overwrite the lineageRPattern's lineage state too
120+
setPatternState('fromPast', lineageRPattern, pattern);
121+
} else {
122+
setPatternState('fromPast', pattern, lineageRPattern);
123+
}
124+
}
125+
}
126+
}
127+
}
128+
}
129+
54130
return {
55131
find_lineage: function (pattern, patternlab) {
56132
findlineage(pattern, patternlab);
133+
},
134+
cascade_pattern_states : function (patternlab) {
135+
cascadePatternStates(patternlab);
57136
}
58137
};
59138
};

core/lib/list_item_hunter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
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

core/lib/media_hunter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
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

core/lib/object_factory.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*

core/lib/parameter_hunter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
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

core/lib/pattern_assembler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.1.3 - 2016
2+
* patternlab-node - v1.2.0 - 2016
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -77,8 +77,8 @@ var pattern_assembler = function () {
7777
}
7878

7979
function setState(pattern, patternlab) {
80-
if (patternlab.config.patternStates && patternlab.config.patternStates[pattern.patternName]) {
81-
pattern.patternState = patternlab.config.patternStates[pattern.patternName];
80+
if (patternlab.config.patternStates && patternlab.config.patternStates[pattern.key]) {
81+
pattern.patternState = patternlab.config.patternStates[pattern.key];
8282
} else {
8383
pattern.patternState = "";
8484
}

core/lib/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 - v1.1.3 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.2.0 - 2016
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

0 commit comments

Comments
 (0)