Last active
June 15, 2021 14:00
-
-
Save davidgilbertson/291e3172ca62ae17260570118cdb4c78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const {PropTypes} = React; | |
import iconPaths from './selection.js';// the file exported from IcoMoon | |
function getPath(iconName) { | |
const icon = iconPaths.icons.find(icon => icon.properties.name === iconName); | |
if (icon) { | |
return icon.icon.paths.join(' '); | |
} else { | |
console.warn(`icon ${iconName} does not exist.`); | |
return ''; | |
} | |
} | |
const Icon = props => ( | |
<svg width="22" height="22" viewBox="0 0 1024 1024"> | |
<path d={getPath(props.icon)}></path> | |
</svg> | |
); | |
Icon.propTypes = { | |
icon: PropTypes.string.isRequired, | |
}; | |
export default Icon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment