@@ -46,12 +46,21 @@ const buildBlock = ({
46
46
const componentName = capitalize ( childComponent . type )
47
47
let propsContent = ''
48
48
49
- const propsNames = Object . keys ( childComponent . props )
49
+ const propsNames = Object . keys ( childComponent . props ) . filter ( propName => {
50
+ if ( childComponent . type === 'Icon' ) {
51
+ return propName !== 'icon'
52
+ }
53
+
54
+ return true
55
+ } )
50
56
51
57
propsNames . forEach ( ( propName : string ) => {
52
58
const propsValue = childComponent . props [ propName ]
53
59
54
- if ( propName . toLowerCase ( ) . includes ( 'icon' ) ) {
60
+ if (
61
+ propName . toLowerCase ( ) . includes ( 'icon' ) &&
62
+ childComponent . type !== 'Icon'
63
+ ) {
55
64
if ( Object . keys ( icons ) . includes ( propsValue ) ) {
56
65
let operand = `={<${ propsValue } />}`
57
66
@@ -79,6 +88,8 @@ const buildBlock = ({
79
88
childComponent . children . length === 0
80
89
) {
81
90
content += `<${ componentName } ${ propsContent } >${ childComponent . props . children } </${ componentName } >`
91
+ } else if ( childComponent . type === 'Icon' ) {
92
+ content += `<${ childComponent . props . icon } ${ propsContent } />`
82
93
} else if ( childComponent . children . length ) {
83
94
content += `<${ componentName } ${ propsContent } >
84
95
${ buildBlock ( { component : childComponent , components, forceBuildBlock } ) }
@@ -152,7 +163,7 @@ const getIconsImports = (components: IComponents) => {
152
163
export const generateCode = async ( components : IComponents ) => {
153
164
let code = buildBlock ( { component : components . root , components } )
154
165
let componentsCodes = buildComponents ( components )
155
- const iconImports = getIconsImports ( components )
166
+ const iconImports = [ ... new Set ( getIconsImports ( components ) ) ]
156
167
157
168
const imports = [
158
169
...new Set (
0 commit comments