mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Certain plugins behave differently and the rules about `default` meaning "no suffix" are not universal (see the cursor plugin). The simplest thing to do right now is keep things as they are, which means only certain plugins respect the default option and only certain other plugins respect the negative prefix convention.
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import _ from 'lodash'
|
|
import prefixNegativeModifiers from '../util/prefixNegativeModifiers'
|
|
|
|
export default function() {
|
|
return function({ addUtilities, e, theme, variants }) {
|
|
const generators = [
|
|
(size, modifier) => ({
|
|
[`.${e(prefixNegativeModifiers('m', modifier))}`]: { margin: `${size}` },
|
|
}),
|
|
(size, modifier) => ({
|
|
[`.${e(prefixNegativeModifiers('my', modifier))}`]: {
|
|
'margin-top': `${size}`,
|
|
'margin-bottom': `${size}`,
|
|
},
|
|
[`.${e(prefixNegativeModifiers('mx', modifier))}`]: {
|
|
'margin-left': `${size}`,
|
|
'margin-right': `${size}`,
|
|
},
|
|
}),
|
|
(size, modifier) => ({
|
|
[`.${e(prefixNegativeModifiers('mt', modifier))}`]: { 'margin-top': `${size}` },
|
|
[`.${e(prefixNegativeModifiers('mr', modifier))}`]: { 'margin-right': `${size}` },
|
|
[`.${e(prefixNegativeModifiers('mb', modifier))}`]: { 'margin-bottom': `${size}` },
|
|
[`.${e(prefixNegativeModifiers('ml', modifier))}`]: { 'margin-left': `${size}` },
|
|
}),
|
|
]
|
|
|
|
const utilities = _.flatMap(generators, generator => {
|
|
return _.flatMap(theme('margin'), generator)
|
|
})
|
|
|
|
addUtilities(utilities, variants('margin'))
|
|
}
|
|
}
|