Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe23dcd

Browse files
authored
feat: add top-level nav styles (#883)
Partially addresses #701.
1 parent 8813788 commit fe23dcd

File tree

1 file changed

+63
-21
lines changed

1 file changed

+63
-21
lines changed
+63-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import Button from "@material-ui/core/Button"
2-
import { makeStyles } from "@material-ui/core/styles"
1+
import List from "@material-ui/core/List"
2+
import ListItem from "@material-ui/core/ListItem"
3+
import { fade, makeStyles } from "@material-ui/core/styles"
34
import React from "react"
4-
import { Link } from "react-router-dom"
5+
import { NavLink } from "react-router-dom"
56
import { UserResponse } from "../../api/types"
67
import { Logo } from "../Icons"
78
import { UserDropdown } from "./UserDropdown"
@@ -14,29 +15,34 @@ export interface NavbarViewProps {
1415
export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut }) => {
1516
const styles = useStyles()
1617
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>
18+
<nav className={styles.root}>
19+
<List className={styles.fixed}>
20+
<ListItem className={styles.item}>
21+
<NavLink className={styles.logo} to="/">
22+
<Logo fill="white" opacity={1} width={125} />
23+
</NavLink>
24+
</ListItem>
25+
<ListItem button className={styles.item}>
26+
<NavLink className={styles.link} to="/templates">
27+
Templates
28+
</NavLink>
29+
</ListItem>
30+
</List>
2531
<div className={styles.fullWidth} />
2632
<div className={styles.fixed}>{user && <UserDropdown user={user} onSignOut={onSignOut} />}</div>
27-
</div>
33+
</nav>
2834
)
2935
}
3036

3137
const useStyles = makeStyles((theme) => ({
3238
root: {
3339
position: "relative",
3440
display: "flex",
35-
flex: "0",
41+
flex: 0,
3642
flexDirection: "row",
3743
justifyContent: "center",
3844
alignItems: "center",
39-
height: "56px",
45+
height: 56,
4046
background: theme.palette.navbar.main,
4147
marginTop: 0,
4248
transition: "margin 150ms ease",
@@ -46,24 +52,60 @@ const useStyles = makeStyles((theme) => ({
4652
borderBottom: `1px solid #383838`,
4753
},
4854
fixed: {
49-
flex: "0",
55+
flex: 0,
56+
display: "flex",
57+
padding: 0,
5058
},
5159
fullWidth: {
52-
flex: "1",
60+
flex: 1,
5361
},
5462
logo: {
55-
flex: "0",
56-
height: "56px",
63+
alignItems: "center",
64+
display: "flex",
65+
height: 56,
5766
paddingLeft: theme.spacing(4),
5867
paddingRight: theme.spacing(2),
59-
borderRadius: 0,
6068
"& svg": {
61-
display: "block",
6269
width: 125,
6370
},
6471
},
6572
title: {
66-
flex: "1",
73+
flex: 1,
6774
textAlign: "center",
6875
},
76+
item: {
77+
padding: 0,
78+
},
79+
link: {
80+
alignItems: "center",
81+
color: "#A7A7A7",
82+
display: "flex",
83+
fontSize: 16,
84+
height: 56,
85+
padding: `0 ${theme.spacing(3)}px`,
86+
textDecoration: "none",
87+
transition: "background-color 0.3s ease",
88+
89+
"&:hover": {
90+
backgroundColor: fade(theme.palette.primary.light, 0.1),
91+
},
92+
93+
// NavLink adds this class when the current route matches.
94+
"&.active": {
95+
position: "relative",
96+
color: theme.palette.primary.contrastText,
97+
98+
"&::before": {
99+
content: `"{"`,
100+
left: 10,
101+
position: "absolute",
102+
},
103+
104+
"&::after": {
105+
content: `"}"`,
106+
position: "absolute",
107+
right: 10,
108+
},
109+
},
110+
},
69111
}))

0 commit comments

Comments
 (0)