-
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
Add codemod for migrating @variants
and @responsive
directives
#14748
Add codemod for migrating @variants
and @responsive
directives
#14748
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @RobinMalfait and the rest of your teammates on Graphite |
@variants
and @responsive
@variants
and @responsive
directives
329126b
to
14e1cac
Compare
The confusing part here is that if you use @variants hover {
.foo {
color: red;
}
} If you then use it in your html as: <div class="hover:foo focus:foo foo">hello world</div> Then the following CSS is being generated: .foo {
color: red;
}
.hover\:foo:hover {
color: red;
}
.focus\:foo:focus {
color: red;
} Which means that the |
@RobinMalfait Ah, yeah, I think you're right we should migrate this to |
Haha yeah that is a bit confusing. In v2 we generated everything ahead-of-time, and later introduced the just-in-time in v3. So in v2 we needed that information to generate all the CSS. |
f677933
to
a2d0425
Compare
packages/@tailwindcss-upgrade/src/codemods/migrate-tailwind-directives.test.ts
Outdated
Show resolved
Hide resolved
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.
Need to add the migrateVariantsDirective
rule to the defaults now 🙈 Let's add a full integration test to make sure it indeed works
c0bf210
to
13a8a63
Compare
Should be good to go now |
Merge activity
|
…14748) This PR migrates the `@variants` and `@responsive` directives. In Tailwind CSS v2, these were used to generate certain variants of responsive variants for the give classes. In Tailwind CSS v3, these still worked but were implemented as a no-op such that these directives don't end up in your final CSS. In Tailwind CSS v4, these don't exist at all anymore, so we can safely get rid of them by replacing them with their contents. Input: ```css @Variants hover, focus { .foo { color: red; } } @Responsive { .bar { color: blue; } } ``` Output: ```css .foo { color: red; } .bar { color: blue; } ```
13a8a63
to
5bf2efb
Compare
This PR migrates the
@variants
and@responsive
directives.In Tailwind CSS v2, these were used to generate certain variants of responsive variants for the give classes. In Tailwind CSS v3, these still worked but were implemented as a no-op such that these directives don't end up in your final CSS.
In Tailwind CSS v4, these don't exist at all anymore, so we can safely get rid of them by replacing them with their contents.
Input:
Output: