File tree Expand file tree Collapse file tree 3 files changed +34
-11
lines changed
Expand file tree Collapse file tree 3 files changed +34
-11
lines changed Original file line number Diff line number Diff line change 1+ import transformCss from '..'
2+
3+ it ( 'transforms hex colors' , ( ) => {
4+ expect ( transformCss ( [ [ 'color' , '#f00' ] ] ) ) . toEqual ( { color : '#f00' } )
5+ } )
6+
7+ it ( 'transforms rgb colors' , ( ) => {
8+ expect ( transformCss ( [ [ 'color' , 'rgb(255, 0, 0)' ] ] ) ) . toEqual ( {
9+ color : 'rgb(255, 0, 0)' ,
10+ } )
11+ } )
12+
13+ it ( 'transforms transparent color' , ( ) => {
14+ expect ( transformCss ( [ [ 'color' , 'transparent' ] ] ) ) . toEqual ( {
15+ color : 'transparent' ,
16+ } )
17+ } )
18+
19+ it ( 'transforms border shorthand with transparent color' , ( ) => {
20+ expect ( transformCss ( [ [ 'border' , '2px dashed transparent' ] ] ) ) . toEqual ( {
21+ borderColor : 'transparent' ,
22+ borderStyle : 'dashed' ,
23+ borderWidth : 2 ,
24+ } )
25+ } )
26+
27+ it ( 'transforms background shorthand with transparent color' , ( ) => {
28+ expect ( transformCss ( [ [ 'background' , 'transparent' ] ] ) ) . toEqual ( {
29+ backgroundColor : 'transparent' ,
30+ } )
31+ } )
Original file line number Diff line number Diff line change @@ -117,16 +117,6 @@ it('transforms strings', () => {
117117 expect ( transformCss ( [ [ 'color' , 'red' ] ] ) ) . toEqual ( { color : 'red' } )
118118} )
119119
120- it ( 'transforms hex colors' , ( ) => {
121- expect ( transformCss ( [ [ 'color' , '#f00' ] ] ) ) . toEqual ( { color : '#f00' } )
122- } )
123-
124- it ( 'transforms rgb colors' , ( ) => {
125- expect ( transformCss ( [ [ 'color' , 'rgb(255, 0, 0)' ] ] ) ) . toEqual ( {
126- color : 'rgb(255, 0, 0)' ,
127- } )
128- } )
129-
130120it ( 'converts to camel-case' , ( ) => {
131121 expect ( transformCss ( [ [ 'background-color' , 'red' ] ] ) ) . toEqual ( {
132122 backgroundColor : 'red' ,
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ const cssFunctionNameRe = /^(rgba?|hsla?|hwb|lab|lch|gray|color)$/
1616const matchColor = node => {
1717 if (
1818 node . type === 'word' &&
19- ( hexColorRe . test ( node . value ) || node . value in cssColorKeywords )
19+ ( hexColorRe . test ( node . value ) ||
20+ node . value in cssColorKeywords ||
21+ node . value === 'transparent' )
2022 ) {
2123 return node . value
2224 } else if ( node . type === 'function' && cssFunctionNameRe . test ( node . value ) ) {
You can’t perform that action at this time.
0 commit comments