tailwindcss/src/plugins/textColor.js

19 lines
574 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 }) {
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}`)}`,
withAlphaVariable({ color: value, property: 'color', variable: '--text-opacity' }),
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
}
}