Skip to content

Commit b7b21f9

Browse files
committed
Add projects link to the top nav
Partially addresses #701.
1 parent c0a9eac commit b7b21f9

File tree

1 file changed

+63
-20
lines changed

1 file changed

+63
-20
lines changed
Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Button from "@material-ui/core/Button"
2-
import { makeStyles } from "@material-ui/core/styles"
2+
import List from "@material-ui/core/List"
3+
import ListItem from "@material-ui/core/ListItem"
4+
import { fade, makeStyles } from "@material-ui/core/styles"
35
import React from "react"
4-
import { Link } from "react-router-dom"
6+
import { NavLink } from "react-router-dom"
57
import { UserResponse } from "../../api/types"
68
import { Logo } from "../Icons"
79
import { UserDropdown } from "./UserDropdown"
@@ -14,29 +16,34 @@ export interface NavbarViewProps {
1416
export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut }) => {
1517
const styles = useStyles()
1618
return (
17-
<div className={styles.root}>
18-
<div className={styles.fixed}>
19-
<Link to="/">
20-
<Button className={styles.logo} variant="text">
21-
<Logo fill="white" opacity={1} />
22-
</Button>
23-
</Link>
24-
</div>
19+
<nav className={styles.root}>
20+
<List className={styles.fixed}>
21+
<ListItem className={styles.item}>
22+
<NavLink className={styles.logo} to="/">
23+
<Logo fill="white" opacity={1} width={125} />
24+
</NavLink>
25+
</ListItem>
26+
<ListItem button className={styles.item}>
27+
<NavLink className={styles.link} to="/projects">
28+
Projects
29+
</NavLink>
30+
</ListItem>
31+
</List>
2532
<div className={styles.fullWidth} />
2633
<div className={styles.fixed}>{user && <UserDropdown user={user} onSignOut={onSignOut} />}</div>
27-
</div>
34+
</nav>
2835
)
2936
}
3037

3138
const useStyles = makeStyles((theme) => ({
3239
root: {
3340
position: "relative",
3441
display: "flex",
35-
flex: "0",
42+
flex: 0,
3643
flexDirection: "row",
3744
justifyContent: "center",
3845
alignItems: "center",
39-
height: "56px",
46+
height: 56,
4047
background: theme.palette.navbar.main,
4148
marginTop: 0,
4249
transition: "margin 150ms ease",
@@ -46,24 +53,60 @@ const useStyles = makeStyles((theme) => ({
4653
borderBottom: `1px solid #383838`,
4754
},
4855
fixed: {
49-
flex: "0",
56+
flex: 0,
57+
display: "flex",
58+
padding: 0,
5059
},
5160
fullWidth: {
52-
flex: "1",
61+
flex: 1,
5362
},
5463
logo: {
55-
flex: "0",
56-
height: "56px",
64+
alignItems: "center",
65+
display: "flex",
66+
height: 56,
5767
paddingLeft: theme.spacing(4),
5868
paddingRight: theme.spacing(2),
59-
borderRadius: 0,
6069
"& svg": {
61-
display: "block",
6270
width: 125,
6371
},
6472
},
6573
title: {
66-
flex: "1",
74+
flex: 1,
6775
textAlign: "center",
6876
},
77+
item: {
78+
padding: 0,
79+
},
80+
link: {
81+
alignItems: "center",
82+
color: "#A7A7A7",
83+
display: "flex",
84+
fontSize: 16,
85+
height: 56,
86+
padding: `0 ${theme.spacing(3)}px`,
87+
textDecoration: "none",
88+
transition: "background-color 0.3s ease",
89+
90+
"&:hover": {
91+
backgroundColor: fade(theme.palette.primary.light, 0.1),
92+
},
93+
94+
// NavLink adds this class when the current route matches.
95+
"&.active": {
96+
position: "relative",
97+
color: theme.palette.primary.contrastText,
98+
99+
"&::before": {
100+
content: `"{"`,
101+
left: 10,
102+
position: "absolute",
103+
},
104+
105+
"&::after": {
106+
content: `"}"`,
107+
position: "absolute",
108+
right: 10,
109+
},
110+
},
111+
},
69112
}))

0 commit comments

Comments
 (0)