aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/tab-bar.js
blob: 0016a09c168cdb6927accd151a7abb0cecf30d41 (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
const { Component } = require('react')
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const classnames = require('classnames')

class TabBar extends Component {
  render () {
    const { tabs = [], onSelect, isActive } = this.props

    return (
      h('.tab-bar', {}, [
        tabs.map(({ key, content }) => {
          return h('div', {
            className: classnames('tab-bar__tab pointer', {
              'tab-bar__tab--active': isActive(key, content),
            }),
            onClick: () => onSelect(key),
            key,
          }, content)
        }),
        h('div.tab-bar__tab.tab-bar__grow-tab'),
      ])
    )
  }
}

TabBar.propTypes = {
  isActive: PropTypes.func.isRequired,
  tabs: PropTypes.array,
  onSelect: PropTypes.func,
}

module.exports = TabBar