-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: prefix animation names #2621
Conversation
f35e7c6
to
6b35af3
Compare
e2055c9
to
5e4c591
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple small things but looks great!
src/plugins/animation.js
Outdated
const keyframesStyles = _.mapKeys(keyframesConfig, (_keyframes, name) => `@keyframes ${name}`) | ||
const keyframesStyles = _.mapKeys( | ||
keyframesConfig, | ||
(_keyframes, name) => `@keyframes ${prefix === undefined ? name : [prefix, name].join('')}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin API provides a prefix
function you can probably use here instead of adding it manually (passed in like theme, variants, etc), probably better because prefix
can technically be a function for weird advanced use cases. I worry it might be expecting a class though, so you may need to do something gross like prefix(
.${name}).slice(1)
to sort of trick it into looking like a class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this existed as well. Turns out we are using an invokePlugin
which is a specific implementation in the tests which doesn't expose all those values. 😬
5e4c591
to
d3af2e5
Compare
This PR adds an animation string parser, for example
This:
"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"
Can be parsed as:
This is useful so that we can run user defined animations through this function so that we can get the animation name. We then can apply the prefix to the animation name. For example
ping
could becometw-ping
. Useful for codebases that require a prefix and don't like the globalping
name.The second commit allows us to do the prefixing of animation
values
.A prefix of
tw-
will generate:No prefix will result in: