@react-email/tailwind 0.0.12 → 0.0.13-canary.0
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/dist/index.js +21 -14
- package/dist/index.mjs +21 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,22 +113,29 @@ var cssToJsxStyle = (cssText) => splitDeclarations(cssText).map(splitDeclaration
|
|
|
113
113
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
114
114
|
function processElement(element, headStyles, twi) {
|
|
115
115
|
let modifiedElement = element;
|
|
116
|
-
|
|
116
|
+
const propsClassName = modifiedElement.props.className;
|
|
117
|
+
if (typeof propsClassName === "string") {
|
|
117
118
|
const convertedStyles = [];
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
const responsiveClassNames = [];
|
|
120
|
+
const customClassNames = [];
|
|
121
|
+
const allClassNames = propsClassName.split(" ");
|
|
122
|
+
allClassNames.forEach((className) => {
|
|
123
|
+
const stylesWithoutMediaQueries = twi(className, {
|
|
124
|
+
ignoreMediaQueries: true
|
|
125
|
+
});
|
|
126
|
+
if (stylesWithoutMediaQueries.length > 0) {
|
|
127
|
+
convertedStyles.push(stylesWithoutMediaQueries);
|
|
128
|
+
} else if (twi(className, { ignoreMediaQueries: false }).length > 0) {
|
|
129
|
+
const classPieces = className.split(":");
|
|
130
|
+
const mediaQueryParts = classPieces.slice(0, -1);
|
|
131
|
+
const twClass = classPieces[classPieces.length - 1];
|
|
132
|
+
const importantPrefixedClassName = twClass.startsWith("!") ? className : `${mediaQueryParts.join(":")}:!${twClass}`;
|
|
133
|
+
responsiveClassNames.push(importantPrefixedClassName);
|
|
134
|
+
} else {
|
|
135
|
+
customClassNames.push(className);
|
|
128
136
|
}
|
|
129
|
-
return true;
|
|
130
137
|
});
|
|
131
|
-
const convertedResponsiveStyles = twi(
|
|
138
|
+
const convertedResponsiveStyles = twi(responsiveClassNames, {
|
|
132
139
|
ignoreMediaQueries: false,
|
|
133
140
|
merge: false
|
|
134
141
|
});
|
|
@@ -136,7 +143,7 @@ function processElement(element, headStyles, twi) {
|
|
|
136
143
|
convertedResponsiveStyles.replace(/^\n+/, "").replace(/\n+$/, "")
|
|
137
144
|
);
|
|
138
145
|
modifiedElement = React.cloneElement(modifiedElement, __spreadProps(__spreadValues({}, modifiedElement.props), {
|
|
139
|
-
className: customClassNames.length ? customClassNames.join(" ") : void 0,
|
|
146
|
+
className: customClassNames.length > 0 || responsiveClassNames.length > 0 ? customClassNames.concat(responsiveClassNames).join(" ") : void 0,
|
|
140
147
|
style: __spreadValues(__spreadValues({}, modifiedElement.props.style), cssToJsxStyle(convertedStyles.join(" ")))
|
|
141
148
|
}));
|
|
142
149
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -80,22 +80,29 @@ var cssToJsxStyle = (cssText) => splitDeclarations(cssText).map(splitDeclaration
|
|
|
80
80
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
81
81
|
function processElement(element, headStyles, twi) {
|
|
82
82
|
let modifiedElement = element;
|
|
83
|
-
|
|
83
|
+
const propsClassName = modifiedElement.props.className;
|
|
84
|
+
if (typeof propsClassName === "string") {
|
|
84
85
|
const convertedStyles = [];
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
const responsiveClassNames = [];
|
|
87
|
+
const customClassNames = [];
|
|
88
|
+
const allClassNames = propsClassName.split(" ");
|
|
89
|
+
allClassNames.forEach((className) => {
|
|
90
|
+
const stylesWithoutMediaQueries = twi(className, {
|
|
91
|
+
ignoreMediaQueries: true
|
|
92
|
+
});
|
|
93
|
+
if (stylesWithoutMediaQueries.length > 0) {
|
|
94
|
+
convertedStyles.push(stylesWithoutMediaQueries);
|
|
95
|
+
} else if (twi(className, { ignoreMediaQueries: false }).length > 0) {
|
|
96
|
+
const classPieces = className.split(":");
|
|
97
|
+
const mediaQueryParts = classPieces.slice(0, -1);
|
|
98
|
+
const twClass = classPieces[classPieces.length - 1];
|
|
99
|
+
const importantPrefixedClassName = twClass.startsWith("!") ? className : `${mediaQueryParts.join(":")}:!${twClass}`;
|
|
100
|
+
responsiveClassNames.push(importantPrefixedClassName);
|
|
101
|
+
} else {
|
|
102
|
+
customClassNames.push(className);
|
|
95
103
|
}
|
|
96
|
-
return true;
|
|
97
104
|
});
|
|
98
|
-
const convertedResponsiveStyles = twi(
|
|
105
|
+
const convertedResponsiveStyles = twi(responsiveClassNames, {
|
|
99
106
|
ignoreMediaQueries: false,
|
|
100
107
|
merge: false
|
|
101
108
|
});
|
|
@@ -103,7 +110,7 @@ function processElement(element, headStyles, twi) {
|
|
|
103
110
|
convertedResponsiveStyles.replace(/^\n+/, "").replace(/\n+$/, "")
|
|
104
111
|
);
|
|
105
112
|
modifiedElement = React.cloneElement(modifiedElement, __spreadProps(__spreadValues({}, modifiedElement.props), {
|
|
106
|
-
className: customClassNames.length ? customClassNames.join(" ") : void 0,
|
|
113
|
+
className: customClassNames.length > 0 || responsiveClassNames.length > 0 ? customClassNames.concat(responsiveClassNames).join(" ") : void 0,
|
|
107
114
|
style: __spreadValues(__spreadValues({}, modifiedElement.props.style), cssToJsxStyle(convertedStyles.join(" ")))
|
|
108
115
|
}));
|
|
109
116
|
}
|