Skip to content

Instantly share code, notes, and snippets.

@behnood-eghbali
Created August 12, 2018 08:19
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 behnood-eghbali/049c6c4cbd51700d763a279f68046a07 to your computer and use it in GitHub Desktop.
Save behnood-eghbali/049c6c4cbd51700d763a279f68046a07 to your computer and use it in GitHub Desktop.
Creating an SVG Icon System with React
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