Skip to content

Instantly share code, notes, and snippets.

@pekkis
Created November 2, 2016 07:27
Show Gist options
  • Save pekkis/e63727d6cd36e4e629e2c883b87977d3 to your computer and use it in GitHub Desktop.
Save pekkis/e63727d6cd36e4e629e2c883b87977d3 to your computer and use it in GitHub Desktop.
import React from 'react';
import cx from 'classnames';
import { icons } from '../services/assets';
import styles from './Icon.pcss';
const Icon = props => {
const { name, size, flip, className } = props;
const classes = cx(
styles.icon,
styles.className,
[styles[`size-${size}`]],{
[styles.flip]: flip,
}
);
return (
<img className={classes} src={icons[name]} />
);
}
Icon.propTypes = {
name: React.PropTypes.string.isRequired,
size: React.PropTypes.string.isRequired,
flip: React.PropTypes.bool.isRequired,
className: React.PropTypes.string,
};
Icon.defaultProps = {
size: '1x',
flip: false,
};
export default Icon;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment