1
0
REI-Fixed/app/javascript/mastodon/features/ui/components/column_header.jsx

39 lines
901 B
React
Raw Normal View History

2023-05-23 17:52:27 +09:00
import { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Icon } from 'mastodon/components/icon';
2023-05-23 17:52:27 +09:00
export default class ColumnHeader extends PureComponent {
static propTypes = {
icon: PropTypes.string,
type: PropTypes.string,
active: PropTypes.bool,
onClick: PropTypes.func,
columnHeaderId: PropTypes.string,
};
handleClick = () => {
this.props.onClick();
2023-01-30 09:45:35 +09:00
};
render () {
const { icon, type, active, columnHeaderId } = this.props;
let iconElement = '';
if (icon) {
iconElement = <Icon id={icon} fixedWidth className='column-header__icon' />;
}
return (
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
<button onClick={this.handleClick}>
{iconElement}
{type}
</button>
</h1>
);
}
}