aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/tab-bar.js
diff options
context:
space:
mode:
authorThomas <tmashuang@gmail.com>2018-04-11 23:35:31 +0800
committerThomas <tmashuang@gmail.com>2018-04-11 23:35:31 +0800
commitf82c51c2c4782f54fb1d690f2dc1c309fafefe65 (patch)
tree84e5d2a1b989459f3dbb6f74e1921b4b83f705a0 /ui/app/components/tab-bar.js
parent30474ccd35d5d7f30ffb8dff0acc8fbc77f44731 (diff)
parent29dab1e9e00c1c1e6ad834026df51b2839d3171d (diff)
downloadtangerine-wallet-browser-f82c51c2c4782f54fb1d690f2dc1c309fafefe65.tar.gz
tangerine-wallet-browser-f82c51c2c4782f54fb1d690f2dc1c309fafefe65.tar.zst
tangerine-wallet-browser-f82c51c2c4782f54fb1d690f2dc1c309fafefe65.zip
Merge branch 'master' into testing
Diffstat (limited to 'ui/app/components/tab-bar.js')
-rw-r--r--ui/app/components/tab-bar.js26
1 files changed, 6 insertions, 20 deletions
diff --git a/ui/app/components/tab-bar.js b/ui/app/components/tab-bar.js
index a80640116..0016a09c1 100644
--- a/ui/app/components/tab-bar.js
+++ b/ui/app/components/tab-bar.js
@@ -4,31 +4,17 @@ const PropTypes = require('prop-types')
const classnames = require('classnames')
class TabBar extends Component {
- constructor (props) {
- super(props)
- const { defaultTab, tabs } = props
-
- this.state = {
- subview: defaultTab || tabs[0].key,
- }
- }
-
render () {
- const { tabs = [], tabSelected } = this.props
- const { subview } = this.state
+ const { tabs = [], onSelect, isActive } = this.props
return (
h('.tab-bar', {}, [
- tabs.map((tab) => {
- const { key, content } = tab
+ tabs.map(({ key, content }) => {
return h('div', {
className: classnames('tab-bar__tab pointer', {
- 'tab-bar__tab--active': subview === key,
+ 'tab-bar__tab--active': isActive(key, content),
}),
- onClick: () => {
- this.setState({ subview: key })
- tabSelected(key)
- },
+ onClick: () => onSelect(key),
key,
}, content)
}),
@@ -39,9 +25,9 @@ class TabBar extends Component {
}
TabBar.propTypes = {
- defaultTab: PropTypes.string,
+ isActive: PropTypes.func.isRequired,
tabs: PropTypes.array,
- tabSelected: PropTypes.func,
+ onSelect: PropTypes.func,
}
module.exports = TabBar