-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathHeader.jsx
More file actions
176 lines (171 loc) · 4.67 KB
/
Header.jsx
File metadata and controls
176 lines (171 loc) · 4.67 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
import styled from 'styled-components'
import { ExternalLink } from "react-feather"
import Button from '@/components/common/Button';
import { Container } from '@/components/common/layout';
import { mediaQueries } from '@/styles/breakpoints';
import navigation from '@/data/navigation';
import { Inter } from "next/font/google"
const Nav = styled.nav`
position: relative;
top: 0;
left: 0;
width: 100%;
height: 52px;
z-index: 9997;
position: sticky;
transition: background-color 0.5s cubic-bezier(0.28, 0.11, 0.32, 1);
background-color: var(--material-background-color);
backdrop-filter: var(--material-filters);
box-shadow: 0 1px 0 0 var(--material-separator-color);
* {
box-sizing: content-box;
}
`;
const Wrapper = styled.div`
`;
const HeaderContainer = styled(Container)`
z-index: 2;
display: flex;
height: 52px;
align-items: center;
justify-content: space-between;
`;
const Title = styled.h2`
font-size: 21px;
line-height: 1.14286;
font-weight: 600;
letter-spacing: .011em;
font-family: "Inter","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
cursor: default;
display: block;
margin: 0;
padding: 0;
white-space: nowrap;
transition: color 0.5s cubic-bezier(0.28, 0.11, 0.32, 1);
color: var(--glyph-gray);
a {
display: inline-block;
letter-spacing: inherit;
line-height: inherit;
margin: 0;
text-decoration: none;
white-space: nowrap;
color: var(--glyph-gray);
opacity: .92;
}
`;
const Menu = styled.div`
font-size: 12px;
line-height: 1;
font-weight: 400;
letter-spacing: -.01em;
font-family: "SF Pro Text","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
display: flex;
align-items: center;
gap: 24px;
`;
const MenuTray = styled.div`
display: flex;
align-items: center;
gap: 24px;
@media ${mediaQueries.sm} {
display: none;
}
`;
const MenuItems = styled.ul`
@media only screen and (max-width: 767px) {
opacity: 0;
padding: 4px 24px 24px;
transform: translate3d(0, -150px, 0);
transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1) 0.5s,opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1) 0.2s;
}
`;
const MenuItem = styled.li`
margin-left: 24px;
float: left;
list-style: none;
display: flex;
gap: 4px;
align-items: center;
a {
color: var(--foreground-color);
display: inline-block;
line-height: 22px;
white-space: nowrap;
opacity: .88;
&:hover {
color: var(--glyph-blue);
}
}
${({ $current }) => $current ? `
&& a {
color: var(--foreground-color) !important;
opacity: 0.5;
}
` : ``}
`;
const MenuLink = styled(Link)``;
const StyledExternalLink = styled(ExternalLink)`
opacity: 0.5;
margin-top: -2px;
`;
const MenuCtaAnchor = styled.a`
display: none;
`;
const MenuCtaAnchorLabel = styled.span``;
const Actions = styled.div``;
const Action = styled.div``;
function Header() {
const { asPath } = useRouter();
return (
<Nav role="navigation">
<Wrapper>
<HeaderContainer>
<Title>
<Link href="/">CodeEdit</Link>
</Title>
<Menu>
<MenuCtaAnchor>
<MenuCtaAnchorLabel>Open Menu</MenuCtaAnchorLabel>
</MenuCtaAnchor>
<MenuCtaAnchor>
<MenuCtaAnchorLabel>Close Menu</MenuCtaAnchorLabel>
</MenuCtaAnchor>
<MenuTray>
<MenuItems>
{navigation.map(item => {
const isExternal = item.href.match(/(https?:\/\/[\w\d.-]+)/gi);
return (
<MenuItem key={item.href} $current={asPath === item.href} {...(isExternal ? { target: "_blank" } : {})}>
<MenuLink href={item.href}>
{item.label}
</MenuLink>
{isExternal && <StyledExternalLink size={11} />}
</MenuItem>
);
})}
</MenuItems>
</MenuTray>
<Actions>
<Action>
<label
htmlFor="codeeditnav-menustate"
className="codeeditnav-menucta"
>
<span className="codeeditnav-menucta-chevron"></span>
</label>
</Action>
<Action>
<Button href="https://github.com/CodeEditApp/CodeEdit/releases/latest" target="_blank" compact>Download</Button>
</Action>
</Actions>
</Menu>
</HeaderContainer>
</Wrapper>
</Nav>
);
}
export default Header;