-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
65 lines (60 loc) · 1.59 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
const _ = require('lodash');
module.exports = function(options = {}) {
return ({ config, e, addVariant, addUtilities }) => {
const defaultOptions = {
empty: true,
};
options = _.merge({}, defaultOptions, options);
const defaultEmptyVariants = [];
const defaultPseudoTheme = {
'before': 'before',
'after': 'after',
};
const pseudoElements = [
'-moz-progress-bar',
'-moz-range-progress',
'-moz-range-thumb',
'-moz-range-track',
'-ms-browse',
'-ms-check',
'-ms-clear',
'-ms-expand',
'-ms-fill',
'-ms-fill-lower',
'-ms-fill-upper',
'-ms-reveal',
'-ms-thumb',
'-ms-ticks-after',
'-ms-ticks-before',
'-ms-tooltip',
'-ms-track',
'-ms-value',
'-webkit-progress-bar',
'-webkit-progress-value',
'-webkit-slider-runnable-track',
'-webkit-slider-thumb',
'after',
'backdrop',
'before',
'cue',
'first-letter',
'first-line',
'grammar-error',
'placeholder',
'selection',
'spelling-error',
];
_.each(config('theme.pseudo', defaultPseudoTheme), (modifier, selector) => {
addVariant(selector, ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`${selector}${separator}${className}`)}${pseudoElements.includes(modifier) ? '::' : ':'}${modifier}`;
});
});
});
if (options.empty) {
addUtilities({
'.empty': { 'content': `''` }
}, config('variants.empty', defaultEmptyVariants));
}
};
};