@@ -24,14 +24,12 @@ const genSVG = (childrenAST: svgson.INode[], data: TransformData) => {
24
24
case "stroke" :
25
25
case "fill" :
26
26
// check if the value is a hex color
27
- if ( / ^ # .+ / . test ( attrVal ) )
28
- _attrVal = `{color || colorCtx || "${ data . defaultColor } "}`
27
+ if ( / ^ # .+ / . test ( attrVal ) ) _attrVal = `{_color}`
29
28
break
30
29
31
30
// Replace StrokeWidth for weight prop
32
31
case "strokeWidth" :
33
- if ( data . variant === "regular" )
34
- _attrVal = `{weight || weightCtx || "${ data . defaultWeight } "}`
32
+ if ( data . variant === "regular" ) _attrVal = `{_weight}`
35
33
else _attrVal = `"${ data . defaultWeight } "`
36
34
break
37
35
}
@@ -50,13 +48,16 @@ style={{
50
48
...styleCtx,
51
49
...style,
52
50
...props.style,
53
- }}`
51
+ }}
52
+ color={_color}
53
+ `
54
54
55
55
const getRegularComponent = (
56
56
transformData : TransformData ,
57
57
svgAST : svgson . INode ,
58
58
) => {
59
- const { componentName, defaultSize, defaultWeight } = transformData
59
+ const { componentName, defaultSize, defaultWeight, defaultColor } =
60
+ transformData
60
61
61
62
return `
62
63
import * as React from 'react'
@@ -82,10 +83,13 @@ const getRegularComponent = (
82
83
style: styleCtx
83
84
} = useContext(JengaIconContext as Context<JengaIconRegularProps>)
84
85
86
+ const _size = size || sizeCtx || ${ defaultSize }
87
+ const _weight = weight || weightCtx || ${ defaultWeight }
88
+ const _color = color || colorCtx || "${ defaultColor } "
85
89
86
90
return <svg
87
- width={size || sizeCtx || ${ defaultSize } }
88
- height={size || sizeCtx || ${ defaultSize } }
91
+ width={_size }
92
+ height={_size }
89
93
strokeWidth={weight || weightCtx || ${ defaultWeight } }
90
94
ref={ref}
91
95
${ genAttrString ( svgAST . attributes ) }
@@ -110,7 +114,7 @@ const getFillComponent = (
110
114
transformData : TransformData ,
111
115
svgAST : svgson . INode ,
112
116
) => {
113
- const { componentName, defaultSize } = transformData
117
+ const { componentName, defaultSize, defaultColor } = transformData
114
118
115
119
return `
116
120
import * as React from 'react'
@@ -135,10 +139,14 @@ const getFillComponent = (
135
139
style: styleCtx
136
140
} = useContext(JengaIconContext)
137
141
142
+
143
+ const _size = size || sizeCtx || ${ defaultSize }
144
+ const _color = color || colorCtx || "${ defaultColor } "
145
+
138
146
139
147
return <svg
140
- width={size || sizeCtx || ${ defaultSize } }
141
- height={size || sizeCtx || ${ defaultSize } }
148
+ width={_size }
149
+ height={_size }
142
150
ref={ref}
143
151
${ genAttrString ( svgAST . attributes ) }
144
152
${ CommonSVGRootProps }
0 commit comments