Created
April 5, 2017 12:36
-
-
Save aaronmcadam/07be35266d7c39dcd5aa71b647b63fe3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { PropTypes } from 'react'; | |
import styled from 'styled-components'; | |
import { sizes } from '../constants/'; | |
const getHeight = ({ size }) => sizes.values[size]; | |
const Wrapper = styled.span` | |
display: inline-block; | |
color: black; | |
height: ${getHeight}; | |
width: ${getHeight}; | |
margin: 0.1rem; | |
box-sizing: border-box; | |
& > svg { | |
width: 100%; | |
height: 100%; | |
fill: currentcolor; | |
stroke: currentcolor; | |
} | |
`; | |
const Icon = ({ name, ...props }) => { | |
const svg = require(`!raw-loader!./icons/${name}.svg`); | |
return <Wrapper {...props} dangerouslySetInnerHTML={{ __html: svg }} />; | |
}; | |
Icon.propTypes = { | |
name: PropTypes.string.isRequired, | |
size: PropTypes.oneOf(sizes), | |
}; | |
Icon.defaultProps = { | |
size: 'mini', | |
}; | |
export default Icon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment