Skip to content

Commit

Permalink
Add serialized configuration to index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannu Pelkonen committed Apr 13, 2015
1 parent 0655e33 commit 139a76d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
10 changes: 2 additions & 8 deletions lib/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" href="assets/img/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
var _styleguideConfig = {{{styleguideConfig}}};
(function() {
'use strict';
var userStyleFiles = [
Expand All @@ -25,17 +26,10 @@
head.appendChild(link);
}

{{#disableEncapsulation}}
// Always use "global" styles
userStyleFiles.forEach(addCssLink);
{{/disableEncapsulation}}

{{^disableEncapsulation}}
// Use Shadow DOM but fallback to global styles if shadow DOM is not supported
if (typeof head.createShadowRoot !== 'function') {
if (typeof head.createShadowRoot !== 'function' || _styleguideConfig.disableEncapsulation) {
userStyleFiles.forEach(addCssLink);
}
{{/disableEncapsulation}}

addCssLink('{{{appRoot}}}/styleguide_at_rules.css');
addCssLink('{{{appRoot}}}/css/app.css', {noReload: true});
Expand Down
2 changes: 1 addition & 1 deletion lib/styleguide.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ module.exports.generate = function(options) {
.pipe(mustache({
title: opt.title,
extraHead: opt.extraHead,
disableEncapsulation: opt.disableEncapsulation,
styleguideConfig: JSON.stringify(copyUsedOptionsToJsonConfig(opt, {}).config),
appRoot: opt.appRoot,
socketIo: opt.server,
filesConfig: JSON.stringify(opt.filesConfig)
Expand Down
3 changes: 3 additions & 0 deletions test/integration/structure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ describe('index.html', function() {
expect(indexHtml.contents.toString()).to.contain('var filesConfig = []');
});

it('should contain serialized styleguide configuration', function() {
expect(indexHtml.contents.toString()).to.contain('var _styleguideConfig = {"appRoot":"/my-styleguide-book"');
});
});

describe('styleguide_pseudo_styles.css', function() {
Expand Down

0 comments on commit 139a76d

Please sign in to comment.