forked from coderplex-org/coderplex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.js
164 lines (159 loc) · 3.75 KB
/
header.js
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import React from 'react';
import Headroom from 'react-headroom';
import NProgress from 'nprogress';
import Router from 'next/router';
import Link from 'next/link';
import GlobalStyles from './global-styles';
import Head from './head';
Router.onRouteChangeStart = () => {
NProgress.start();
};
Router.onRouteChangeComplete = () => {
NProgress.done();
};
Router.onRouteChangeError = () => {
NProgress.done();
};
export default props => {
const title =
props.url.pathname === '/'
? 'Home'
: props.url.pathname.split('/')[1].toUpperCase();
const navItems = [
{
title: 'Home',
path: '/',
external: false,
},
{
title: 'Learn',
path: '/learn',
external: false,
},
{
title: 'Space',
path: '/space',
external: false,
},
{
title: 'Events',
path: '/events',
external: false,
},
{
title: 'Blog',
path: 'https://medium.com/coderplex',
external: true,
},
];
return (
<Headroom>
<header>
<Head title={`${title} | Coderplex`} />
<GlobalStyles />
<div className="header__container">
<nav>
<div className="nav__logo">
<img src="/static/favicons/android-chrome-192x192.png" alt="" />
</div>
<ul className="nav__links">
{navItems.map(item => {
return (
<li key={item.title} className="nav__linkItem">
<Link href={item.path}>
<a
className={`nav__link ${props.url.pathname === item.path
? 'nav__link--active'
: ''}`}
target={item.external ? '_blank' : '_self'}
>
{item.title}
</a>
</Link>
</li>
);
})}
</ul>
</nav>
</div>
</header>
<style jsx>{`
header {
padding: 5px 20px;
width: 100%;
background: #fff;
z-index: 1000;
}
.header__container {
max-width: 1280px;
margin: 0 auto;
}
nav {
display: flex;
height: 70px;
align-items: center;
}
.nav__logo {
flex: 1;
display: flex;
align-items: center;
}
.nav__logo img {
width: 50px;
height: 50px;
margin-right: 5px;
}
.nav__links {
margin: 0;
padding: 0;
list-style: none;
flex: 2;
display: flex;
align-items: center;
}
.nav__linkItem {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
}
.nav__linkItem :global(.dropdown__linkItem) {
display: flex;
justify-content: center;
align-items: center;
}
.nav__linkItem img {
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 5px;
}
.nav__link {
text-decoration: none;
color: #666;
font-size: 14px;
padding-bottom: 4px;
}
.nav__link:hover {
color: #444;
}
.nav__link--active {
color: #444;
border-bottom: 2px solid #314159;
pointer-events: none;
}
@media (max-width: 700px) {
nav {
justify-content: center;
}
.nav__logo {
flex: initial;
}
.nav__links {
display: none;
}
}
`}</style>
</Headroom>
);
};