-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflex-gaps.js
35 lines (29 loc) · 898 Bytes
/
flex-gaps.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
// ####################################
// ##### FLEX GAPS (TAILWIND PLUGIN)
// ####################################
const sizes = [ 'px', '2px', 0, 1, 2, 3, 4, 5, 6 ].map(x => x.toString())
module.exports = function({ addUtilities, config }) {
const utilities = {}
const margins = config('theme.margin')
sizes.forEach(x => {
// COL (good for flex-row)
utilities[`.flex-cg-${x}`] = {
'margin-left': `-${margins[x]}`,
'margin-right': `-${margins[x]}`,
},
utilities[`.flex-cg-${x} > *`] = {
'margin-left': margins[x],
'margin-right': margins[x]
},
// ROW (good for flex-col)
utilities[`.flex-rg-${x}`] = {
'margin-top': `-${margins[x]}`,
'margin-bottom': `-${margins[x]}`,
},
utilities[`.flex-rg-${x} > *`] = {
'margin-top': margins[x],
'margin-bottom': margins[x]
}
})
addUtilities(utilities)
}