2017-05-21 00:31:47 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 23:38:10 +09:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
2018-03-29 00:13:13 +09:00
|
|
|
import classNames from 'classnames';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
2023-11-15 20:01:51 +09:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2016-08-31 23:15:12 +09:00
|
|
|
|
2023-05-28 21:18:23 +09:00
|
|
|
export default class ColumnHeader extends PureComponent {
|
2016-08-31 23:15:12 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
static propTypes = {
|
|
|
|
icon: PropTypes.string,
|
2023-10-25 05:43:06 +09:00
|
|
|
iconComponent: PropTypes.func,
|
2017-05-12 21:44:10 +09:00
|
|
|
type: PropTypes.string,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-21 00:31:47 +09:00
|
|
|
columnHeaderId: PropTypes.string,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2016-09-06 07:44:28 +09:00
|
|
|
this.props.onClick();
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2016-09-06 07:44:28 +09:00
|
|
|
|
2016-08-31 23:15:12 +09:00
|
|
|
render () {
|
2023-10-25 05:43:06 +09:00
|
|
|
const { icon, iconComponent, type, active, columnHeaderId } = this.props;
|
2018-03-29 00:13:13 +09:00
|
|
|
let iconElement = '';
|
2017-02-21 08:10:49 +09:00
|
|
|
|
2018-03-29 00:13:13 +09:00
|
|
|
if (icon) {
|
2023-10-25 05:43:06 +09:00
|
|
|
iconElement = <Icon id={icon} icon={iconComponent} className='column-header__icon' />;
|
2016-09-06 07:44:28 +09:00
|
|
|
}
|
|
|
|
|
2016-08-25 00:56:44 +09:00
|
|
|
return (
|
2018-03-29 00:13:13 +09:00
|
|
|
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
|
|
|
|
<button onClick={this.handleClick}>
|
|
|
|
{iconElement}
|
|
|
|
{type}
|
|
|
|
</button>
|
|
|
|
</h1>
|
2016-08-25 00:56:44 +09:00
|
|
|
);
|
|
|
|
}
|
2016-08-31 23:15:12 +09:00
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|