react-email 6.6.1 → 6.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # react-email
2
2
 
3
+ ## 6.6.3
4
+
5
+ ## 6.6.2
6
+
7
+ ### Patch Changes
8
+
9
+ - 437c414: Fix Tailwind opacity modifiers (e.g. `bg-blue-600/50`) rendering an invalid percentage alpha that breaks in some email clients.
10
+
3
11
  ## 6.6.1
4
12
 
5
13
  ### Patch Changes
@@ -6523,7 +6523,7 @@ const getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFil
6523
6523
  //#region package.json
6524
6524
  var package_default = {
6525
6525
  name: "react-email",
6526
- version: "6.6.1",
6526
+ version: "6.6.3",
6527
6527
  description: "A live preview of your emails right in your browser.",
6528
6528
  bin: { "email": "./dist/cli/index.mjs" },
6529
6529
  type: "module",
package/dist/index.cjs CHANGED
@@ -38321,11 +38321,25 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
38321
38321
  const color = children[3];
38322
38322
  const opacity = children[4];
38323
38323
  if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && color?.type === "Function" && color?.name === "rgb" && opacity) {
38324
- color.children.appendData({
38325
- type: "Operator",
38326
- value: ","
38327
- });
38328
- color.children.appendData(opacity);
38324
+ if (opacity.type === "Percentage") {
38325
+ const alpha = Number.parseFloat(opacity.value) / 100;
38326
+ if (alpha < 1) {
38327
+ color.children.appendData({
38328
+ type: "Operator",
38329
+ value: ","
38330
+ });
38331
+ color.children.appendData({
38332
+ type: "Number",
38333
+ value: alpha.toString()
38334
+ });
38335
+ }
38336
+ } else {
38337
+ color.children.appendData({
38338
+ type: "Operator",
38339
+ value: ","
38340
+ });
38341
+ color.children.appendData(opacity);
38342
+ }
38329
38343
  parentListItem.data = color;
38330
38344
  }
38331
38345
  }
package/dist/index.mjs CHANGED
@@ -38300,11 +38300,25 @@ function sanitizeDeclarations(nodeContainingDeclarations) {
38300
38300
  const color = children[3];
38301
38301
  const opacity = children[4];
38302
38302
  if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && color?.type === "Function" && color?.name === "rgb" && opacity) {
38303
- color.children.appendData({
38304
- type: "Operator",
38305
- value: ","
38306
- });
38307
- color.children.appendData(opacity);
38303
+ if (opacity.type === "Percentage") {
38304
+ const alpha = Number.parseFloat(opacity.value) / 100;
38305
+ if (alpha < 1) {
38306
+ color.children.appendData({
38307
+ type: "Operator",
38308
+ value: ","
38309
+ });
38310
+ color.children.appendData({
38311
+ type: "Number",
38312
+ value: alpha.toString()
38313
+ });
38314
+ }
38315
+ } else {
38316
+ color.children.appendData({
38317
+ type: "Operator",
38318
+ value: ","
38319
+ });
38320
+ color.children.appendData(opacity);
38321
+ }
38308
38322
  parentListItem.data = color;
38309
38323
  }
38310
38324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "6.6.1",
3
+ "version": "6.6.3",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/cli/index.mjs"
@@ -348,7 +348,39 @@ describe('sanitizeDeclarations', () => {
348
348
  sanitizeDeclarations(stylesheet);
349
349
  const result = generate(stylesheet);
350
350
  expect(result).toMatchInlineSnapshot(
351
- `".bg-blue-600/50{background-color:rgb(21,93,252,60%)}"`,
351
+ `".bg-blue-600/50{background-color:rgb(21,93,252,0.6)}"`,
352
+ );
353
+ });
354
+
355
+ it('converts the color-mix opacity percentage into a decimal alpha', () => {
356
+ let stylesheet = parse(`
357
+ .bg-blue-600\\/50 {
358
+ background-color: color-mix(in oklab, oklch(54.6% 0.245 262.881) 50%, transparent);
359
+ }
360
+ `);
361
+ sanitizeDeclarations(stylesheet);
362
+ expect(generate(stylesheet), 'half opacity').toMatchInlineSnapshot(
363
+ `".bg-blue-600\\/50{background-color:rgb(21,93,252,0.5)}"`,
364
+ );
365
+
366
+ stylesheet = parse(`
367
+ .bg-blue-600\\/12\\.5 {
368
+ background-color: color-mix(in oklab, oklch(54.6% 0.245 262.881) 12.5%, transparent);
369
+ }
370
+ `);
371
+ sanitizeDeclarations(stylesheet);
372
+ expect(generate(stylesheet), 'fractional opacity').toMatchInlineSnapshot(
373
+ `".bg-blue-600\\/12\\.5{background-color:rgb(21,93,252,0.125)}"`,
374
+ );
375
+
376
+ stylesheet = parse(`
377
+ .bg-blue-600\\/100 {
378
+ background-color: color-mix(in oklab, oklch(54.6% 0.245 262.881) 100%, transparent);
379
+ }
380
+ `);
381
+ sanitizeDeclarations(stylesheet);
382
+ expect(generate(stylesheet), 'full opacity').toMatchInlineSnapshot(
383
+ `".bg-blue-600\\/100{background-color:rgb(21,93,252)}"`,
352
384
  );
353
385
  });
354
386
 
@@ -384,11 +384,25 @@ export function sanitizeDeclarations(nodeContainingDeclarations: CssNode) {
384
384
  color?.name === 'rgb' &&
385
385
  opacity
386
386
  ) {
387
- color.children.appendData({
388
- type: 'Operator',
389
- value: ',',
390
- });
391
- color.children.appendData(opacity);
387
+ if (opacity.type === 'Percentage') {
388
+ const alpha = Number.parseFloat(opacity.value) / 100;
389
+ if (alpha < 1) {
390
+ color.children.appendData({
391
+ type: 'Operator',
392
+ value: ',',
393
+ });
394
+ color.children.appendData({
395
+ type: 'Number',
396
+ value: alpha.toString(),
397
+ });
398
+ }
399
+ } else {
400
+ color.children.appendData({
401
+ type: 'Operator',
402
+ value: ',',
403
+ });
404
+ color.children.appendData(opacity);
405
+ }
392
406
  parentListItem.data = color;
393
407
  }
394
408
  }