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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
import _ from 'lodash';
import * as React from 'react';
import { Link as ReactRouterLink } from 'react-router-dom';
import styled from 'styled-components';
import { colors } from 'ts/style/colors';
import { Button, ButtonWrap, Link } from 'ts/@next/components/button';
import { DevelopersDropDown } from 'ts/@next/components/dropdowns/developers_drop_down';
import { Dropdown } from 'ts/@next/components/dropdowns/mock';
import { Hamburger } from 'ts/@next/components/hamburger';
import { Section, Wrap } from 'ts/@next/components/layout';
import { Logo } from 'ts/@next/components/logo';
import { Paragraph } from 'ts/@next/components/text';
interface HeaderProps {
isOpen: boolean;
location?: Location;
}
interface HeaderState {
isOpen: boolean;
}
interface HeaderState {
isOpen: boolean;
}
interface NavItem {
url?: string;
id?: string;
text?: string;
}
const mobileProductLinks = [
{ url: '/next/0x-instant', text: '0x Instant' },
{ url: '/next/launch-kit', text: '0x Launch Kit' },
];
const navItems: NavItem[] = [
{ id: 'why', url: '/next/why', text: 'Why 0x' },
{
id: 'products',
url: '/next/0x-instant',
text: 'Products',
dropdownComponent: Dropdown,
},
{
id: 'developers',
url: '#',
text: 'Developers',
dropdownComponent: Dropdown,
},
{ id: 'about', url: '/next/about/mission', text: 'About' },
{ id: 'blog', url: '#', text: 'Blog' },
];
export class Header extends React.Component<HeaderProps, HeaderState> {
constructor(props: HeaderProps) {
super(props);
this.state = {
isOpen: false,
};
}
public render(): React.ReactNode {
return (
<StyledHeader isOpen={this.state.isOpen}>
<HeaderWrap>
<ReactRouterLink to="/next">
<Logo/>
</ReactRouterLink>
<Hamburger isOpen={this.state.isOpen} onClick={this._onMenuButtonClick.bind(this)}/>
<Nav>
<MobileProductLinksWrap>
{_.map(mobileProductLinks, (link, index) => (
<StyledLink
key={`productlink-${index}`}
href={link.url}
isTransparent={true}
isNoBorder={true}
>
{link.text}
</StyledLink>
))}
</MobileProductLinksWrap>
<StyledButtonWrap>
{_.map(navItems, (link, index) => this._getNavItem(link, index))}
</StyledButtonWrap>
</Nav>
<TradeButton href="#">Trade on 0x</TradeButton>
</HeaderWrap>
</StyledHeader>
);
}
private _onMenuButtonClick(): void {
this.setState({
isOpen: !this.state.isOpen,
});
}
private _getNavItem(link: NavItem, index: number): React.ReactNode {
const Wrapper = link.dropdownComponent ? LinkWrap : React.Fragment;
const Subnav = link.dropdownComponent;
return (
<Wrapper>
<StyledLink
key={`nav-${index}`}
href={link.url}
isTransparent={true}
isNoBorder={true}
>
{link.text}
</StyledLink>
{link.dropdownComponent &&
<DropdownWrap>
<Subnav />
</DropdownWrap>
}
</Wrapper>
);
}
}
const StyledHeader = styled(Section.withComponent('header'))<HeaderProps>`
@media (max-width: 768px) {
overflow: hidden;
min-height: ${props => props.isOpen ? '385px' : '70px'};
position: relative;
transition: min-height 0.25s ease-in-out;
:root & {
padding: 20px 20px 0 !important;
}
}
`;
const HeaderWrap = styled(Wrap)`
justify-content: space-between;
align-items: center;
@media (max-width: 768px) {
padding-top: 0;
display: flex;
padding-bottom: 0;
}
`;
const StyledButtonWrap = styled(ButtonWrap)`
display: flex;
@media (max-width: 768px) {
background-color: #022924;
display: flex;
flex-wrap: wrap;
padding: 20px 20px;
a {
text-align: left;
padding-left: 0;
}
}
button + button,
a + a,
a + button,
button + a {
margin-left: 0;
@media (min-width: 768px) {
margin-left: 10px;
}
}
`;
const MobileProductLinksWrap = styled(StyledButtonWrap)`
display: none;
@media (max-width: 768px) {
display: block;
background-color: transparent;
flex-direction: column;
a {
display: block;
width: 100%;
}
}
`;
const LinkWrap = styled.div`
position: relative;
a {
display: block;
}
&:hover > div {
display: block;
visibility: visible;
opacity: 1;
transform: translate3d(0, 0, 0);
transition: opacity 0.35s, transform 0.35s, visibility 0s;
}
`;
const DropdownWrap = styled.div`
width: 420px;
padding: 30px;
background-color: #ffffff;
color: #000000;
position: absolute;
top: 100%;
left: calc(50% - 210px);
visibility: hidden;
opacity: 0;
transform: translate3d(0, -10px, 0);
transition: opacity 0.35s, transform 0.35s, visibility 0s 0.35s;
&:after {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #ffffff;
border-width: 10px;
margin-left: -10px;
}
`;
const StyledLink = styled(Link)`
`;
const Nav = styled.div`
@media (max-width: 768px) {
background-color: ${colors.brandDark};
position: absolute;
top: 0;
left: 0;
right: 0;
padding-top: 65px;
}
`;
const TradeButton = styled(Button)`
padding: 14px 22px;
@media (max-width: 768px) {
display: none;
}
`;
|