mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* prefix custom properties with tw- * prefix custom properties with tw- in tests * prefix gradient values in the defaultConfig * inline gradient-via-color * simplify --tw-tailwind-empty to --tw-empty * replace the long --tw-font-variant-numeric-... to the way shorter --tw-fvn-... * Rename --tw-box-shadow to --tw-shadow To match class name. * Rename font-variant-numeric variables * Remove 'transform' from transform variables * Shorten gradient variables * Fix style Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
32 lines
927 B
JavaScript
32 lines
927 B
JavaScript
import _ from 'lodash'
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
|
import withAlphaVariable from '../util/withAlphaVariable'
|
|
import toColorValue from '../util/toColorValue'
|
|
import nameClass from '../util/nameClass'
|
|
|
|
export default function () {
|
|
return function ({ addUtilities, theme, variants, corePlugins }) {
|
|
const colors = flattenColorPalette(theme('backgroundColor'))
|
|
|
|
const getProperties = (value) => {
|
|
if (corePlugins('backgroundOpacity')) {
|
|
return withAlphaVariable({
|
|
color: value,
|
|
property: 'background-color',
|
|
variable: '--tw-bg-opacity',
|
|
})
|
|
}
|
|
|
|
return { 'background-color': toColorValue(value) }
|
|
}
|
|
|
|
const utilities = _.fromPairs(
|
|
_.map(colors, (value, modifier) => {
|
|
return [nameClass('bg', modifier), getProperties(value)]
|
|
})
|
|
)
|
|
|
|
addUtilities(utilities, variants('backgroundColor'))
|
|
}
|
|
}
|