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.

35 lines
829 B

  1. import PropTypes from 'prop-types';
  2. class TextIconButton extends React.PureComponent {
  3. constructor (props, context) {
  4. super(props, context);
  5. this.handleClick = this.handleClick.bind(this);
  6. }
  7. handleClick (e) {
  8. e.preventDefault();
  9. this.props.onClick();
  10. }
  11. render () {
  12. const { label, title, active, ariaControls } = this.props;
  13. return (
  14. <button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} aria-expanded={active} onClick={this.handleClick} aria-controls={ariaControls}>
  15. {label}
  16. </button>
  17. );
  18. }
  19. }
  20. TextIconButton.propTypes = {
  21. label: PropTypes.string.isRequired,
  22. title: PropTypes.string,
  23. active: PropTypes.bool,
  24. onClick: PropTypes.func.isRequired,
  25. ariaControls: PropTypes.string
  26. };
  27. export default TextIconButton;