2017-05-03 02:04:16 +02:00
|
|
|
import React from 'react';
|
2017-05-20 17:31:47 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2018-03-28 17:13:13 +02:00
|
|
|
import classNames from 'classnames';
|
2019-09-09 16:41:41 +02:00
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2017-06-23 19:36:54 +02:00
|
|
|
export default class ColumnHeader extends React.PureComponent {
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2017-05-12 14:44:10 +02:00
|
|
|
static propTypes = {
|
|
|
|
icon: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-20 17:31:47 +02:00
|
|
|
columnHeaderId: PropTypes.string,
|
2017-05-12 14:44:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2016-09-06 00:44:28 +02:00
|
|
|
this.props.onClick();
|
2017-04-21 20:05:35 +02:00
|
|
|
}
|
2016-09-06 00:44:28 +02:00
|
|
|
|
2016-08-31 16:15:12 +02:00
|
|
|
render () {
|
2018-03-28 17:13:13 +02:00
|
|
|
const { icon, type, active, columnHeaderId } = this.props;
|
|
|
|
let iconElement = '';
|
2017-02-21 00:10:49 +01:00
|
|
|
|
2018-03-28 17:13:13 +02:00
|
|
|
if (icon) {
|
2019-09-09 16:41:41 +02:00
|
|
|
iconElement = <Icon id={icon} fixedWidth className='column-header__icon' />;
|
2016-09-06 00:44:28 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 17:56:44 +02:00
|
|
|
return (
|
2018-03-28 17:13:13 +02:00
|
|
|
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
|
|
|
|
<button onClick={this.handleClick}>
|
|
|
|
{iconElement}
|
|
|
|
{type}
|
|
|
|
</button>
|
|
|
|
</h1>
|
2016-08-24 17:56:44 +02:00
|
|
|
);
|
|
|
|
}
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2017-04-21 20:05:35 +02:00
|
|
|
}
|