forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextColor.js
More file actions
33 lines (27 loc) · 874 Bytes
/
Copy pathtextColor.js
File metadata and controls
33 lines (27 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import _ from 'lodash'
import flattenColorPalette from '../util/flattenColorPalette'
import withAlphaVariable from '../util/withAlphaVariable'
export default function() {
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
const colors = flattenColorPalette(theme('textColor'))
const getProperties = value => {
if (target('textColor') === 'ie11') {
return { color: value }
}
if (corePlugins('textOpacity')) {
return withAlphaVariable({
color: value,
property: 'color',
variable: '--text-opacity',
})
}
return { color: value }
}
const utilities = _.fromPairs(
_.map(colors, (value, modifier) => {
return [`.${e(`text-${modifier}`)}`, getProperties(value)]
})
)
addUtilities(utilities, variants('textColor'))
}
}