Skip to content

Commit c33b7e1

Browse files
committed
fix: media
1 parent 27b27af commit c33b7e1

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

npm/CssToTailwindTranslator.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,11 @@ const moreDefaultMediaVals: Record<string, string> = {
20512051
'@media(min-width:1024px)': 'lg',
20522052
'@media(min-width:1280px)': 'xl',
20532053
'@media(min-width:1536px)': '2xl',
2054+
'@media_not_all_and(min-width:640px)': 'max-sm',
2055+
'@media_not_all_and(min-width:768px)': 'max-md',
2056+
'@media_not_all_and(min-width:1024px)': 'max-lg',
2057+
'@media_not_all_and(min-width:1280px)': 'max-xl',
2058+
'@media_not_all_and(min-width:1536px)': 'max-2xl',
20542059
}
20552060

20562061
let moreDefaultValuesMap: Record<string, Record<string, string>> = {
@@ -2273,10 +2278,10 @@ export const CssToTailwindTranslator = (code: string, config: TranslatorConfig =
22732278
return getResultCode(it, '', config)
22742279
} else if (it.selectorName.includes('@media')) {
22752280
return it.cssCode.map(v => {
2276-
const mediaName = it.selectorName.replace(/\s/g, '')
2281+
const mediaName = getCustomVal(it.selectorName.replace(/\(.+\)/g, v => v.replace(/\s/g, '')).replace(/\s+\(/g, '('))
22772282
const res = getResultCode(v, customTheme.media?.[it.selectorName] || (config.useAllDefaultValues && moreDefaultMediaVals[mediaName]) || `[${mediaName}]`, config)
22782283
return res ? ({
2279-
selectorName: `${it.selectorName.replace(/\s/g, '')}-->${res.selectorName}`,
2284+
selectorName: `${it.selectorName}-->${res.selectorName}`,
22802285
resultVal: res.resultVal
22812286
}) : null
22822287
})

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-to-tailwind-translator",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Convert CSS code to Tailwindcss syntax in real time",
55
"scripts": {},
66
"repository": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-to-tailwind",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
@@ -15,7 +15,7 @@
1515
"@monaco-editor/react": "^4.4.6",
1616
"clipboard": "^2.0.11",
1717
"clsx": "^1.2.1",
18-
"css-to-tailwind-translator": "^1.1.1",
18+
"css-to-tailwind-translator": "^1.1.2",
1919
"next": "13.2.4",
2020
"react": "18.2.0",
2121
"react-dom": "18.2.0",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)