2016-10-23 23:48:06 +13:00
|
|
|
|
2018-02-18 21:39:03 +13:00
|
|
|
import React, { PropTypes } from 'react';
|
2018-05-15 21:30:57 +12:00
|
|
|
import FontAwesome from 'react-fontawesome';
|
2016-10-23 23:48:06 +13:00
|
|
|
|
2018-05-13 16:03:51 +12:00
|
|
|
export default class Icon extends React.Component{
|
2016-10-23 23:48:06 +13:00
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
constructor(props){
|
2016-10-23 23:48:06 +13:00
|
|
|
super(props);
|
2018-02-15 16:16:00 +13:00
|
|
|
}
|
|
|
|
|
|
2018-05-20 20:42:20 +12:00
|
|
|
handleClick(e){
|
|
|
|
|
if (this.props.onClick){
|
|
|
|
|
this.props.onClick(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 23:48:06 +13:00
|
|
|
render(){
|
2018-05-15 21:30:57 +12:00
|
|
|
var className = "icon";
|
2018-02-15 16:16:00 +13:00
|
|
|
if (this.props.className){
|
|
|
|
|
className += ' '+this.props.className;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 21:30:57 +12:00
|
|
|
switch (this.props.type){
|
|
|
|
|
case 'fontawesome':
|
2018-05-20 20:42:20 +12:00
|
|
|
return <FontAwesome type="fontawesome" name={this.props.name} onClick={e => this.handleClick(e)} />;
|
2018-05-15 21:30:57 +12:00
|
|
|
|
|
|
|
|
default:
|
2018-05-16 16:50:46 +12:00
|
|
|
className += ' material-icon';
|
2018-05-20 20:42:20 +12:00
|
|
|
return <i className={className} onClick={e => this.handleClick(e)}>{this.props.name}</i>;
|
2018-05-15 21:30:57 +12:00
|
|
|
}
|
2018-02-18 21:39:03 +13:00
|
|
|
}
|
2018-05-13 16:03:51 +12:00
|
|
|
}
|