Repository navigation
fix(tailwind): resolve var() fallbacks inside variable definitions - #3768
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
|
@deepanshupal is attempting to deploy a commit to the resend Team on Vercel. A member of the Team first needs to authorize it. |
馃 Changeset detectedLatest commit: 375e288 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution. The fix works when no element in the email sets a shadow or ring color. It does not work when one does: The card still renders Each element needs the default color unless that element sets its own. Can you fix that case and add a test for the two-element case? |
Use element-local variables and cloned rules to keep sibling colors isolated. Resolve missing colors from their fallback or registered initial value.
Fallbacks are now resolved using each element's inline rules instead of all classes in the render.
Remove the unused render-wide class argument; inline resolution now handles defaults per element.
Cover default colors beside color-only siblings, shared utilities on colored and default siblings, and conditional hover shadow colors. These three regressions fail on the previous PR head and pass with the per-element fix.
|
Moved nested variable resolution to inline time, using only each element's rules and a fresh rule clone. Defaults no longer depend on a sibling's color class or a hover color. Added regressions for the two-element shadow/ring case, colored and default siblings sharing utilities, and hover shadow colors. All three fail on the previous head and pass with this change. Full package suite: 303 tests passing; typecheck and Biome pass. |
The per-element rule clone is not needed, because resolveValue already builds a new tree. Declarations without var() now skip the parse and generate step.
commit: |
Closes #3767
<Tailwind>leftvar(--tw-shadow-color, rgb(0 0 0 / 0.1))andvar(--tw-ring-color, currentcolor)in the inline styles for the defaultshadow,shadow-md,shadow-lgandring-Nclasses. Email clients do not supportvar(), so they drop the whole declaration and the shadow or ring disappears.Tailwind v4 defines
--tw-shadowwith a nestedvar(). The variable resolver skips definitions when it collects uses, so the nestedvar()is copied into the inline style untouched.This resolves the fallback of any
var()inside a custom property definition when no rule for a class used in the render defines that variable. It runs before the downlevel step, so colours come out in comma syntax (rgb(0,0,0,0.1)).Only rules for the classes used in the current render count as definitions. The compiler is cached per config and keeps rules from earlier renders, so counting the whole sheet would make the result depend on render order.
Tests: added a spec for
shadow-md ring-2. It fails oncanaryand passes with the fix. The full package suite passes in file order (300 tests), and biome and tsc are clean. Patch changeset forreact-emailincluded.AI disclosure: this change was written with AI assistance (Claude), reviewed and tested locally by the submitter.
Summary by cubic
Fixes
<Tailwind>leavingvar(--tw-shadow-color, rgb(0 0 0 / 0.1))andvar(--tw-ring-color, currentcolor)in inline styles for the defaultshadow,shadow-md,shadow-lg, andring-Nclasses. Email clients don't supportvar(), so they drop the declaration and the shadow or ring disappears.var()inside a custom property definition when no rule used in the render defines that variable.var().rgb(0,0,0,0.1)).react-email.Written for commit 375e288. Summary will update on new commits.