2017-05-20 08:31:47 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 07:38:10 -07:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
2018-03-28 08:13:13 -07:00
|
|
|
import classNames from 'classnames';
|
2023-05-28 07:38:10 -07:00
|
|
|
|
2023-05-08 18:11:56 -07:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2016-08-31 07:15:12 -07:00
|
|
|
|
2023-05-28 05:18:23 -07:00
|
|
|
export default class ColumnHeader extends 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();
|
2023-02-03 11:52:07 -08:00
|
|
|
};
|
2016-09-05 15:44:28 -07:00
|
|
|
|
2016-08-31 07:15:12 -07:00
|
|
|
render () {
|
2018-03-28 08:13:13 -07:00
|
|
|
const { icon, type, active, columnHeaderId } = this.props;
|
|
|
|
let iconElement = '';
|
2017-02-20 15:10:49 -08:00
|
|
|
|
2018-03-28 08:13:13 -07:00
|
|
|
if (icon) {
|
2019-09-09 07:41:41 -07:00
|
|
|
iconElement = <Icon id={icon} fixedWidth className='column-header__icon' />;
|
2016-09-05 15:44:28 -07:00
|
|
|
}
|
|
|
|
|
2016-08-24 08:56:44 -07:00
|
|
|
return (
|
2018-03-28 08:13:13 -07:00
|
|
|
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
|
|
|
|
<button onClick={this.handleClick}>
|
|
|
|
{iconElement}
|
|
|
|
{type}
|
|
|
|
</button>
|
|
|
|
</h1>
|
2016-08-24 08:56:44 -07:00
|
|
|
);
|
|
|
|
}
|
2016-08-31 07:15:12 -07:00
|
|
|
|
2017-04-21 11:05:35 -07:00
|
|
|
}
|