-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 933 Bytes
/
index.js
File metadata and controls
41 lines (33 loc) · 933 Bytes
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
export default class ModuleClass {
constructor(styles) {
this.styles = styles;
}
class() {
if (arguments.length < 1) {
return null;
} else if (arguments.length === 1) {
return this.styleExists(arguments[0]) ? this.styles[arguments[0]] : null;
} else if (arguments.length > 1) {
let classArray = [];
for (let argument of arguments) {
if (this.styleExists(argument)) {
classArray.push(this.styles[argument]);
}
}
return this.classArrayJoin(classArray);
}
}
compose() {
let classArray = [];
for (let argument of arguments) {
if (argument) classArray.push(argument);
}
return this.classArrayJoin(classArray);
}
styleExists(style) {
return typeof this.styles[style] === 'undefined' ? false : true;
}
classArrayJoin(classArray) {
return classArray.length > 0 ? classArray.join(' ').trim() : '';
}
}