From 983f85ea2f7c747c4f7e87f8706556a4e15037b4 Mon Sep 17 00:00:00 2001 From: krister Date: Wed, 14 Aug 2019 11:10:00 +0300 Subject: [PATCH 1/2] Fix border-color only accepting named colors --- src/__tests__/borderColor.js | 27 +++++++++++++++++++++++++++ src/transforms/index.js | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/__tests__/borderColor.js b/src/__tests__/borderColor.js index 66f3532..e6bd8e0 100644 --- a/src/__tests__/borderColor.js +++ b/src/__tests__/borderColor.js @@ -8,3 +8,30 @@ it('transforms border color with multiple values', () => { borderLeftColor: 'blue', }) }) + +it('transforms border color with hex color', () => { + expect(transformCss([['border-color', '#f00']])).toEqual({ + borderBottomColor: '#f00', + borderLeftColor: '#f00', + borderRightColor: '#f00', + borderTopColor: '#f00', + }) +}) + +it('transforms border color with rgb color', () => { + expect(transformCss([['border-color', 'rgb(255, 0, 0)']])).toEqual({ + borderBottomColor: 'rgb(255, 0, 0)', + borderLeftColor: 'rgb(255, 0, 0)', + borderRightColor: 'rgb(255, 0, 0)', + borderTopColor: 'rgb(255, 0, 0)', + }) +}) + +it('transforms border color with rgba color', () => { + expect(transformCss([['border-color', 'rgba(255, 0, 0, 0.1)']])).toEqual({ + borderBottomColor: 'rgba(255, 0, 0, 0.1)', + borderLeftColor: 'rgba(255, 0, 0, 0.1)', + borderRightColor: 'rgba(255, 0, 0, 0.1)', + borderTopColor: 'rgba(255, 0, 0, 0.1)', + }) +}) diff --git a/src/transforms/index.js b/src/transforms/index.js index 1185858..21cb3b1 100644 --- a/src/transforms/index.js +++ b/src/transforms/index.js @@ -5,9 +5,9 @@ import flex from './flex' import flexFlow from './flexFlow' import font from './font' import fontFamily from './fontFamily' -import textShadow from './textShadow' import textDecoration from './textDecoration' import textDecorationLine from './textDecorationLine' +import textShadow from './textShadow' import transform from './transform' import { directionFactory, parseShadowOffset } from './util' @@ -25,7 +25,7 @@ const background = tokenStream => ({ backgroundColor: tokenStream.expect(COLOR), }) const borderColor = directionFactory({ - types: [WORD], + types: [WORD, COLOR], prefix: 'border', suffix: 'Color', }) From 3a3a596b4d60abcb76242a45f12cd8d846ff16db Mon Sep 17 00:00:00 2001 From: Krister Kari Date: Wed, 14 Aug 2019 12:31:20 +0300 Subject: [PATCH 2/2] Update src/transforms/index.js Co-Authored-By: Jacob Parker --- src/transforms/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transforms/index.js b/src/transforms/index.js index 21cb3b1..333728b 100644 --- a/src/transforms/index.js +++ b/src/transforms/index.js @@ -25,7 +25,7 @@ const background = tokenStream => ({ backgroundColor: tokenStream.expect(COLOR), }) const borderColor = directionFactory({ - types: [WORD, COLOR], + types: [COLOR], prefix: 'border', suffix: 'Color', })