1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/app/components/tab-bar.js

34 lines
815 B
JavaScript
Raw Normal View History

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')
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 () {
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', {}, [
tabs.map(({ key, content }) => {
2017-10-23 07:40:03 +02:00
return h('div', {
className: classnames('tab-bar__tab pointer', {
'tab-bar__tab--active': isActive(key, content),
2017-10-23 07:40:03 +02: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-11-02 03:30:33 +01:00
TabBar.propTypes = {
isActive: PropTypes.func.isRequired,
2017-11-02 03:30:33 +01:00
tabs: PropTypes.array,
onSelect: PropTypes.func,
2017-11-02 03:30:33 +01:00
}
2017-10-23 07:40:03 +02:00
module.exports = TabBar