-
Notifications
You must be signed in to change notification settings - Fork 0
/
padding.js
52 lines (46 loc) · 1.51 KB
/
padding.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
const _ = require("lodash");
module.exports = function(
{ addUtilities, e, theme, variants, config },
isEnabled
) {
const corePaddingConfig = config("corePlugins.padding");
if (isEnabled) {
const prefixObj = {
py: corePaddingConfig === false ? "pb" : "lpb",
px: corePaddingConfig === false ? "pi" : "lpi"
};
const globalPadding =
corePaddingConfig === false
? [
(size, modifier) => ({
[`.${e(`p-${modifier}`)}`]: { padding: `${size}` }
})
]
: [];
const generators = [
...globalPadding,
(size, modifier) => ({
[`.${e(`${prefixObj["py"]}-${modifier}`)}`]: {
"padding-block-start": `${size}`,
"padding-block-end": `${size}`,
"padding-block": `${size}`
},
[`.${e(`${prefixObj["px"]}-${modifier}`)}`]: {
"padding-inline-start": `${size}`,
"padding-inline-end": `${size}`,
"padding-inline": `${size}`
}
}),
(size, modifier) => ({
[`.${e(`pbs-${modifier}`)}`]: { "padding-block-start": `${size}` },
[`.${e(`pbe-${modifier}`)}`]: { "padding-block-end": `${size}` },
[`.${e(`pis-${modifier}`)}`]: { "padding-inline-start": `${size}` },
[`.${e(`pie-${modifier}`)}`]: { "padding-inline-end": `${size}` }
})
];
const utilities = _.flatMap(generators, generator => {
return _.flatMap(theme("padding"), generator);
});
addUtilities(utilities, variants("padding"));
}
};