2017-10-23 07:40:03 +02:00
|
|
|
const { Component } = require('react')
|
2016-11-04 20:00:56 +01:00
|
|
|
const h = require('react-hyperscript')
|
2018-02-07 07:03:37 +01:00
|
|
|
const PropTypes = require('prop-types')
|
2017-10-23 07:40:03 +02:00
|
|
|
const classnames = require('classnames')
|
2016-11-04 20:00:56 +01:00
|
|
|
|
2017-10-23 07:40:03 +02:00
|
|
|
class TabBar extends Component {
|
|
|
|
render () {
|
2017-11-29 05:24:35 +01:00
|
|
|
const { tabs = [], onSelect, isActive } = this.props
|
2016-11-04 20:00:56 +01:00
|
|
|
|
2017-10-23 07:40:03 +02:00
|
|
|
return (
|
|
|
|
h('.tab-bar', {}, [
|
2017-11-29 05:24:35 +01:00
|
|
|
tabs.map(({ key, content }) => {
|
2017-10-23 07:40:03 +02:00
|
|
|
return h('div', {
|
|
|
|
className: classnames('tab-bar__tab pointer', {
|
2017-11-29 05:24:35 +01:00
|
|
|
'tab-bar__tab--active': isActive(key, content),
|
2017-10-23 07:40:03 +02:00
|
|
|
}),
|
2017-11-29 05:24:35 +01:00
|
|
|
onClick: () => onSelect(key),
|
2017-10-23 07:40:03 +02:00
|
|
|
key,
|
|
|
|
}, content)
|
|
|
|
}),
|
|
|
|
h('div.tab-bar__tab.tab-bar__grow-tab'),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|
2016-11-04 20:00:56 +01:00
|
|
|
}
|
2017-06-14 02:47:56 +02:00
|
|
|
|
2017-11-02 03:30:33 +01:00
|
|
|
TabBar.propTypes = {
|
2017-11-29 05:24:35 +01:00
|
|
|
isActive: PropTypes.func.isRequired,
|
2017-11-02 03:30:33 +01:00
|
|
|
tabs: PropTypes.array,
|
2017-11-29 05:24:35 +01:00
|
|
|
onSelect: PropTypes.func,
|
2017-11-02 03:30:33 +01:00
|
|
|
}
|
|
|
|
|
2017-10-23 07:40:03 +02:00
|
|
|
module.exports = TabBar
|