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(tailwind): Media query escaped class names #1114

Merged
merged 4 commits into from
Mar 8, 2024

Conversation

gabrielmfern
Copy link
Collaborator

@gabrielmfern gabrielmfern commented Dec 26, 2023

This PR changes how the media query class names are kept by removing
escaping characters from them and replacing the ones they were meant
to escape with other characters that have better CSS support. Closes #1095.

Besides this, I also added in something I think is really important.
I added Contributing notes that mention the decisions
taken to modify the CSS generated by Tailwind and how it is applied to the email
for better email client support and for us to not lose these.

Would also be a great idea to write unit tests for these email support decisions, so we
don't lose them by checking on a CI basis as well.

How can I make sure this is fixed?

You can take a look into how I implemented the unit tests and how their snapshots look, no need to test by manually rendering.

Though you can try making sure things are completely working by sending to a Gmail account of yours an email with React Email's Tailwind integration as Gmail strips the styles completely. Just remember to use media queries, as they are the only ones that end up on a <style> tag.

This caused problems because escaping class names seems to not be very
well supported for email clients.

Closes #1095
…ort decisions

This I belive to be very important to keep account of because we have lost a few of these
decisions throughout the development and rewrites of the component which caused this to not
have the best support.
@gabrielmfern gabrielmfern force-pushed the fix/tailwind-media-query-escaped-class-names branch from a3c833e to 94518f7 Compare March 7, 2024 17:09
Copy link

vercel bot commented Mar 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2024 5:11pm
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2024 5:11pm

@gabrielmfern gabrielmfern merged commit 0fa7055 into canary Mar 8, 2024
9 checks passed
@gabrielmfern gabrielmfern deleted the fix/tailwind-media-query-escaped-class-names branch March 8, 2024 15:00
@jwarykowski
Copy link
Contributor

Hey @gabrielmfern / @vcapretz, has this been shipped in a package version yet?

@gabrielmfern
Copy link
Collaborator Author

@jwarykowski It should be released on @react-email/tailwind@0.0.15

github-merge-queue bot referenced this pull request in dotkom/monoweb Aug 20, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@react-email/tailwind](https://togithub.com/resend/react-email)
([source](https://togithub.com/resend/react-email/tree/HEAD/packages/tailwind))
| [`^0.0.12` ->
`^0.0.19`](https://renovatebot.com/diffs/npm/@react-email%2ftailwind/0.0.12/0.0.19)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@react-email%2ftailwind/0.0.19?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@react-email%2ftailwind/0.0.19?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@react-email%2ftailwind/0.0.12/0.0.19?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@react-email%2ftailwind/0.0.12/0.0.19?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>resend/react-email (@&#8203;react-email/tailwind)</summary>

###
[`v0.0.19`](https://togithub.com/resend/react-email/blob/HEAD/packages/tailwind/CHANGELOG.md#0019)

[Compare
Source](https://togithub.com/resend/react-email/compare/@react-email/tailwind@0.0.18...@react-email/tailwind@0.0.19)

##### Patch Changes

- [`dfb55ce`](https://togithub.com/resend/react-email/commit/dfb55ce):
Changed it so children of a component are only processed after the
component is done with them
-   Add forward ref

###
[`v0.0.18`](https://togithub.com/resend/react-email/releases/tag/%40react-email/tailwind%400.0.18):
@&#8203;react-email/tailwind 0.0.18

[Compare
Source](https://togithub.com/resend/react-email/compare/@react-email/tailwind@0.0.17...@react-email/tailwind@0.0.18)

#### What's Changed

- Fixes relatively complex media queries not being parsed properly by
[@&#8203;gabrielmfern](https://togithub.com/gabrielmfern) on
[#&#8203;1475](https://togithub.com/resend/react-email/issues/1475)

**Full Changelog**:
https://github.com/resend/react-email/compare/[@&#8203;react-email/tailwind](https://togithub.com/react-email/tailwind)[@&#8203;0](https://togithub.com/0).0.17...[@&#8203;react-email/tailwind](https://togithub.com/react-email/tailwind)[@&#8203;0](https://togithub.com/0).0.18

###
[`v0.0.17`](https://togithub.com/resend/react-email/releases/tag/%40react-email/tailwind%400.0.17):
@&#8203;react-email/tailwind 0.0.17

[Compare
Source](https://togithub.com/resend/react-email/compare/@react-email/tailwind@0.0.16...@react-email/tailwind@0.0.17)

#### What's Changed

- Treat React as a peer dependency by
[@&#8203;eps1lon](https://togithub.com/eps1lon) on
[#&#8203;1463](https://togithub.com/resend/react-email/issues/1463)
- Fixes the inlining of the JSX runtime by
[@&#8203;eps1lon](https://togithub.com/eps1lon) on
[#&#8203;1462](https://togithub.com/resend/react-email/issues/1462)
- Fixes types for `TailwindConfig` being basically a `Record<string,
any>` by [@&#8203;gabrielmfern](https://togithub.com/gabrielmfern) on
[#&#8203;1439](https://togithub.com/resend/react-email/issues/1439)
- Fixes children always being transformed into an array by
[@&#8203;gabrielmfern](https://togithub.com/gabrielmfern) on
[#&#8203;1397](https://togithub.com/resend/react-email/issues/1397)
- Fixes `React.forwardRef` components not working by
[@&#8203;nzben](https://togithub.com/nzben) on
[#&#8203;1335](https://togithub.com/resend/react-email/issues/1335)

**Full Changelog**:
https://github.com/resend/react-email/compare/[@&#8203;react-email/tailwind](https://togithub.com/react-email/tailwind)[@&#8203;0](https://togithub.com/0).0.16...[@&#8203;react-email/tailwind](https://togithub.com/react-email/tailwind)[@&#8203;0](https://togithub.com/0).0.17

###
[`v0.0.16`](https://togithub.com/resend/react-email/compare/@react-email/tailwind@0.0.15...@react-email/tailwind@0.0.16)

[Compare
Source](https://togithub.com/resend/react-email/compare/@react-email/tailwind@0.0.15...@react-email/tailwind@0.0.16)

###
[`v0.0.15`](https://togithub.com/resend/react-email/releases/tag/%40react-email/tailwind%400.0.15):
@&#8203;react-email/tailwind 0.0.15

[Compare
Source](https://togithub.com/resend/react-email/compare/v0.0.14...@react-email/tailwind@0.0.15)

#### What's Changed

- Fixed media query selectors being escaped, which caused issues for
some email clients
([https://github.com/resend/react-email/pull/1114](https://togithub.com/resend/react-email/pull/1114))
- Improved internal code readability and fixed key warnings
([https://github.com/resend/react-email/pull/1351](https://togithub.com/resend/react-email/pull/1351))
- Fixed missing head errors being thrown after minification of the
Email's component code
([https://github.com/resend/react-email/pull/1352](https://togithub.com/resend/react-email/pull/1352))
- Fixed not being able to use Tailwind classes on the `<html>` element
([https://github.com/resend/react-email/pull/1352](https://togithub.com/resend/react-email/pull/1352))

###
[`v0.0.14`](https://togithub.com/resend/react-email/releases/tag/v0.0.14)

[Compare
Source](https://togithub.com/resend/react-email/compare/v0.0.13...v0.0.14)

#### Patches

- Fix lint
[#&#8203;660](https://togithub.com/resend/react-email/issues/660)

###
[`v0.0.13`](https://togithub.com/resend/react-email/releases/tag/v0.0.13)

[Compare
Source](https://togithub.com/resend/react-email/compare/v0.0.12...v0.0.13)

#### Patches

- Support external file imports inside of email components
[#&#8203;615](https://togithub.com/resend/react-email/issues/615)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/dotkom/monoweb).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media queries do not show up in browsers email clients
3 participants