This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
NavTabs.js
93 lines (80 loc) · 2.34 KB
/
NavTabs.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import AppBar from '@material-ui/core/AppBar'
import CssBaseline from '@material-ui/core/CssBaseline'
import Typography from '@material-ui/core/Typography'
import Tab from '@material-ui/core/Tab'
import Tabs from '@material-ui/core/Tabs'
import NodesTab from './Nodes'
const styles = theme => ({
root: {
display: 'flex'
},
appBar: {
zIndex: theme.zIndex.drawer + 1
},
content: {
flexGrow: 1,
padding: theme.spacing.unit * 3
}
})
const TabContainer = withStyles(styles)(props => {
const { children, classes, display } = props
return (
<main className={classes.content} style={{ display }}>
<Typography component="div">{children}</Typography>
</main>
)
})
TabContainer.propTypes = {
children: PropTypes.node.isRequired,
classes: PropTypes.object,
display: PropTypes.string
}
class NavTabs extends React.Component {
static propTypes = {
classes: PropTypes.object
}
state = {
activeTab: 0
}
handleTabChange = (event, activeTab) => {
this.setState({ activeTab })
}
render() {
const { classes } = this.props
const { activeTab } = this.state
return (
<div className={classes.root}>
<CssBaseline />
<AppBar position="fixed" className={classes.appBar}>
<Tabs
value={activeTab}
onChange={this.handleTabChange}
textColor="primary"
indicatorColor="primary"
>
<Tab label="Nodes" />
<Tab label="Network" disabled />
<Tab label="Transactions" disabled />
<Tab label="Tools" disabled />
</Tabs>
</AppBar>
<div style={{ display: activeTab === 0 ? 'inherit' : 'none' }}>
<NodesTab />
</div>
<TabContainer display={activeTab === 1 ? 'block' : 'none'}>
<Typography component="h6">Network</Typography>
</TabContainer>
<TabContainer display={activeTab === 2 ? 'block' : 'none'}>
<Typography component="h6">Transactions</Typography>
</TabContainer>
<TabContainer display={activeTab === 3 ? 'block' : 'none'}>
<Typography component="h6">Tools</Typography>
</TabContainer>
</div>
)
}
}
export default withStyles(styles)(NavTabs)