From 56fb226ae6cc4929f0db5fe9f24fff47e3c58039 Mon Sep 17 00:00:00 2001 From: Sjoert <63722509+Sjoertjuh@users.noreply.github.com> Date: Wed, 26 Feb 2025 21:25:10 +0100 Subject: [PATCH 01/51] feat(tailwind): extract pseudo classes to stylesheet (#1864) Co-authored-by: gabriel miranda --- .changeset/great-parrots-yell.md | 5 + .../src/__snapshots__/tailwind.spec.tsx.snap | 41 +----- packages/tailwind/src/tailwind.spec.tsx | 10 +- .../sanitize-media-queries.spec.ts | 88 ------------ .../media-queries/sanitize-media-queries.ts | 64 --------- .../sanitize-non-inlinable-classes.spec.ts | 130 ++++++++++++++++++ .../css/sanitize-non-inlinable-classes.ts | 92 +++++++++++++ .../clone-element-with-inlined-styles.ts | 14 +- 8 files changed, 240 insertions(+), 204 deletions(-) create mode 100644 .changeset/great-parrots-yell.md delete mode 100644 packages/tailwind/src/utils/css/media-queries/sanitize-media-queries.spec.ts delete mode 100644 packages/tailwind/src/utils/css/media-queries/sanitize-media-queries.ts create mode 100644 packages/tailwind/src/utils/css/sanitize-non-inlinable-classes.spec.ts create mode 100644 packages/tailwind/src/utils/css/sanitize-non-inlinable-classes.ts diff --git a/.changeset/great-parrots-yell.md b/.changeset/great-parrots-yell.md new file mode 100644 index 0000000000..429c2c034d --- /dev/null +++ b/.changeset/great-parrots-yell.md @@ -0,0 +1,5 @@ +--- +"@react-email/tailwind": minor +--- + +Extract tailwind pseudo classes to stylesheet diff --git a/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap b/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap index 76d7a2b1da..90d35508af 100644 --- a/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap +++ b/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap @@ -14,45 +14,7 @@ exports[`Custom theme config > should be able to use custom spacing 1`] = `" should be able to use custom text alignment 1`] = `"
"`; -exports[`Responsive styles > should add css to and keep responsive class names 1`] = `"
"`; - -exports[`Responsive styles > should not have duplicate media queries 1`] = `"
"`; - -exports[`Responsive styles > should persist existing elements 1`] = `"
"`; - -exports[`Responsive styles > should throw an error when used without a 1`] = ` -[Error: You are trying to use the following Tailwind classes that cannot be inlined: sm:bg-red-500. -For the media queries to work properly on rendering, they need to be added into a
"`; - -exports[`Responsive styles > should work with arbitrarily deep (in the React tree) elements 2`] = `"
"`; - -exports[`Responsive styles > should work with relatively complex media query utilities 1`] = `"

I am some text

"`; - -exports[`Tailwind component >