mirror of
https://github.com/hanzoai/tailwindcss.git
synced 2026-09-24 17:03:14 +00:00
24 lines
799 B
JavaScript
24 lines
799 B
JavaScript
import identity from 'lodash/identity'
|
|
import fromPairs from 'lodash/fromPairs'
|
|
import toPairs from 'lodash/toPairs'
|
|
import castArray from 'lodash/castArray'
|
|
import nameClass from './nameClass'
|
|
|
|
export default function createUtilityPlugin(themeKey, utilityVariations) {
|
|
return function ({ addUtilities, variants, theme }) {
|
|
const utilities = utilityVariations.map(
|
|
([classPrefix, properties, transformValue = identity]) => {
|
|
return fromPairs(
|
|
toPairs(theme(themeKey)).map(([key, value]) => {
|
|
return [
|
|
nameClass(classPrefix, key),
|
|
fromPairs(castArray(properties).map((property) => [property, transformValue(value)])),
|
|
]
|
|
})
|
|
)
|
|
}
|
|
)
|
|
return addUtilities(utilities, variants(themeKey))
|
|
}
|
|
}
|