Skip to content

Commit caa0202

Browse files
authored
Merge pull request #4 from stplasim/master
Optimised package bundle size and handled some more potential issues
2 parents 0f6ae30 + 47cac1a commit caa0202

1,322 files changed

Lines changed: 1687 additions & 4353 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generator.js

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

88
function setup() {
9-
// Create components folder
10-
fs.mkdirSync(path.join(__dirname, 'src', 'components'))
11-
129
// Create types file
1310
fs.writeFileSync(
14-
path.join(__dirname, 'src', 'components', 'types.ts'),
11+
path.join(__dirname, 'src', 'types.ts'),
1512
'import React from "react" \nexport type IconProps = React.SVGProps<SVGSVGElement>'
1613
)
1714
}
@@ -45,7 +42,7 @@ function componentTemplate(name, svg) {
4542
component += "import { IconProps } from './types'\n\n"
4643
component += `const ${name}: React.FC<IconProps> = (props) => (`
4744
component += svg + ')\n\n'
48-
component += `export { ${name} }`
45+
component += `export { ${name} as default }`
4946

5047
return component
5148
}
@@ -61,34 +58,12 @@ function generateComponent(icon) {
6158
const svg = await getSVGFile(c.name, c.version)
6259

6360
fs.writeFileSync(
64-
path.join(__dirname, 'src', 'components', `${name}.tsx`),
61+
path.join(__dirname, 'src', `${name}.tsx`),
6562
componentTemplate(name, svg)
6663
)
6764
})
6865
}
6966

70-
/**
71-
* Generate index tsx file for easy import
72-
*
73-
* @param icons - Array of icons
74-
*/
75-
function generateIndex(icons) {
76-
let imports = ''
77-
let exports = 'export {\n'
78-
79-
icons.forEach((icon) => {
80-
const name = formatName(icon.name)
81-
imports += `import { ${name} } from './components/${name}'\n`
82-
exports += ` ${name},\n`
83-
})
84-
exports += '}'
85-
86-
fs.writeFileSync(
87-
path.join(__dirname, 'src', 'index.ts'),
88-
imports + '\n' + exports
89-
)
90-
}
91-
9267
/**
9368
* Get SVG data form google static fonts api
9469
*
@@ -105,6 +80,9 @@ async function getSVGFile(icon, version) {
10580
.replace('height="24"', '')
10681
.replace('width="24"', '{...props}')
10782
.replace(/class/g, 'className')
83+
.replace(/enable-background/g, 'enableBackground')
84+
.replace(/clip-rule/g, 'clipRule')
85+
.replace(/fill-rule/g, 'fillRule')
10886
}
10987

11088
/**
@@ -124,5 +102,4 @@ async function getSVGFile(icon, version) {
124102

125103
// Generate icon components and Index
126104
await generateComponent(icons.icons)
127-
await generateIndex(icons.icons)
128105
})()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@aboutbits/react-material-icons",
33
"version": "0.1.8",
44
"description": "Material design icon components for React",
5-
"main": "dist/index.js",
5+
"main": "dist/",
66
"scripts": {
77
"build": "tsc",
88
"generate": "rm -rf src/* && node generator.js",

readme.md

Lines changed: 1 addition & 0 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const Icon360: React.FC<IconProps> = (props) => (
88
</svg>
99
)
1010

11-
export { Icon360 }
11+
export { Icon360 as default }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const Icon3dRotation: React.FC<IconProps> = (props) => (
88
</svg>
99
)
1010

11-
export { Icon3dRotation }
11+
export { Icon3dRotation as default }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const Icon4k: React.FC<IconProps> = (props) => (
88
</svg>
99
)
1010

11-
export { Icon4k }
11+
export { Icon4k as default }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IconProps } from './types'
44
const Icon5g: React.FC<IconProps> = (props) => (
55
<svg
66
xmlns="http://www.w3.org/2000/svg"
7-
enable-background="new 0 0 24 24"
7+
enableBackground="new 0 0 24 24"
88
viewBox="0 0 24 24"
99
{...props}
1010
>
@@ -20,4 +20,4 @@ const Icon5g: React.FC<IconProps> = (props) => (
2020
</svg>
2121
)
2222

23-
export { Icon5g }
23+
export { Icon5g as default }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IconProps } from './types'
44
const Icon6FtApart: React.FC<IconProps> = (props) => (
55
<svg
66
xmlns="http://www.w3.org/2000/svg"
7-
enable-background="new 0 0 24 24"
7+
enableBackground="new 0 0 24 24"
88
viewBox="0 0 24 24"
99
{...props}
1010
>
@@ -13,4 +13,4 @@ const Icon6FtApart: React.FC<IconProps> = (props) => (
1313
</svg>
1414
)
1515

16-
export { Icon6FtApart }
16+
export { Icon6FtApart as default }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const IconAcUnit: React.FC<IconProps> = (props) => (
88
</svg>
99
)
1010

11-
export { IconAcUnit }
11+
export { IconAcUnit as default }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const IconAccessAlarm: React.FC<IconProps> = (props) => (
88
</svg>
99
)
1010

11-
export { IconAccessAlarm }
11+
export { IconAccessAlarm as default }

0 commit comments

Comments
 (0)