Created
August 12, 2018 08:19
-
-
Save behnood-eghbali/049c6c4cbd51700d763a279f68046a07 to your computer and use it in GitHub Desktop.
Creating an SVG Icon System with React
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, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class StarIcon extends Component { | |
render() { | |
const {color, width, height} = this.props; | |
return ( | |
<svg className="star" width={width} height={height} fill={color} viewBox="0 0 200 200"> | |
<path d="M100,10 L150,140 20,50 180,50 50,140 Z" /> | |
</svg> | |
); | |
} | |
} | |
StarIcon.propTypes = { | |
color: PropTypes.string, | |
width: PropTypes.number, | |
height: PropTypes.number, | |
selected: PropTypes.bool, | |
onClick: PropTypes.func | |
} | |
StarIcon.defaultProps = { | |
color: "blue", | |
width: 50, | |
height: 50 | |
} | |
export default StarIcon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment