You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
889 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import classNames from 'classnames';
  4. import Icon from 'mastodon/components/icon';
  5. export default class ColumnHeader extends React.PureComponent {
  6. static propTypes = {
  7. icon: PropTypes.string,
  8. type: PropTypes.string,
  9. active: PropTypes.bool,
  10. onClick: PropTypes.func,
  11. columnHeaderId: PropTypes.string,
  12. };
  13. handleClick = () => {
  14. this.props.onClick();
  15. }
  16. render () {
  17. const { icon, type, active, columnHeaderId } = this.props;
  18. let iconElement = '';
  19. if (icon) {
  20. iconElement = <Icon id={icon} fixedWidth className='column-header__icon' />;
  21. }
  22. return (
  23. <h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
  24. <button onClick={this.handleClick}>
  25. {iconElement}
  26. {type}
  27. </button>
  28. </h1>
  29. );
  30. }
  31. }