From 2defeb68332ac65fc4a40b0c67ece97d36b1e052 Mon Sep 17 00:00:00 2001 From: hymenhan Date: Tue, 19 Dec 2023 20:10:15 +0800 Subject: [PATCH] fix: border bug --- npm/CssToTailwindTranslator.ts | 26 +++++--------------------- npm/package.json | 4 ++-- package.json | 6 +++--- pnpm-lock.yaml | 8 ++++---- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/npm/CssToTailwindTranslator.ts b/npm/CssToTailwindTranslator.ts index 1e1f981..9341136 100644 --- a/npm/CssToTailwindTranslator.ts +++ b/npm/CssToTailwindTranslator.ts @@ -455,18 +455,14 @@ const propertyMap: Map | ((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)[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)[v] ?? `border-[${v}]`) : ((propertyMap.get('border-style') as Record)[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)}]` } ], [ @@ -528,11 +524,7 @@ const propertyMap: Map | ((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)}]` } ], [ @@ -577,11 +569,7 @@ const propertyMap: Map | ((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)}]` } ], [ @@ -609,11 +597,7 @@ const propertyMap: Map | ((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)}]` } ], [ diff --git a/npm/package.json b/npm/package.json index c6ad18e..0851495 100644 --- a/npm/package.json +++ b/npm/package.json @@ -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": { @@ -42,4 +42,4 @@ "css-to-tailwind-translator", "convert css code to tailwindcss" ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index e352123..2c4ed4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-to-tailwind", - "version": "1.2.6", + "version": "1.2.8", "private": true, "scripts": { "dev": "next dev", @@ -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", @@ -41,4 +41,4 @@ "tailwindcss": "^3.2.7", "typescript": "5.0.2" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d38ca77..c71a920 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ dependencies: specifier: ^1.2.1 version: 1.2.1 css-to-tailwind-translator: - specifier: ^1.2.6 - version: 1.2.6 + specifier: ^1.2.8 + version: 1.2.8 next: specifier: 13.2.4 version: 13.2.4(@babel/core@7.21.8)(react-dom@18.2.0)(react@18.2.0) @@ -2297,8 +2297,8 @@ packages: nth-check: 2.1.1 dev: true - /css-to-tailwind-translator@1.2.6: - resolution: {integrity: sha512-/dTIyxXb0SRy9w6JnqgeGRrCpLoMQ449+DsR1xJx92Y13UrGEVjlppqw7gtlaSbOhhC4//0Qdjx9yUvqfCplXg==} + /css-to-tailwind-translator@1.2.8: + resolution: {integrity: sha512-4hGXc4En6aVHlQdGZuSL9IS4rmLUJ3rKFnkx9u03/SW6jbEjgrV/l3u7cc36nv43zEu7NDGLpJgAsX4K/9HhrQ==} dev: false /css-tree@2.2.1: