2017-05-03 10:04:16 +10:00
|
|
|
import React from 'react';
|
2017-05-21 01:31:47 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2018-01-24 14:03:51 +11:00
|
|
|
import classNames from 'classnames';
|
2016-09-01 00:15:12 +10:00
|
|
|
|
2017-06-24 03:36:54 +10:00
|
|
|
export default class ColumnHeader extends React.PureComponent {
|
2016-09-01 00:15:12 +10:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
static propTypes = {
|
|
|
|
icon: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-21 01:31:47 +10:00
|
|
|
columnHeaderId: PropTypes.string,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2016-09-06 08:44:28 +10:00
|
|
|
this.props.onClick();
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2016-09-06 08:44:28 +10:00
|
|
|
|
2016-09-01 00:15:12 +10:00
|
|
|
render () {
|
2018-01-24 14:03:51 +11:00
|
|
|
const { icon, type, active, columnHeaderId } = this.props;
|
|
|
|
let iconElement = '';
|
2017-02-21 10:10:49 +11:00
|
|
|
|
2018-01-24 14:03:51 +11:00
|
|
|
if (icon) {
|
2018-09-28 01:08:56 +10:00
|
|
|
iconElement = <i className={`fas fa-fw fa-${icon} column-header__icon`} />;
|
2016-09-06 08:44:28 +10:00
|
|
|
}
|
|
|
|
|
2016-08-25 01:56:44 +10:00
|
|
|
return (
|
2018-01-24 14:03:51 +11:00
|
|
|
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
|
|
|
|
<button onClick={this.handleClick}>
|
|
|
|
{iconElement}
|
|
|
|
{type}
|
|
|
|
</button>
|
|
|
|
</h1>
|
2016-08-25 01:56:44 +10:00
|
|
|
);
|
|
|
|
}
|
2016-09-01 00:15:12 +10:00
|
|
|
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|