Skip to content

Commit 014abbd

Browse files
author
Simon Planinschek
committed
Added new types file and title tag to generator.js
1 parent 6a25385 commit 014abbd

2 files changed

Lines changed: 95 additions & 5 deletions

File tree

generator.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ const axios = require('axios')
66
const iconURL = 'https://fonts.google.com/metadata/icons'
77

88
function 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'
14+
915
// Create types file
10-
fs.writeFileSync(
11-
path.join(__dirname, 'src', 'types.ts'),
12-
'import React from "react" \nexport type IconProps = React.SVGProps<SVGSVGElement>'
13-
)
16+
fs.writeFileSync(path.join(__dirname, 'src', 'types.ts'), typesFile)
1417
}
1518

1619
/**
@@ -83,6 +86,12 @@ async function getSVGFile(icon, version) {
8386
.replace(/enable-background/g, 'enableBackground')
8487
.replace(/clip-rule/g, 'clipRule')
8588
.replace(/fill-rule/g, 'fillRule')
89+
.replace(
90+
'>',
91+
`><title>{props.title === undefined ? '${formatName(
92+
icon
93+
)}' : props.title}</title>`
94+
)
8695
}
8796

8897
/**

package-lock.json

Lines changed: 82 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)