forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnegativeMargin.js
More file actions
29 lines (26 loc) · 1.05 KB
/
negativeMargin.js
File metadata and controls
29 lines (26 loc) · 1.05 KB
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
import _ from 'lodash'
export default function() {
return function({ addUtilities, e, config }) {
const generators = [
(size, modifier) => ({
[`.${e(`-m-${modifier}`)}`]: { margin: `${size}` },
}),
(size, modifier) => ({
[`.${e(`-my-${modifier}`)}`]: { 'margin-top': `${size}`, 'margin-bottom': `${size}` },
[`.${e(`-mx-${modifier}`)}`]: { 'margin-left': `${size}`, 'margin-right': `${size}` },
}),
(size, modifier) => ({
[`.${e(`-mt-${modifier}`)}`]: { 'margin-top': `${size}` },
[`.${e(`-mr-${modifier}`)}`]: { 'margin-right': `${size}` },
[`.${e(`-mb-${modifier}`)}`]: { 'margin-bottom': `${size}` },
[`.${e(`-ml-${modifier}`)}`]: { 'margin-left': `${size}` },
}),
]
const utilities = _.flatMap(generators, generator => {
return _.flatMap(config('theme.negativeMargin'), (size, modifier) => {
return generator(`${size}` === '0' ? `${size}` : `-${size}`, modifier)
})
})
addUtilities(utilities, config('variants.negativeMargin'))
}
}