Skip to content

Commit 91e6f2c

Browse files
committed
fix: default radius bug
1 parent aedeeb6 commit 91e6f2c

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

npm/CssToTailwindTranslator.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,15 @@ const getRemDefaultVal = (val: string) => {
242242

243243
const getBorderRadiusDefaultVal = (val: string) => {
244244
return ({
245-
"0px": "none", "0.125rem": "sm", "0.25rem": "", "0.375rem": "md", "0.5rem": "lg", "0.75rem": "xl", "1rem": "2xl", "1.5rem": "3xl", "9999px": "full"
245+
"0px": "-none",
246+
"0.125rem": "-sm",
247+
"0.25rem": "null",
248+
"0.375rem": "-md",
249+
"0.5rem": "-lg",
250+
"0.75rem": "-xl",
251+
"1rem": "-2xl",
252+
"1.5rem": "-3xl",
253+
"9999px": "-full"
246254
}[val])
247255
}
248256

@@ -464,11 +472,11 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
464472
],
465473
[
466474
'border-bottom-left-radius',
467-
val => ({ '0': 'rounded-bl-none', '0px': 'rounded-bl-none' }[val] ?? (isUnit(val) ? `rounded-bl-${(useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `[${getCustomVal(val)}]`}` : ''))
475+
val => ({ '0': 'rounded-bl-none', '0px': 'rounded-bl-none' }[val] ?? (isUnit(val) ? `rounded-bl${((useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `-[${getCustomVal(val)}]`).replace(/null$/, '')}` : ''))
468476
],
469477
[
470478
'border-bottom-right-radius',
471-
val => ({ '0': 'rounded-br-none', '0px': 'rounded-br-none' }[val] ?? (isUnit(val) ? `rounded-br-${(useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `[${getCustomVal(val)}]`}` : ''))
479+
val => ({ '0': 'rounded-br-none', '0px': 'rounded-br-none' }[val] ?? (isUnit(val) ? `rounded-br${((useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `-[${getCustomVal(val)}]`).replace(/null$/, '')}` : ''))
472480
],
473481
[
474482
'border-bottom-style',
@@ -550,15 +558,15 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
550558
if (vals.filter(v => !isUnit(v)).length > 0) {
551559
return ''
552560
}
553-
vals = vals.map(v => (useAllDefaultValues && getBorderRadiusDefaultVal(v)) || `[${v}]`)
561+
vals = vals.map(v => ((useAllDefaultValues && getBorderRadiusDefaultVal(v)) || `-[${v}]`).replace(/null$/, ''))
554562
if (vals.length === 1) {
555-
return `rounded-${vals[0]}`
563+
return `rounded${vals[0]}`
556564
} else if (vals.length === 2) {
557-
return `rounded-tl-${vals[0]} rounded-br-${vals[0]} rounded-tr-${vals[1]} rounded-bl-${vals[1]}`
565+
return `rounded-tl${vals[0]} rounded-br${vals[0]} rounded-tr${vals[1]} rounded-bl${vals[1]}`
558566
} else if (vals.length === 3) {
559-
return `rounded-tl-${vals[0]} rounded-br-${vals[2]} rounded-tr-${vals[1]} rounded-bl-${vals[1]}`
567+
return `rounded-tl${vals[0]} rounded-br${vals[2]} rounded-tr${vals[1]} rounded-bl${vals[1]}`
560568
} else if (vals.length === 4) {
561-
return `rounded-tl-${vals[0]} rounded-br-${vals[2]} rounded-tr-${vals[1]} rounded-bl-${vals[3]}`
569+
return `rounded-tl${vals[0]} rounded-br${vals[2]} rounded-tr${vals[1]} rounded-bl${vals[3]}`
562570
}
563571
return ''
564572
}
@@ -611,11 +619,11 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
611619
],
612620
[
613621
'border-top-left-radius',
614-
val => ({ '0': 'rounded-tl-none', '0px': 'rounded-tl-none' }[val] ?? (isUnit(val) ? `rounded-tl-${(useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `[${getCustomVal(val)}]`}` : ''))
622+
val => ({ '0': 'rounded-tl-none', '0px': 'rounded-tl-none' }[val] ?? (isUnit(val) ? `rounded-tl${((useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `-[${getCustomVal(val)}]`).replace(/null$/, '')}` : ''))
615623
],
616624
[
617625
'border-top-right-radius',
618-
val => ({ '0': 'rounded-tr-none', '0px': 'rounded-tr-none' }[val] ?? (isUnit(val) ? `rounded-tr-${(useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `[${getCustomVal(val)}]`}` : ''))
626+
val => ({ '0': 'rounded-tr-none', '0px': 'rounded-tr-none' }[val] ?? (isUnit(val) ? `rounded-tr${((useAllDefaultValues && getBorderRadiusDefaultVal(val)) || `-[${getCustomVal(val)}]`).replace(/null$/, '')}` : ''))
619627
],
620628
[
621629
'border-top-style',

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.6",
3+
"version": "1.1.7",
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.6",
3+
"version": "1.1.7",
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.6",
18+
"css-to-tailwind-translator": "^1.1.7",
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)