~cytrogen/masto-fe

ref: 8f66126b1010e0aaaa8b5f2a2f4ea8a28824e2b7 masto-fe/app/javascript/mastodon/features/ui/components/column_header.jsx -rw-r--r-- 901 bytes
8f66126b — Renaud Chaput Use the new JSX transform (#25064) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Icon }  from 'mastodon/components/icon';

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();
  };

  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>
    );
  }

}