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