Skip to content

Commit

Permalink
fix(config): Import all themes if user botched included themes
Browse files Browse the repository at this point in the history
Previously it only imported the 'default', which might not be the theme the user expects.
  • Loading branch information
knownasilya committed Nov 14, 2017
1 parent 47877c7 commit 691edb9
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,34 @@ module.exports = {
importThemes: function(app) {
var projectConfig = this.project.config(app.env);
var config = projectConfig['ember-toggle'] || {};
var excludeBaseStyles = config.excludeBaseStyles || false;
var allThemes = ['light', 'ios', 'default', 'flat', 'skewed', 'flip', 'material'];
var included = config.includedThemes;
var excluded = config.excludedThemes;
var themes = [];
var excludeBaseStyles = false;

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

excludeBaseStyles = config.excludeBaseStyles || false;

if (included && Array.isArray(included)) {
themes = themes.concat(included);
}
else {
themes = allThemes;
}

if (excluded && Array.isArray(excluded)) {
themes = themes.filter(function (theme) {
return excluded.indexOf(theme) === -1;
});
}
if (included && Array.isArray(included)) {
themes = themes.concat(included);
} else {
themes = allThemes;
}

if (excluded && Array.isArray(excluded)) {
themes = themes.filter(function (theme) {
return theme && allThemes.indexOf(theme) !== -1;
return excluded.indexOf(theme) === -1;
});
}

themes = themes.filter(function (theme) {
return theme && allThemes.indexOf(theme) !== -1;
});

if (!excludeBaseStyles) {
app.import('vendor/ember-toggle/base.css');
}

themes = themes.length ? themes : ['default'];
// Include all themes if user incorrectly specified themes in the config
themes = themes.length ? themes : allThemes;

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

0 comments on commit 691edb9

Please sign in to comment.