-
Notifications
You must be signed in to change notification settings - Fork 3
/
helpers.js
48 lines (44 loc) 路 1.23 KB
/
helpers.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
module.exports = {
prefix: {
get(property, ...prefixes) {
return prefixes.map(pfx => `${pfx}-${property}`);
},
all(property, ...prefixes) {
return [property, ...this.get(property, ...prefixes)];
}
},
midfix: {
get(property, ...midfixes) {
const holder = property.split('-');
const last = holder.pop();
return midfixes.map(mdfx => `${holder.join('-')}${holder.length > 0 ? '-' : ''}${mdfx}-${last}`);
},
all(property, ...prefixes) {
return [property, ...this.get(property, ...prefixes)];
}
},
suffix: {
get(property, ...suffixes) {
return suffixes.map(sffx => `${property}-${sffx}`);
},
all(property, ...suffixes) {
return [property, ...this.get(property, ...suffixes)];
}
},
trbl(property) {
const rules = [];
let prop = '';
if (property) {
rules.push(property);
prop = `${property}-`;
}
return rules.concat([`${prop}top`, `${prop}right`, `${prop}bottom`, `${prop}left`]);
},
border() {
const borderDesc = ['width', 'style', 'color'];
const borderExtend = this.trbl('border')
.map(value => this.suffix.all(value, ...borderDesc))
.reduce((a, b) => a.concat(b));
return borderExtend;
}
};