2020-11-09 16:39:49 -05:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
|
|
|
|
import nameClass from '../util/nameClass'
|
2020-11-13 19:41:08 -05:00
|
|
|
import withAlphaVariable from '../util/withAlphaVariable'
|
2020-11-09 16:39:49 -05:00
|
|
|
|
|
|
|
|
export default function () {
|
|
|
|
|
return function ({ addUtilities, theme, variants }) {
|
|
|
|
|
const colors = flattenColorPalette(theme('ringColor'))
|
2020-11-13 19:41:08 -05:00
|
|
|
|
|
|
|
|
const getProperties = (value) => {
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
2020-11-16 17:45:55 +01:00
|
|
|
property: '--tw-ring-color',
|
|
|
|
|
variable: '--tw-ring-opacity',
|
2020-11-13 19:41:08 -05:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 16:39:49 -05:00
|
|
|
const utilities = _.fromPairs(
|
|
|
|
|
_.map(_.omit(colors, 'DEFAULT'), (value, modifier) => {
|
2020-11-13 19:41:08 -05:00
|
|
|
return [nameClass('ring', modifier), getProperties(value)]
|
2020-11-09 16:39:49 -05:00
|
|
|
})
|
|
|
|
|
)
|
2020-11-13 19:41:08 -05:00
|
|
|
|
2020-11-09 16:39:49 -05:00
|
|
|
addUtilities(utilities, variants('ringColor'))
|
|
|
|
|
}
|
|
|
|
|
}
|