-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support keyframes in JS theme config #14594
Conversation
@keyframes enter { | ||
from { | ||
opacity: var(--tw-enter-opacity, 1); | ||
transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0) scale3d(var(--tw-enter-scale, 1), var(--tw-enter-scale, 1), var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0)); | ||
} | ||
} | ||
@keyframes exit { | ||
to { | ||
opacity: var(--tw-exit-opacity, 1); | ||
transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0)); | ||
} | ||
} |
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.
Uh oh wait what.
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.
This is interesting, in v3, plugins require an addBase
to add the keyframes but if it was part of the JS config theme, it would be added automatically. That's lovely:
https://play.tailwindcss.com/YQLQchsWWW?file=config
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.
In v3 the way this worked was keyframes were not emitted until used. So you had to do @keyframes …
: theme('keyframes.whatever`) in your utility function. And we handle that already.
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.
Or we do in addUtilities at least. I don't think we do in matchUtilities which we should I think.
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.
Or at least I'm like 95% sure it works that way. Maybe we just de-duped them…
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.
Oh gotch you're right they're only added when used! If you use addBase
and use it with an animate-*
variable, it is emitted twice in v3 (at the end of the stylesheet).
I guess it's fine if we always emit keyframes for compat now (we do this for v4 keyframes too!). However unsure if we should then guard against this case. Maybe it's ok if the keyframes are emitted twice here since it does no harm? WDYT?
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.
yeah it's probably fine — would be nice to dedupe them but that can be an optimization done later. They should still be de-duped when minifying with lightingcss.
Adds support for defining
keyframes
via the v3 JS config file. E.g.: