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"
3
4
import React from "react"
4
- import { Link } from "react-router-dom"
5
+ import { NavLink } from "react-router-dom"
5
6
import { UserResponse } from "../../api/types"
6
7
import { Logo } from "../Icons"
7
8
import { UserDropdown } from "./UserDropdown"
@@ -14,29 +15,34 @@ export interface NavbarViewProps {
14
15
export const NavbarView : React . FC < NavbarViewProps > = ( { user, onSignOut } ) => {
15
16
const styles = useStyles ( )
16
17
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 >
25
31
< div className = { styles . fullWidth } />
26
32
< div className = { styles . fixed } > { user && < UserDropdown user = { user } onSignOut = { onSignOut } /> } </ div >
27
- </ div >
33
+ </ nav >
28
34
)
29
35
}
30
36
31
37
const useStyles = makeStyles ( ( theme ) => ( {
32
38
root : {
33
39
position : "relative" ,
34
40
display : "flex" ,
35
- flex : "0" ,
41
+ flex : 0 ,
36
42
flexDirection : "row" ,
37
43
justifyContent : "center" ,
38
44
alignItems : "center" ,
39
- height : "56px" ,
45
+ height : 56 ,
40
46
background : theme . palette . navbar . main ,
41
47
marginTop : 0 ,
42
48
transition : "margin 150ms ease" ,
@@ -46,24 +52,60 @@ const useStyles = makeStyles((theme) => ({
46
52
borderBottom : `1px solid #383838` ,
47
53
} ,
48
54
fixed : {
49
- flex : "0" ,
55
+ flex : 0 ,
56
+ display : "flex" ,
57
+ padding : 0 ,
50
58
} ,
51
59
fullWidth : {
52
- flex : "1" ,
60
+ flex : 1 ,
53
61
} ,
54
62
logo : {
55
- flex : "0" ,
56
- height : "56px" ,
63
+ alignItems : "center" ,
64
+ display : "flex" ,
65
+ height : 56 ,
57
66
paddingLeft : theme . spacing ( 4 ) ,
58
67
paddingRight : theme . spacing ( 2 ) ,
59
- borderRadius : 0 ,
60
68
"& svg" : {
61
- display : "block" ,
62
69
width : 125 ,
63
70
} ,
64
71
} ,
65
72
title : {
66
- flex : "1" ,
73
+ flex : 1 ,
67
74
textAlign : "center" ,
68
75
} ,
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
+ } ,
69
111
} ) )
0 commit comments