You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
964 B

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. const IconButton = React.createClass({
  3. propTypes: {
  4. title: React.PropTypes.string.isRequired,
  5. icon: React.PropTypes.string.isRequired,
  6. onClick: React.PropTypes.func.isRequired,
  7. size: React.PropTypes.number,
  8. active: React.PropTypes.bool
  9. },
  10. getDefaultProps () {
  11. return {
  12. size: 18,
  13. active: false
  14. };
  15. },
  16. mixins: [PureRenderMixin],
  17. handleClick (e) {
  18. e.preventDefault();
  19. this.props.onClick();
  20. },
  21. render () {
  22. return (
  23. <a href='#' title={this.props.title} className={`icon-button ${this.props.active ? 'active' : ''}`} onClick={this.handleClick} style={{ display: 'inline-block', fontSize: `${this.props.size}px`, width: `${this.props.size}px`, height: `${this.props.size}px`, lineHeight: `${this.props.size}px`}}>
  24. <i className={`fa fa-fw fa-${this.props.icon}`}></i>
  25. </a>
  26. );
  27. }
  28. });
  29. export default IconButton;