Repository navigation
Conversation
Contributor
|
@Maliik-B 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: 6b8c480 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 |
3 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue or discussion
Fixes #3950.
What this changes
The
color-mix()conversion insanitizeDeclarationsmoves into its own function,resolveDerivedColors, whichsanitizeDeclarationsstill calls andmakeInlineStylesFornow also runs on each value it resolved.Inside it:
bg-[#ff000080]/50gets one alpha (0.25098039215686274) instead of a fifth value.color-mix()with two literal percentages becomes onergb().color-mix()whose percentage is still a variable, likevar(--tw-shadow-alpha), is left for the inline step instead of getting the variable appended.oklab(from rgb(…) l a b / <percentage>), which Tailwind writes for the default color ofshadow-lg/20, torgb()with that percentage as the alpha. The same goes forinset-,text-anddrop-shadow-*/NN.The inline step is what fixes shadow colors.
--tw-shadow-alphais set per element (shadow-lg/20sets20%), so the percentage is only known there.shadow-red-500/40now inlinesrgb(251,44,54,0.4),shadow-lg/20 shadow-red-500/40gives0.08, andshadow-red-500givesrgb(251,44,54)instead of100%. Without the inline call, every colored shadow would stay acolor-mix(). Sent to Gmail (web and Android), the output keeps the element'sstyle.The inline step runs only this function, not all of
sanitizeDeclarationsas the fallback branch above it does: the values it resolves have already been through the stylesheet pass, and the full pass cost about four times as much. As it is, it adds about 5 to 10% render time for colored shadows and none for other classes."works with shadows" now inlines
rgb(85,85,85)instead ofrgb(85,85,85,100%), the shadow case #3579 left out. No other existing test changes.This and #3933 both touch
makeInlineStylesFor(the declaration loop here,resolveValuethere); it merges cleanly with #3933 and with #3937.Not addressed
rgb()when the email is built still leave acolor-mix(), which Gmail strips with the element's other styles:currentandtransparentwith an opacity (bg-current/40), and an opacity variable the element doesn't set (bg-red-500/(--o)with--oon a parent). For that last one this is a change:canarygavergb(251,44,54,var(--o)), which loses only the color in Gmail. These go to one follow-up issue.shadow-[0_0_4px_red]/50) still leavesoklab(from red …).<style>rules (hover:,md:), avar()fallback isn't converted, so variant shadows keeprgb(0 0 0 / 0.1)andoklab(from …); that reaches past shadows and gets its own issue.Tests
sanitizeDeclarations: nestedcolor-mix()opacities multiply into one alpha; a relativeoklab()with a percentage alpha is converted and five near misses are left as written.<Tailwind>: an alpha shadow color, a shadow color with an opacity under a shadow opacity, and an alpha background with an opacity come out as plainrgb();shadow-lg/20comes out asrgb(0,0,0,0.2).canary.pnpm lintandpnpm typecheckpass; the package tests pass except two react-email CLI specs that fail oncanaryon Windows too.AI disclosure: written with Claude's help. I reviewed the change and the tests before opening this.
Checklist
Summary by cubic
Fixes Tailwind shadow colors with an opacity modifier (
shadow-red-500/40,shadow-lg/20) so they render as a plainrgb()in the element's inline style instead of acolor-mix()function, which Gmail strips.Bug Fixes
color-mix()conversion fromsanitizeDeclarationsintoresolveDerivedColorsand runs it during the inline step, where per-element values like--tw-shadow-alphaare known.color-mix()opacities into a single alpha, sobg-[#ff000080]/50no longer produces a fifth value.oklab(from rgb(...) l a b / <percentage>)— the form Tailwind emits for the default shadow color inshadow-lg/20— intorgb()with that percentage as alpha.rgb()at build time, liketransparentorcurrentwith an opacity, still leave acolor-mix().Written for commit 6b8c480. Summary will update on new commits.