-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.jsx
135 lines (120 loc) · 2.91 KB
/
header.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React, {useContext, useEffect} from 'react';
import Link from 'next/link';
import Toggler from './toggler'
import UnitsToggler from './unitsToggler'
import styled from 'styled-components'
import LoadingIcon from './loading-icon'
import Logo from '../assets/logo4.svg'
import { useUser } from '../lib/user';
import { WeatherContext } from '../lib/weather';
const Nav = styled.nav`
max-width: ${props => props.theme.theme.contentWidths[0]};
margin: auto;
display: flex;
align-items: center;
padding: 15px 15px;
color: ${props => props.theme.theme.text.primary};
justify-content: space-between;
a {
color: ${props => props.theme.theme.text.primary};
}
`
const StyledHeader = styled.header`
background-color: ${props => props.theme.theme.bg.primary};
/* border-bottom: 1px solid #E9E6E9; */
`
const HeaderGroup = styled.div`
display: flex;
align-items: center;
a {
margin-right: 15px;
padding: 0;
display: block;
}
svg {
max-height: 44px;
max-width: 44px;
vertical-align:bottom
}
span{
margin-right: 15px;
display: flex;
}
`
const ProfileImg = styled.img`
width: 30px;
border-radius: 100%;
display: block;
`
const Header = () => {
const { user, loading } = useUser();
const { isLoading } = useContext(WeatherContext)
// console.log(isLoading)
return (
<StyledHeader>
<Nav>
<HeaderGroup>
<Link href="/">
<a><Logo /></a>
</Link>
{/* <Link href="/about">
<a>About</a>
</Link> */}
</HeaderGroup>
<HeaderGroup>
<LoadingIcon isLoading={isLoading} className='nav-item' />
{!loading &&
(user ? (
<>
<a href="/api/logout">Logout</a>
<Link href="/profile" >
<a><ProfileImg src={user.picture} alt="profile-photo"/></a>
</Link>
</>
) : (
<>
<a href="/api/#">Login</a>
</>
))}
{/* <Toggler /> */}
<UnitsToggler />
</HeaderGroup>
</Nav>
<style jsx>{`
header {
}
nav {
max-width: 42rem;
margin: 10px auto;
display: flex;
align-items: center;
padding: 5px 15px;
}
ul {
display: flex;
list-style: none;
margin-left: 0;
padding-left: 0;
}
li {
margin-right: 1rem;
}
li:nth-child(2) {
margin-right: auto;
}
a {
text-decoration: none;
vertical-align: center;
}
button {
font-size: 1rem;
color: #fff;
cursor: pointer;
border: none;
background: none;
}
`}</style>
</StyledHeader>
);
};
export default Header;