1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
metamask-extension/ui/app/components/tab-bar.js

41 lines
938 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')
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 {
constructor (props) {
super(props)
const { defaultTab, tabs } = props
2016-11-04 20:00:56 +01:00
2017-10-23 07:40:03 +02:00
this.state = {
subview: defaultTab || tabs[0].key,
}
}
2016-11-04 20:00:56 +01:00
2017-10-23 07:40:03 +02:00
render () {
const { tabs = [], tabSelected } = this.props
const { subview } = this.state
2016-11-04 20:00:56 +01:00
2017-10-23 07:40:03 +02:00
return (
h('.tab-bar', {}, [
tabs.map((tab) => {
const { key, content } = tab
return h('div', {
className: classnames('tab-bar__tab pointer', {
'tab-bar__tab--active': subview === key,
}),
onClick: () => {
this.setState({ subview: key })
tabSelected(key)
},
key,
}, content)
}),
h('div.tab-bar__tab.tab-bar__grow-tab'),
])
)
}
2016-11-04 20:00:56 +01:00
}
2017-10-23 07:40:03 +02:00
module.exports = TabBar