mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
32 lines
939 B
JavaScript
32 lines
939 B
JavaScript
import _ from 'lodash'
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
|
import nameClass from '../util/nameClass'
|
|
import toColorValue from '../util/toColorValue'
|
|
import withAlphaVariable from '../util/withAlphaVariable'
|
|
|
|
export default function () {
|
|
return function ({ addUtilities, theme, variants, corePlugins }) {
|
|
const colors = flattenColorPalette(theme('placeholderColor'))
|
|
|
|
const getProperties = (value) => {
|
|
if (corePlugins('placeholderOpacity')) {
|
|
return withAlphaVariable({
|
|
color: value,
|
|
property: 'color',
|
|
variable: '--placeholder-opacity',
|
|
})
|
|
}
|
|
|
|
return { color: toColorValue(value) }
|
|
}
|
|
|
|
const utilities = _.fromPairs(
|
|
_.map(colors, (value, modifier) => {
|
|
return [`${nameClass('placeholder', modifier)}::placeholder`, getProperties(value)]
|
|
})
|
|
)
|
|
|
|
addUtilities(utilities, variants('placeholderColor'))
|
|
}
|
|
}
|