forked from lucky-media/cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexgap.js
25 lines (23 loc) · 792 Bytes
/
flexgap.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
const plugin = require("tailwindcss/plugin");
const half = (value) => {
return value.replace(/\d+(.\d+)?/, (number) => number / 1);
};
module.exports = plugin.withOptions(function () {
return function ({ addUtilities, e, theme, variants }) {
Object.entries(theme("gap")).forEach(([key, value]) =>
addUtilities(
{
[`.flex-gap-${e(key)}`]: {
marginTop: `-${half(value)}`,
marginLeft: `-${half(value)}`,
"& > *": {
marginTop: half(value),
marginLeft: half(value),
},
},
},
variants("gap")
)
);
};
});