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