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