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
856 B
37 lines
856 B
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import PropTypes from 'prop-types';
|
||
8 years ago
|
|
||
8 years ago
|
class TextIconButton extends React.PureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
constructor (props, context) {
|
||
|
super(props, context);
|
||
|
this.handleClick = this.handleClick.bind(this);
|
||
|
}
|
||
8 years ago
|
|
||
|
handleClick (e) {
|
||
|
e.preventDefault();
|
||
|
this.props.onClick();
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
|
render () {
|
||
8 years ago
|
const { label, title, active, ariaControls } = this.props;
|
||
8 years ago
|
|
||
|
return (
|
||
8 years ago
|
<button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} aria-expanded={active} onClick={this.handleClick} aria-controls={ariaControls}>
|
||
8 years ago
|
{label}
|
||
|
</button>
|
||
|
);
|
||
|
}
|
||
|
|
||
8 years ago
|
}
|
||
|
|
||
|
TextIconButton.propTypes = {
|
||
|
label: PropTypes.string.isRequired,
|
||
|
title: PropTypes.string,
|
||
|
active: PropTypes.bool,
|
||
8 years ago
|
onClick: PropTypes.func.isRequired,
|
||
|
ariaControls: PropTypes.string
|
||
8 years ago
|
};
|
||
8 years ago
|
|
||
|
export default TextIconButton;
|