2017-05-02 17:04:16 -07:00
|
|
|
import React from 'react';
|
2017-05-20 08:31:47 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2016-08-31 07:15:12 -07:00
|
|
|
|
2017-06-23 10:36:54 -07:00
|
|
|
export default class ColumnHeader extends React.PureComponent {
|
2016-08-31 07:15:12 -07:00
|
|
|
|
2017-05-12 05:44:10 -07:00
|
|
|
static propTypes = {
|
|
|
|
icon: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-20 08:31:47 -07:00
|
|
|
columnHeaderId: PropTypes.string,
|
2017-05-12 05:44:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2016-09-05 15:44:28 -07:00
|
|
|
this.props.onClick();
|
2017-04-21 11:05:35 -07:00
|
|
|
}
|
2016-09-05 15:44:28 -07:00
|
|
|
|
2016-08-31 07:15:12 -07:00
|
|
|
render () {
|
2017-07-26 04:46:53 -07:00
|
|
|
const { type, active, columnHeaderId } = this.props;
|
2017-02-20 15:10:49 -08:00
|
|
|
|
2016-09-05 15:44:28 -07:00
|
|
|
let icon = '';
|
|
|
|
|
|
|
|
if (this.props.icon) {
|
2017-04-22 19:26:55 -07:00
|
|
|
icon = <i className={`fa fa-fw fa-${this.props.icon} column-header__icon`} />;
|
2016-09-05 15:44:28 -07:00
|
|
|
}
|
|
|
|
|
2016-08-24 08:56:44 -07:00
|
|
|
return (
|
2017-07-26 04:46:53 -07:00
|
|
|
<div role='heading' tabIndex='0' className={`column-header ${active ? 'active' : ''}`} onClick={this.handleClick} id={columnHeaderId || null}>
|
2016-09-05 15:44:28 -07:00
|
|
|
{icon}
|
2017-02-20 15:10:49 -08:00
|
|
|
{type}
|
2016-08-24 08:56:44 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-08-31 07:15:12 -07:00
|
|
|
|
2017-04-21 11:05:35 -07:00
|
|
|
}
|