Simplifying animation utilities generation (#2606)

This commit is contained in:
Twentylives 2020-10-18 22:44:10 +03:00 • committed by GitHub
parent 44f2c54605
commit a2337e6cc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,23 +4,13 @@ import nameClass from '../util/nameClass'
export default function () {
return function ({ addUtilities, theme, variants }) {
const keyframesConfig = theme('keyframes')
const keyframesStyles = _.fromPairs(
_.toPairs(keyframesConfig).map(([name, keyframes]) => {
return [`@keyframes ${name}`, keyframes]
})
)
const keyframesStyles = _.mapKeys(keyframesConfig, (_keyframes, name) => `@keyframes ${name}`)
addUtilities(keyframesStyles, { respectImportant: false })
const animationConfig = theme('animation')
const utilities = _.fromPairs(
_.toPairs(animationConfig).map(([suffix, animation]) => {
return [
nameClass('animate', suffix),
{
animation,
},
]
})
const utilities = _.mapValues(
_.mapKeys(animationConfig, (_animation, suffix) => nameClass('animate', suffix)),
(animation) => ({ animation })
)
addUtilities(utilities, variants('animation'))
}