tailwindcss/packages
Robin Malfait 3fb49bb0ee
Fix theme(…/15%) to only apply when used on its own (#14922)
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.

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2024-11-08 16:05:30 +00:00
..
@tailwindcss-cli Optimize generated CSS output (#14873) 2024-11-06 11:39:09 +00:00
@tailwindcss-node Rewrite urls in CSS files when using Vite (#14877) 2024-11-07 09:51:58 -05:00
@tailwindcss-postcss Rename --letter-spacing-* variables to --tracking-* (#14921) 2024-11-08 17:02:47 +01:00
@tailwindcss-standalone Prepare v4.0.0-alpha.31 release (#14823) 2024-10-30 07:53:51 -04:00
@tailwindcss-upgrade Fix theme(…/15%) to only apply when used on its own (#14922) 2024-11-08 16:05:30 +00:00
@tailwindcss-vite Apply non-Tailwind CSS transforms in Vite plugin (#14871) 2024-11-07 16:26:18 +01:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Rename --letter-spacing-* variables to --tracking-* (#14921) 2024-11-08 17:02:47 +01:00
tsconfig.base.json introduce v4 codebase 2024-03-05 14:29:15 +01:00