* implement matchUtilities2 * ensure animation names without keyframes are not prefixed * remove matchBase * call addUtilities for each group individually * WIP: Write plugins using matchUtilities2 * MORE * Fix arbitrary value support for fontSize * Fixes, update fixtures * Rebuild fixtures * Don't generate `divide` class with no modifier * Fixes, rebuild fixtures * Rename matchUtilities2 to matchUtilities * Delete bad tests * Remove temp files GROSS * Clean stuff up * Support no return in matchUtilities Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import parseAnimationValue from '../util/parseAnimationValue'
|
|
|
|
export default function () {
|
|
return function ({ matchUtilities, theme, variants, prefix }) {
|
|
let prefixName = (name) => prefix(`.${name}`).slice(1)
|
|
let keyframes = Object.fromEntries(
|
|
Object.entries(theme('keyframes')).map(([key, value]) => {
|
|
return [
|
|
key,
|
|
[
|
|
{
|
|
[`@keyframes ${prefixName(key)}`]: value,
|
|
},
|
|
{ respectVariants: false },
|
|
],
|
|
]
|
|
})
|
|
)
|
|
|
|
matchUtilities(
|
|
{
|
|
animate: (value, { includeRules }) => {
|
|
let { name: animationName } = parseAnimationValue(value)
|
|
|
|
if (keyframes[animationName] !== undefined) {
|
|
includeRules(keyframes[animationName], { respectImportant: false })
|
|
}
|
|
|
|
if (animationName === undefined || keyframes[animationName] === undefined) {
|
|
return { animation: value }
|
|
}
|
|
|
|
return {
|
|
animation: value.replace(animationName, prefixName(animationName)),
|
|
}
|
|
},
|
|
},
|
|
{ values: theme('animation'), variants: variants('animation') }
|
|
)
|
|
}
|
|
}
|