Skip to content

Fix border-color only accepting named colors #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/__tests__/borderColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
})
})
4 changes: 2 additions & 2 deletions src/transforms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -25,7 +25,7 @@ const background = tokenStream => ({
backgroundColor: tokenStream.expect(COLOR),
})
const borderColor = directionFactory({
types: [WORD],
types: [COLOR],
prefix: 'border',
suffix: 'Color',
})
Expand Down