File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,26 @@ describe('Element', () => {
100100 expect ( await element . render ( ) ) . toEqual (
101101 '<Box w="60px">\n <Box w="100%" />\n</Box>' ,
102102 )
103+ {
104+ const element = createElement ( 'RECTANGLE' , {
105+ border : 'solid 1px var(--containerBackground, #FFF)' ,
106+ fills : [ ] ,
107+ } )
108+ expect ( await element . getComponentType ( ) ) . toEqual ( 'Box' )
109+ expect ( await element . render ( ) ) . toEqual (
110+ '<Box border="solid 1px $containerBackground" />' ,
111+ )
112+ }
113+ {
114+ const element = createElement ( 'RECTANGLE' , {
115+ border : 'solid 1px var(--containerBackground)' ,
116+ fills : [ ] ,
117+ } )
118+ expect ( await element . getComponentType ( ) ) . toEqual ( 'Box' )
119+ expect ( await element . render ( ) ) . toEqual (
120+ '<Box border="solid 1px $containerBackground" />' ,
121+ )
122+ }
103123 } )
104124
105125 describe ( 'Image' , ( ) => {
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ export function space(depth: number) {
116116function extractVariableName ( value : string ) {
117117 if ( ! value . startsWith ( 'var(--' ) ) return value
118118 const match = value . match ( / v a r \( - - ( \w + ) / )
119- return '$' + match ?. [ 1 ]
119+ return '$' + match ?. [ 1 ] . split ( ',' ) [ 0 ] . trim ( )
120120}
121121
122122export function propsToComponentProps (
@@ -431,6 +431,8 @@ export function organizeProps(props: Record<string, string>) {
431431 if ( ret [ key ] . startsWith ( '"' ) && ret [ key ] . endsWith ( '"' ) )
432432 ret [ key ] = ret [ key ] . slice ( 1 , - 1 )
433433 if ( ret [ key ] . includes ( '/*' ) ) ret [ key ] = ret [ key ] . split ( '/*' ) [ 0 ] . trim ( )
434+ if ( ret [ key ] . includes ( 'var(--' ) )
435+ ret [ key ] = ret [ key ] . replace ( / v a r \( - - .* \) / g, extractVariableName )
434436 }
435437 for ( const key in CONVERT_PROPS_VALUE_MAP ) {
436438 if ( ! ret [ key ] ) continue
You can’t perform that action at this time.
0 commit comments