-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Upgrade: Handle darkMode
value with block syntax
#16507
Upgrade: Handle darkMode
value with block syntax
#16507
Conversation
699b486
to
f4f9246
Compare
} | ||
} | ||
|
||
return output |
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.
Will this actually work with an array of format strings? @custom-variant
overrides
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.
ok i will be less lazy
if (variantName.includes('{')) { | ||
customVariant += variantName.replace('}', '{ @slot }}') + '\n' | ||
} else { | ||
customVariant += variantName + '{ @slot }\n' | ||
} |
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.
Not 100% if this is enough, can we add a few more test cases:
Nested media queries:
darkMode: ['variant', '@media not print { @media screen { .dark & } }'],
/* dark:flex */
@media not print {
@media screen {
.dark .dark\:flex {
display: flex;
}
}
}
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.
Here are few more fun ones: https://sourcegraph.com/search?q=context:global+%22darkMode:+%5B%27variant%27%22&patternType=keyword&sm=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.
I think this should work, we decided to go with the "replaces first closing brace with the slot stuff" in the addVariant API so this just makes sure whatever we create would be equivalent to running the compat layer at this point haha
Your specific example would convert to this which would work: https://play.tailwindcss.com/94rgXzHkCF
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.
Closes #16171
This PR handles
darkMode
variant configs containing braces (so creating sub-rules) the same way we handle it in the interop layer. Since the interop layer runs inside theaddVariant
API that we do not run here, I instead oped to copy the one liner.Test plan
Updated one of the migration tests to include a rule that wasn't working before. Ensured the new output works via https://play.tailwindcss.com/nR99uhKtv3