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.

38 lines
989 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. e.stopPropagation();
  21. },
  22. render () {
  23. return (
  24. <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`}}>
  25. <i className={`fa fa-fw fa-${this.props.icon}`}></i>
  26. </a>
  27. );
  28. }
  29. });
  30. export default IconButton;