2017-05-03 01:04:16 +01:00
|
|
|
import React from 'react';
|
2017-04-21 19:05:35 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2016-08-31 15:15:12 +01:00
|
|
|
|
2017-04-21 19:05:35 +01:00
|
|
|
class ColumnHeader extends React.PureComponent {
|
2016-08-31 15:15:12 +01:00
|
|
|
|
2017-04-21 19:05:35 +01:00
|
|
|
constructor (props, context) {
|
|
|
|
super(props, context);
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
2016-08-31 15:15:12 +01:00
|
|
|
|
2016-09-05 23:44:28 +01:00
|
|
|
handleClick () {
|
|
|
|
this.props.onClick();
|
2017-04-21 19:05:35 +01:00
|
|
|
}
|
2016-09-05 23:44:28 +01:00
|
|
|
|
2016-08-31 15:15:12 +01:00
|
|
|
render () {
|
2017-04-22 16:30:35 +01:00
|
|
|
const { type, active, hideOnMobile, columnHeaderId } = this.props;
|
2017-02-20 23:10:49 +00:00
|
|
|
|
2016-09-05 23:44:28 +01:00
|
|
|
let icon = '';
|
|
|
|
|
|
|
|
if (this.props.icon) {
|
2017-04-23 03:26:55 +01:00
|
|
|
icon = <i className={`fa fa-fw fa-${this.props.icon} column-header__icon`} />;
|
2016-09-05 23:44:28 +01:00
|
|
|
}
|
|
|
|
|
2016-08-24 16:56:44 +01:00
|
|
|
return (
|
2017-04-22 16:30:35 +01:00
|
|
|
<div role='button heading' tabIndex='0' className={`column-header ${active ? 'active' : ''} ${hideOnMobile ? 'hidden-on-mobile' : ''}`} onClick={this.handleClick} id={columnHeaderId || null}>
|
2016-09-05 23:44:28 +01:00
|
|
|
{icon}
|
2017-02-20 23:10:49 +00:00
|
|
|
{type}
|
2016-08-24 16:56:44 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-08-31 15:15:12 +01:00
|
|
|
|
2017-04-21 19:05:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnHeader.propTypes = {
|
|
|
|
icon: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func,
|
2017-04-22 16:30:35 +01:00
|
|
|
hideOnMobile: PropTypes.bool,
|
|
|
|
columnHeaderId: PropTypes.string
|
2017-04-21 19:05:35 +01:00
|
|
|
};
|
2016-08-24 16:56:44 +01:00
|
|
|
|
|
|
|
export default ColumnHeader;
|