tailwind-to-style 1.0.2 → 1.0.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/index.js +48 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5683,6 +5683,14 @@ function replaceAndRemoveCSSVariables(styleString) {
|
|
|
5683
5683
|
return updatedStyleString;
|
|
5684
5684
|
}
|
|
5685
5685
|
|
|
5686
|
+
const breakpoints = {
|
|
5687
|
+
sm: "@media (min-width: 640px)",
|
|
5688
|
+
md: "@media (min-width: 768px)",
|
|
5689
|
+
lg: "@media (min-width: 1024px)",
|
|
5690
|
+
xl: "@media (min-width: 1280px)",
|
|
5691
|
+
"2xl": "@media (min-width: 1536px)",
|
|
5692
|
+
};
|
|
5693
|
+
|
|
5686
5694
|
function tws(classNames, convertToJson) {
|
|
5687
5695
|
const cssString = generateTailwindCssString().replace(/\s\s+/g, " ");
|
|
5688
5696
|
|
|
@@ -5705,4 +5713,43 @@ function tws(classNames, convertToJson) {
|
|
|
5705
5713
|
return cssResult;
|
|
5706
5714
|
}
|
|
5707
5715
|
|
|
5708
|
-
|
|
5716
|
+
function twsx(selectorsConfig) {
|
|
5717
|
+
return Object.entries(selectorsConfig)
|
|
5718
|
+
.map(([selector, [baseStyles, extensions = {}]]) => {
|
|
5719
|
+
let baseCSS = `${selector} { ${tws(baseStyles)} }`;
|
|
5720
|
+
let extendedCSS = "";
|
|
5721
|
+
|
|
5722
|
+
for (const [key, value] of Object.entries(extensions)) {
|
|
5723
|
+
if (breakpoints[key]) {
|
|
5724
|
+
const mediaQuery = breakpoints[key];
|
|
5725
|
+
extendedCSS += `
|
|
5726
|
+
${mediaQuery} {
|
|
5727
|
+
${selector} {
|
|
5728
|
+
${tws(value)}
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5731
|
+
`;
|
|
5732
|
+
} else if (key.startsWith("@media")) {
|
|
5733
|
+
extendedCSS += `
|
|
5734
|
+
${key} {
|
|
5735
|
+
${selector} {
|
|
5736
|
+
${tws(value)}
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
`;
|
|
5740
|
+
} else {
|
|
5741
|
+
extendedCSS += `
|
|
5742
|
+
${selector}${key} {
|
|
5743
|
+
${tws(value)}
|
|
5744
|
+
}
|
|
5745
|
+
`;
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
|
|
5749
|
+
return `${baseCSS} ${extendedCSS}`;
|
|
5750
|
+
})
|
|
5751
|
+
.join(" ");
|
|
5752
|
+
}
|
|
5753
|
+
|
|
5754
|
+
exports.tws = tws;
|
|
5755
|
+
exports.twsx = twsx;
|