Skip to content

Commit a46718b

Browse files
authored
Merge branch 'dev' into fix-1019
2 parents 0368ff0 + a03c3bb commit a46718b

File tree

15 files changed

+150
-135
lines changed

15 files changed

+150
-135
lines changed

packages/core/src/lib/exportData.js

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
const eol = require('os').EOL;
43
const path = require('path');
5-
const _ = require('lodash');
4+
const eol = require('os').EOL;
65

76
const ae = require('./annotation_exporter');
87

@@ -12,7 +11,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const
1211
* Write out our pattern information for use by the front end
1312
* @param patternlab - global data store
1413
*/
15-
module.exports = function(patternlab) {
14+
module.exports = function(patternlab, uikit) {
1615
const annotation_exporter = new ae(patternlab);
1716

1817
const paths = patternlab.config.paths;
@@ -71,42 +70,38 @@ module.exports = function(patternlab) {
7170
const annotationsJSON = annotation_exporter.gather();
7271
const annotations =
7372
'var comments = { "comments" : ' + JSON.stringify(annotationsJSON) + '};';
74-
_.each(patternlab.uikits, uikit => {
75-
fs.outputFileSync(
76-
path.resolve(
77-
path.join(
78-
process.cwd(),
79-
uikit.outputDir,
80-
paths.public.annotations,
81-
'annotations.js'
82-
)
83-
),
84-
annotations
85-
);
86-
});
73+
fs.outputFileSync(
74+
path.resolve(
75+
path.join(
76+
process.cwd(),
77+
uikit.outputDir,
78+
paths.public.annotations,
79+
'annotations.js'
80+
)
81+
),
82+
annotations
83+
);
8784

8885
// add module.export to the Nodejs-specific file generated.
8986
const exportedOutput =
9087
output +
9188
'module.exports = { config, ishControls, navItems, patternPaths, viewAllPaths, plugins, defaultShowPatternInfo, defaultPattern };';
9289

9390
//write all output to patternlab-data
94-
_.each(patternlab.uikits, uikit => {
95-
fs.outputFileSync(
96-
path.resolve(
97-
path.join(process.cwd(), uikit.outputDir, paths.public.data),
98-
'patternlab-data.js'
99-
),
100-
output
101-
);
102-
fs.outputFileSync(
103-
path.resolve(
104-
path.join(process.cwd(), uikit.outputDir, paths.public.data),
105-
'patternlab-data.cjs.js'
106-
),
107-
exportedOutput
108-
);
109-
});
91+
fs.outputFileSync(
92+
path.resolve(
93+
path.join(process.cwd(), uikit.outputDir, paths.public.data),
94+
'patternlab-data.js'
95+
),
96+
output
97+
);
98+
fs.outputFileSync(
99+
path.resolve(
100+
path.join(process.cwd(), uikit.outputDir, paths.public.data),
101+
'patternlab-data.cjs.js'
102+
),
103+
exportedOutput
104+
);
110105

111106
return output;
112107
};

packages/core/src/lib/ui_builder.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,18 @@ const ui_builder = function() {
755755

756756
/**
757757
* The main entry point for ui_builder
758-
*
759-
* @param patternlab - global data store
758+
* @param patternlabGlobal - global data store
760759
* @returns {Promise} a promise fulfilled when build is complete
761760
*/
762-
function buildFrontend(patternlab) {
763-
resetUIBuilderState(patternlab);
761+
function buildFrontend(patternlabGlobal) {
762+
const paths = patternlabGlobal.config.paths;
764763

765-
const paths = patternlab.config.paths;
764+
const uikitPromises = _.map(patternlabGlobal.uikits, uikit => {
765+
//we need to make sure the patternlab object gets manipulated per uikit
766+
const patternlab = Object.assign({}, patternlabGlobal);
766767

767-
const uikitPromises = _.map(patternlab.uikits, uikit => {
768-
// determine which patterns should be included in the front-end rendering
768+
resetUIBuilderState(patternlab);
769+
//determine which patterns should be included in the front-end rendering
769770
const styleguidePatterns = groupPatterns(patternlab, uikit);
770771

771772
return new Promise(resolve => {
@@ -891,8 +892,8 @@ const ui_builder = function() {
891892
patternlabSiteHtml
892893
);
893894

894-
// write out patternlab.data object to be read by the client
895-
exportData(patternlab);
895+
//write out patternlab.data object to be read by the client
896+
exportData(patternlab, uikit);
896897
resolve();
897898
})
898899
.catch(reason => {

packages/core/test/exportData_tests.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,77 @@ exportData.__set__({
2020
fs: fsMock,
2121
});
2222

23-
const patternlab = util.fakePatternLab(testPatternsPath);
24-
const result = exportData(patternlab);
23+
const uikitFoo = {
24+
name: 'uikit-foo',
25+
enabled: true,
26+
outputDir: 'foo',
27+
excludedPatternStates: ['legacy'],
28+
excludedTags: ['baz'],
29+
};
2530

2631
tap.test('exportData exports config', function(test) {
32+
const patternlab = util.fakePatternLab(testPatternsPath);
33+
const result = exportData(patternlab, uikitFoo);
34+
2735
test.equals(result.indexOf('config') > -1, true);
2836
test.equals(result.indexOf('paths') > -1, true);
2937
test.equals(result.indexOf('theme') > -1, true);
3038
test.end();
3139
});
3240

3341
tap.test('exportData exports ishControls', function(test) {
42+
const patternlab = util.fakePatternLab(testPatternsPath);
43+
const result = exportData(patternlab, uikitFoo);
44+
3445
test.equals(result.indexOf('ishControlsHide') > -1, true);
3546
test.end();
3647
});
3748

3849
tap.test('exportData exports navItems', function(test) {
50+
const patternlab = util.fakePatternLab(testPatternsPath);
51+
const result = exportData(patternlab, uikitFoo);
52+
3953
test.equals(result.indexOf('patternTypes') > -1, true);
4054
test.end();
4155
});
4256

4357
tap.test('exportData exports patternPaths', function(test) {
58+
const patternlab = util.fakePatternLab(testPatternsPath);
59+
const result = exportData(patternlab, uikitFoo);
60+
4461
test.equals(result.indexOf('patternPaths') > -1, true);
4562
test.end();
4663
});
4764

4865
tap.test('exportData exports viewAllPaths', function(test) {
66+
const patternlab = util.fakePatternLab(testPatternsPath);
67+
const result = exportData(patternlab, uikitFoo);
68+
4969
test.equals(result.indexOf('viewAllPaths') > -1, true);
5070
test.end();
5171
});
5272

5373
tap.test('exportData exports plugins', function(test) {
74+
const patternlab = util.fakePatternLab(testPatternsPath);
75+
const result = exportData(patternlab, uikitFoo);
76+
5477
test.equals(result.indexOf('plugins') > -1, true);
5578
test.end();
5679
});
5780

5881
tap.test('exportData exports defaultShowPatternInfo', function(test) {
82+
const patternlab = util.fakePatternLab(testPatternsPath);
83+
const result = exportData(patternlab, uikitFoo);
84+
5985
test.equals(result.indexOf('defaultShowPatternInfo') > -1, true);
6086
test.equals(result.indexOf('"defaultShowPatternInfo":false') > -1, true);
6187
test.end();
6288
});
6389

6490
tap.test('exportData exports defaultPattern', function(test) {
91+
const patternlab = util.fakePatternLab(testPatternsPath);
92+
const result = exportData(patternlab, uikitFoo);
93+
6594
test.equals(result.indexOf('defaultPattern') > -1, true);
6695
test.equals(result.indexOf('"defaultPattern":"all"') > -1, true);
6796
test.end();

packages/docs/src/docs/advanced-config-options.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Sets whether or not you want the styleguide to load with the pattern info open o
4545

4646
**default**: `false`
4747

48+
### defaultPatternInfoPanelCode (optional)
49+
50+
Sets default active pattern info code panel by file extension - if unset, uses the value out of _patternExtension_ config value, or instead use value `html` to display the html code initially, or the value defined for the _patternExtension_.
51+
52+
**default**: _patternExtension_ value (`"hbs"` | `"mustache"` | `"twig"` | `"html"`)
53+
4854
### ishControlsHide
4955

5056
Sets whether or not to hide navigation options within the styleguide.

packages/plugin-tab/src/snippet.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
window.patternlab.panels.add({
22
id: 'sg-panel-<<type>>',
33
name: '<<typeUC>>',
4-
default: window.config.defaultPatternInfoPanelCode && window.config.defaultPatternInfoPanelCode === "<<type>>",
4+
default:
5+
window.config.defaultPatternInfoPanelCode &&
6+
window.config.defaultPatternInfoPanelCode === '<<type>>',
57
templateID: 'pl-panel-template-code',
68
httpRequest: true,
79
httpRequestReplace: '.<<type>>',
810
httpRequestCompleted: false,
911
prismHighlight: true,
10-
language: '<<type>>'//,
12+
language: '<<type>>', //,
1113
/* TODO: We would need to find a way to enable keyCombo for multiple panels
1214
keyCombo: 'ctrl+shift+z',*/
1315
});

packages/uikit-workshop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"mini-css-extract-plugin": "^0.8.0",
100100
"mousetrap": "^1.6.3",
101101
"no-emit-webpack-plugin": "^1.0.0",
102-
"node-sass": "^4.13.0",
102+
"node-sass": "^4.14.1",
103103
"node-sass-selector-importer": "^5.2.0",
104104
"penthouse": "^2.2.2",
105105
"postcss-loader": "^3.0.0",

packages/uikit-workshop/src/scripts/components/panels.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ function init(event) {
6868
Panels.add({
6969
id: 'pl-panel-pattern',
7070
name: window.config.patternExtension.toUpperCase(),
71-
default: !window.config.defaultPatternInfoPanelCode ||
72-
window.config.defaultPatternInfoPanelCode ===
73-
window.config.patternExtension,
71+
default:
72+
!window.config.defaultPatternInfoPanelCode ||
73+
window.config.defaultPatternInfoPanelCode ===
74+
window.config.patternExtension,
7475
templateID: 'pl-panel-template-code',
7576
httpRequest: true,
7677
httpRequestReplace: fileSuffixPattern,
@@ -83,7 +84,7 @@ function init(event) {
8384
Panels.add({
8485
id: 'pl-panel-html',
8586
name: 'HTML',
86-
default: false,
87+
default: window.config.defaultPatternInfoPanelCode && window.config.defaultPatternInfoPanelCode === 'html',
8788
templateID: 'pl-panel-template-code',
8889
httpRequest: true,
8990
httpRequestReplace: fileSuffixMarkup + '.html',

packages/uikit-workshop/src/scripts/components/pl-nav/pl-nav.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ import { NavItem } from './src/NavItem';
2020
class Nav extends BaseComponent {
2121
static is = 'pl-nav';
2222

23-
constructor(self) {
24-
self = super(self);
25-
self.toggleNavPanel = self.toggleNavPanel.bind(self);
26-
self.toggleSpecialNavPanel = self.toggleSpecialNavPanel.bind(self);
27-
self.handleClick = self.handleClick.bind(self);
28-
self.handleURLChange = self.handleURLChange.bind(self);
29-
self.handlePageClick = self.handlePageClick.bind(self);
30-
self._hasInitiallyRendered = false;
31-
self.receiveIframeMessage = self.receiveIframeMessage.bind(self);
32-
self.useShadow = false;
33-
return self;
23+
constructor() {
24+
super();
25+
this.toggleNavPanel = this.toggleNavPanel.bind(this);
26+
this.toggleSpecialNavPanel = this.toggleSpecialNavPanel.bind(this);
27+
this.handleClick = this.handleClick.bind(this);
28+
this.handleURLChange = this.handleURLChange.bind(this);
29+
this.handlePageClick = this.handlePageClick.bind(this);
30+
this._hasInitiallyRendered = false;
31+
this.receiveIframeMessage = this.receiveIframeMessage.bind(this);
32+
this.useShadow = false;
3433
}
3534

3635
handlePageClick(e) {

packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,28 @@ import { BaseComponent } from '../base-component';
1717
class Search extends BaseComponent {
1818
static is = 'pl-search';
1919

20-
constructor(self) {
21-
self = super(self);
22-
self.useShadow = false;
23-
self.defaultMaxResults = 10;
20+
constructor() {
21+
super();
22+
this.useShadow = false;
23+
this.defaultMaxResults = 10;
2424

2525
// Autosuggest is a controlled component.
2626
// This means that you need to provide an input value
2727
// and an onChange handler that updates this value (see below).
2828
// Suggestions also need to be provided to the Autosuggest,
2929
// and they are initially empty because the Autosuggest is closed.
30-
self.state = {
30+
this.state = {
3131
value: '',
3232
suggestions: [],
3333
isFocused: false,
3434
};
3535

36-
self.receiveIframeMessage = self.receiveIframeMessage.bind(self);
37-
self.onChange = self.onChange.bind(self);
38-
self.toggleSearch = self.toggleSearch.bind(self);
39-
self.closeSearch = self.closeSearch.bind(self);
40-
self.renderInputComponent = self.renderInputComponent.bind(self);
41-
self.openSearch = self.openSearch.bind(self);
42-
return self;
36+
this.receiveIframeMessage = this.receiveIframeMessage.bind(this);
37+
this.onChange = this.onChange.bind(this);
38+
this.toggleSearch = this.toggleSearch.bind(this);
39+
this.closeSearch = this.closeSearch.bind(this);
40+
this.renderInputComponent = this.renderInputComponent.bind(this);
41+
this.openSearch = this.openSearch.bind(this);
4342
}
4443

4544
connecting() {
@@ -61,10 +60,9 @@ class Search extends BaseComponent {
6160
}
6261

6362
connected() {
64-
const self = this;
6563
Mousetrap.bind('command+shift+f', function(e) {
6664
e.preventDefault();
67-
self.toggleSearch();
65+
this.toggleSearch();
6866
});
6967
window.addEventListener('message', this.receiveIframeMessage, false);
7068
}

packages/uikit-workshop/src/scripts/lit-components/pl-drawer/pl-drawer.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import styles from './pl-drawer.scss?external';
1111

1212
@customElement('pl-drawer')
1313
class Drawer extends LitElement {
14-
constructor(self) {
15-
self = super(self);
16-
self.onMouseDown = self.onMouseDown.bind(self); // fix bindings so "self" works properly
17-
self.onMouseUp = self.onMouseUp.bind(self); // fix bindings so "self" works properly
18-
self.onMouseMove = self.onMouseMove.bind(self); // fix bindings so "this" works properly
19-
return self;
14+
constructor() {
15+
super();
16+
this.onMouseDown = this.onMouseDown.bind(this); // fix bindings so "this" works properly
17+
this.onMouseUp = this.onMouseUp.bind(this); // fix bindings so "this" works properly
18+
this.onMouseMove = this.onMouseMove.bind(this); // fix bindings so "this" works properly
2019
}
2120

2221
connectedCallback() {

0 commit comments

Comments
 (0)