about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/column_header.js
blob: 2701cd57d295cfc13ae1b387f5c0883052094843 (plain) (blame)
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
39
40
41
42
43
import React from 'react';
import PropTypes from 'prop-types'

class ColumnHeader extends React.PureComponent {

  constructor (props, context) {
    super(props, context);
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick () {
    this.props.onClick();
  }

  render () {
    const { type, active, hideOnMobile, columnHeaderId } = this.props;

    let icon = '';

    if (this.props.icon) {
      icon = <i className={`fa fa-fw fa-${this.props.icon} column-header__icon`} />;
    }

    return (
      <div role='button heading' tabIndex='0' className={`column-header ${active ? 'active' : ''} ${hideOnMobile ? 'hidden-on-mobile' : ''}`} onClick={this.handleClick} id={columnHeaderId || null}>
        {icon}
        {type}
      </div>
    );
  }

}

ColumnHeader.propTypes = {
  icon: PropTypes.string,
  type: PropTypes.string,
  active: PropTypes.bool,
  onClick: PropTypes.func,
  hideOnMobile: PropTypes.bool,
  columnHeaderId: PropTypes.string
};

export default ColumnHeader;