Skip to content
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

Fix theme(…/15%) to only apply when used on its own #14922

Merged
merged 5 commits into from
Nov 8, 2024

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue where our codemod migrations can convert bg-[theme(colors.white/15%)] to bg-[var(--color-white)]/15 where the 15% from within the theme(…) is converted to a candidate modifier (at the end).

The idea was that if the theme(…) is used with a modifier, then it can only be used with colors. If a candidate uses it, it also means that a color was used and we can use /15 instead.

However this is not true if it is used as part of a bigger value. E.g.: shadow-[shadow:inset_0_0_0_1px_theme(colors.white/15%)] would be converted to shadow-[inset_0_0_0_1px_var(--color-white)]/15 which is not correct because the value isn't a color, the color is part of the value.

In this case, we make sure that the theme(…) is the only AST node in the value, and if it is we can safely do the conversion. If there are other AST nodes we keep the theme(…) call.

@RobinMalfait RobinMalfait requested a review from a team as a code owner November 8, 2024 15:50
CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
@RobinMalfait RobinMalfait enabled auto-merge (squash) November 8, 2024 15:56
@RobinMalfait RobinMalfait merged commit 3fb49bb into next Nov 8, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the fix/shadow-theme-to-var-migration branch November 8, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants