forked from knownasilya/ember-toggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (55 loc) · 1.68 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
module.exports = {
name: require('./package').name,
included: function (app, parentAddon) {
var target = parentAddon || app;
// necessary for nested usage
// parent addon should call `this._super.included.apply(this, arguments);`
if (target.app) {
target = target.app;
}
this.app = target;
// Use configuration to decide which theme css files
// to import, thus not populating the user's app
this.importThemes(target);
this._super.included.apply(this, arguments);
},
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 = [];
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;
});
}
themes = themes.filter(function (theme) {
return theme && allThemes.indexOf(theme) !== -1;
});
if (!excludeBaseStyles) {
app.import('vendor/ember-toggle/base.css');
}
// 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');
});
},
};