1import React from 'react';
2import { Link } from 'react-router-dom';
3
4import AppBar from '@material-ui/core/AppBar';
5import Tab from '@material-ui/core/Tab';
6import Tabs from '@material-ui/core/Tabs';
7import Toolbar from '@material-ui/core/Toolbar';
8import { makeStyles } from '@material-ui/core/styles';
9
10import { LightSwitch } from '../../components/Themer';
11import CurrentIdentity from '../CurrentIdentity/CurrentIdentity';
12
13const useStyles = makeStyles((theme) => ({
14 offset: {
15 ...theme.mixins.toolbar,
16 },
17 filler: {
18 flexGrow: 1,
19 },
20 appBar: {
21 backgroundColor: theme.palette.primary.dark,
22 color: theme.palette.primary.contrastText,
23 },
24 appTitle: {
25 ...theme.typography.h6,
26 color: theme.palette.primary.contrastText,
27 textDecoration: 'none',
28 display: 'flex',
29 alignItems: 'center',
30 },
31 lightSwitch: {
32 padding: '0 20px',
33 },
34 logo: {
35 height: '42px',
36 marginRight: theme.spacing(2),
37 },
38}));
39
40function a11yProps(index: any) {
41 return {
42 id: `nav-tab-${index}`,
43 'aria-controls': `nav-tabpanel-${index}`,
44 };
45}
46
47function NavTabs() {
48 const [value, setValue] = React.useState(0);
49
50 //TODO page refresh resets state. Must parse url to determine which tab is
51 //highlighted
52 const handleChange = (event: React.ChangeEvent<{}>, newValue: number) => {
53 setValue(newValue);
54 };
55
56 return (
57 <Tabs
58 centered
59 value={value}
60 onChange={handleChange}
61 aria-label="nav tabs example"
62 >
63 <Tab disabled label="Code" component="a" href="/code" {...a11yProps(0)} />
64 <Tab label="Bugs" component="a" href="/" {...a11yProps(1)} />
65 <Tab
66 disabled
67 label="Pull Requests"
68 component="a"
69 href="/pulls"
70 {...a11yProps(2)}
71 />
72 <Tab
73 disabled
74 label="Settings"
75 component="a"
76 href="/settings"
77 {...a11yProps(3)}
78 />
79 </Tabs>
80 );
81}
82
83function Header() {
84 const classes = useStyles();
85
86 return (
87 <>
88 <AppBar position="fixed" className={classes.appBar}>
89 <Toolbar>
90 <Link to="/" className={classes.appTitle}>
91 <img src="/logo.svg" className={classes.logo} alt="git-bug" />
92 git-bug
93 </Link>
94 <div className={classes.filler} />
95 <div className={classes.lightSwitch}>
96 <LightSwitch />
97 </div>
98 <CurrentIdentity />
99 </Toolbar>
100 </AppBar>
101 <div className={classes.offset} />
102 <NavTabs />
103 </>
104 );
105}
106
107export default Header;