Skip to content

chore(tailwind): Small refactor for easier changes and ease of understanding #1351

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

Merged
merged 9 commits into from
Mar 12, 2024

Conversation

gabrielmfern
Copy link
Collaborator

@gabrielmfern gabrielmfern commented Mar 11, 2024

This was going to initially be address #1112, but I wasn't able to fix
it without first making improvements to the code's organization
because as it wasn't prioritized while we made the performance improvements
from before.

This does a few things to make the readability and organization a bit better:

  • Separate the code for inlining styles and for getting them all from the elements into two "hook"s
    • Not exactly a hook since re-renders don't happen, so it might seem a bit off with the name,
      but, by a hook, I mean mostly following the general ways of creating and using them
      that makes the code a bit more familiar and easier to understand
  • Don't replace the elements inside the array in place but rather, do a map over them
  • Process the Head as we're processing the elements
  • Separates the utils into different domains so that they're easier to find
  • Adds a few more comments to places that are not so intuitive

How can I test/review this?

Most of the work we've put into writing our unit tests to make sure basic things
are still working properly already assure things are fine, so the tests passing is already
a thing that we can rest assured on.

As for reviewing, you can just look for the changes I mentioned before to make sure
they seem fine here, I'll try adding a few comments per line so that's easier to
understand to what portions I'm referring to.

@gabrielmfern gabrielmfern requested a review from vcapretz March 11, 2024 10:23
@gabrielmfern gabrielmfern self-assigned this Mar 11, 2024
Copy link

vercel bot commented Mar 11, 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 11, 2024 11:03am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
react-email-demo ⬜️ Ignored (Inspect) Visit Preview Mar 11, 2024 11:03am

@gabrielmfern gabrielmfern merged commit 9da83cb into canary Mar 12, 2024
@gabrielmfern gabrielmfern deleted the fix/tailwind-head-minification-issue branch March 12, 2024 16:46
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/[email protected]...@react-email/[email protected])

##### 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/[email protected]...@react-email/[email protected])

#### 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/[email protected]...@react-email/[email protected])

#### 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/[email protected]...@react-email/[email protected])

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

###
[`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/[email protected])

#### 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants