tailwindcss/src/plugins/textColor.js

33 lines
983 B
JavaScript
Raw Normal View History

2019-01-09 13:11:27 -05:00
import _ from 'lodash'
import flattenColorPalette from '../util/flattenColorPalette'
import withAlphaVariable from '../util/withAlphaVariable'
2019-01-09 13:11:27 -05:00
2019-02-28 12:36:18 -05:00
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
2020-04-28 15:31:57 -04:00
if (target('textColor') === 'ie11') {
2020-04-26 15:10:12 -04:00
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('textColor')), (value, modifier) => {
return [`.${e(`text-${modifier}`)}`, { color: value }]
})
)
addUtilities(utilities, variants('textColor'))
return
}
2019-01-11 12:29:33 -05:00
const utilities = _.fromPairs(
_.map(flattenColorPalette(theme('textColor')), (value, modifier) => {
2019-01-11 12:29:33 -05:00
return [
`.${e(`text-${modifier}`)}`,
corePlugins('textOpacity')
? withAlphaVariable({ color: value, property: 'color', variable: '--text-opacity' })
: { color: value },
2019-01-11 12:29:33 -05:00
]
})
)
2019-01-09 13:11:27 -05:00
addUtilities(utilities, variants('textColor'))
2019-01-09 13:11:27 -05:00
}
}