Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active June 15, 2021 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidgilbertson/291e3172ca62ae17260570118cdb4c78 to your computer and use it in GitHub Desktop.
Save davidgilbertson/291e3172ca62ae17260570118cdb4c78 to your computer and use it in GitHub Desktop.
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