Skip to content

Commit

Permalink
Fix default theme if none specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Jul 21, 2015
1 parent 4e30133 commit a38c9ce
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
module.exports = {
name: 'ember-cli-toggle',

included: function(app) {
app.import('vendor/ember-cli-toggle/base.css');
included: function(app, parentAddon) {
var target = (parentAddon || app);

target.import('vendor/ember-cli-toggle/base.css');

// Use configuration to decide which theme css files
// to import, thus not populating the user's app
this.importThemes(app);
this.importThemes(target);
},

importThemes: function(app) {
var projectConfig = this.project.config(app.env);
var config = projectConfig['ember-cli-toggle'];
var themes = [];

if (config) {
var allThemes = ['light', 'ios', 'default', 'flat', 'skewed', 'flip'];
var included = config.includedThemes;
var excluded = config.excludedThemes;
var themes = [];

if (included && Array.isArray(included)) {
themes = themes.concat(included);
Expand All @@ -38,11 +40,13 @@ module.exports = {
themes = themes.filter(function (theme) {
return theme && allThemes.indexOf(theme) !== -1;
});

themes.forEach(function (theme) {
app.import('vendor/ember-cli-toggle/themes/' + theme + '.css');
});
}

themes = themes.length ? themes : ['default'];

themes.forEach(function (theme) {
app.import('vendor/ember-cli-toggle/themes/' + theme + '.css');
});
}
};

0 comments on commit a38c9ce

Please sign in to comment.