Skip to content

Commit

Permalink
fix: border bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hymhub committed Dec 19, 2023
1 parent 9124b53 commit 2defeb6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
26 changes: 5 additions & 21 deletions npm/CssToTailwindTranslator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,14 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
'border',
val => {
val = val.replace(/\(.+?\)/, v => v.replace(/\s/g, ''))
const vals: string = val.split(' ').filter(v => v !== '').map(v => (isUnit(v) || isColor(v)) ? ({ 'transparent': 'border-transparent', 'currentColor': 'border-current', 'currentcolor': 'border-current' }[val] ?? `border-[${v}]`) : ((propertyMap.get('border-style') as Record<string, string>)[v] ?? '')).filter(v => v !== '').join(' ')
const vals: string = val.split(' ').filter(v => v !== '').map(v => (isUnit(v) || isColor(v)) ? ({ 'transparent': 'border-transparent', 'currentColor': 'border-current', 'currentcolor': 'border-current' }[val] ?? (propertyMap.get('border-style') as Record<string, string>)[v] ?? `border-[${v}]`) : ((propertyMap.get('border-style') as Record<string, string>)[v] ?? '')).filter(v => v !== '').join(' ')
return vals
}
],
[
'border-bottom',
val => {
if (isUnit(val)) {
return `border-b-[${getCustomVal(val)}]`
} else {
return `[border-bottom:${getCustomVal(val)}]`
}
return `[border-bottom:${getCustomVal(val)}]`
}
],
[
Expand Down Expand Up @@ -528,11 +524,7 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
[
'border-left',
val => {
if (isUnit(val)) {
return `border-l-[${getCustomVal(val)}]`
} else {
return `[border-left:${getCustomVal(val)}]`
}
return `[border-left:${getCustomVal(val)}]`
}
],
[
Expand Down Expand Up @@ -577,11 +569,7 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
[
'border-right',
val => {
if (isUnit(val)) {
return `border-r-[${getCustomVal(val)}]`
} else {
return `[border-right:${getCustomVal(val)}]`
}
return `[border-right:${getCustomVal(val)}]`
}
],
[
Expand Down Expand Up @@ -609,11 +597,7 @@ const propertyMap: Map<string, Record<string, string> | ((val: string) => string
[
'border-top',
val => {
if (isUnit(val)) {
return `border-t-[${getCustomVal(val)}]`
} else {
return `[border-top:${getCustomVal(val)}]`
}
return `[border-top:${getCustomVal(val)}]`
}
],
[
Expand Down
4 changes: 2 additions & 2 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "css-to-tailwind-translator",
"version": "1.2.6",
"version": "1.2.8",
"description": "Convert CSS code to Tailwindcss syntax in real time",
"scripts": {},
"repository": {
Expand Down Expand Up @@ -42,4 +42,4 @@
"css-to-tailwind-translator",
"convert css code to tailwindcss"
]
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "css-to-tailwind",
"version": "1.2.6",
"version": "1.2.8",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -15,7 +15,7 @@
"@monaco-editor/react": "^4.4.6",
"clipboard": "^2.0.11",
"clsx": "^1.2.1",
"css-to-tailwind-translator": "^1.2.6",
"css-to-tailwind-translator": "^1.2.8",
"next": "13.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -41,4 +41,4 @@
"tailwindcss": "^3.2.7",
"typescript": "5.0.2"
}
}
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2defeb6

Please sign in to comment.