2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2017-05-20 11:31:47 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2018-01-23 22:03:51 -05:00
|
|
|
import classNames from 'classnames';
|
2019-01-31 18:14:05 -05:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2016-08-31 10:15:12 -04:00
|
|
|
|
2017-06-23 13:36:54 -04:00
|
|
|
export default class ColumnHeader extends React.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) {
|
2019-01-31 18:14:05 -05:00
|
|
|
iconElement = <Icon id={icon} fixedWidth 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
|
|
|
}
|