Created
May 24, 2019 10:07
-
-
Save iamchristough/493c60112770058566d559e6860dc4c9 to your computer and use it in GitHub Desktop.
svg-icon-component.js
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 cx from 'classnames' | |
import PropTypes from 'prop-types' | |
import Instagram from '../../../static/images/instagram.svg' | |
import Story from '../../../static/images/story.svg' | |
import Facebook from '../../../static/images/facebook.svg' | |
import Twitter from '../../../static/images/twitter.svg' | |
import Snapchat from '../../../static/images/snapchat.svg' | |
import Youtube from '../../../static/images/youtube.svg' | |
import Blog from '../../../static/images/blog.svg' | |
import Travel from '../../../static/images/travel.svg' | |
import Event from '../../../static/images/event.svg' | |
class Icon extends Component { | |
getIcon = () => { | |
const { name } = this.props | |
const icons = { | |
'instagram': <Instagram />, | |
'story': <Story />, | |
'facebook': <Facebook />, | |
'snapchat': <Snapchat />, | |
'twitter': <Twitter />, | |
'youtube': <Youtube />, | |
'blog': <Blog />, | |
'travel': <Travel />, | |
'event': <Event /> | |
} | |
return icons[name] | |
} | |
render () { | |
return ( | |
<div className={cx('icon')}> | |
{ this.getIcon() } | |
</div> | |
) | |
} | |
} | |
Icon.propTypes = { | |
name: PropTypes.string | |
} | |
export default Icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment