@@ -6,11 +6,12 @@ const axios = require('axios')
66const iconURL = 'https://fonts.google.com/metadata/icons'
77
88function setup ( ) {
9- let typesFile = "import React from 'react'\n\n"
10- typesFile +=
11- 'export interface IconProps extends React.SVGProps<SVGSVGElement> {\n'
12- typesFile += '\ttitle?: string\n'
13- typesFile += '}\n'
9+ const typesFile = `
10+ import React from 'react'
11+ export interface IconProps extends React.SVGProps<SVGSVGElement> {
12+ title?: string
13+ }
14+ `
1415
1516 // Create types file
1617 fs . writeFileSync ( path . join ( __dirname , 'src' , 'types.ts' ) , typesFile )
@@ -41,13 +42,16 @@ function formatName(string) {
4142 * @returns {string } - Component
4243 */
4344function componentTemplate ( name , svg ) {
44- let component = "import React from 'react'\n"
45- component += "import { IconProps } from './types'\n\n"
46- component += `const ${ name } : React.FC<IconProps> = ({ title = '${ name } ', ...props }) => (`
47- component += svg + ')\n\n'
48- component += `export { ${ name } as default }`
49-
50- return component
45+ return `
46+ import React from 'react'
47+ import { IconProps } from './types'
48+
49+ const ${ name } : React.FC<IconProps> = ({ ...props }) => (
50+ ${ svg }
51+ )
52+
53+ export { ${ name } as default }
54+ `
5155}
5256
5357/**
@@ -86,7 +90,7 @@ async function getSVGFile(icon, version) {
8690 . replace ( / e n a b l e - b a c k g r o u n d / g, 'enableBackground' )
8791 . replace ( / c l i p - r u l e / g, 'clipRule' )
8892 . replace ( / f i l l - r u l e / g, 'fillRule' )
89- . replace ( '>' , '><title>{title}</title>' )
93+ . replace ( '>' , '>{props.title && <title>{props. title}</title>} ' )
9094}
9195
9296/**
0 commit comments