-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMobileNav.js
108 lines (97 loc) · 3.13 KB
/
MobileNav.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
import React, { Component } from 'react'
import onClickOutside from 'react-onclickoutside'
import styled from 'styled-components'
import theme from './theme'
import Link from 'next/link'
import AnchorButton from './elements/AnchorButton'
const MobileNavLink = styled.a`
border-top: 1px solid ${theme.colors.blueExtraLight};
color: ${theme.colors.blue};
font-size: 0.8em;
font-weight: 700;
padding: 1.5em 1.5em 1.5em 1em;
text-decoration: none;
&:hover {
background-color: ${theme.colors.blueExtraLight};
color: ${theme.colors.blueLight};
}
&:last-of-type {
border-bottom: 1px solid ${theme.colors.blueExtraLight};
}
`
const MenuLink = styled.div`
color: ${theme.colors.blue};
cursor: pointer;
font-size: 0.8em;
font-weight: 700;
padding: 1.5em 1.5em 1.5em 1em;
text-decoration: none;
text-transform: uppercase;
&:hover {
background-color: ${theme.colors.blueExtraLight};
color: ${theme.colors.blueLight};
}
`
const NavMobileContainer = styled.div`
position: relative;
@media (min-width: 885px) {
display: none;
}
`
const MobileTopNav = styled.div`
display: flex;
justify-content: space-between;
margin: 0 auto;
`
const MobileLinks = styled.div`
&.is-visible {
display: flex;
flex-direction: column;
overflow: visible;
transition: transform .2s ease-in-out .1s, opacity .2s ease-in-out .2s;
}
&.is-hidden {
display: none;
overflow: hidden;
transform: translateY(-100%);
opacity: 0;
transition: transform .2s ease-in-out .1s, opacity .2s ease-in-out .2s;
}
`
class MobileMenu extends Component {
constructor() {
super()
this.state = { isOpen: false }
}
openMenu = () => {
this.setState({ isOpen: true })
}
closeMenu = () => {
this.setState({ isOpen: false })
}
handleClickOutside = () => {
this.closeMenu()
}
render() {
return (
<NavMobileContainer>
<MobileTopNav>
<MenuLink
onClick={this.state.isOpen ? this.closeMenu : this.openMenu} >
Menu
</MenuLink>
{/* <AnchorButton style={{ alignSelf: 'center', marginRight: '1em' }} href="https://ti.to/gdg-new-orleans/devfest-new-orleans-2019" small="true" target="_blank" rel="noopener noreferrer">Register now</AnchorButton> */}
</MobileTopNav>
<MobileLinks className={this.state.isOpen ? 'is-visible' : 'is-hidden'}>
<Link passHref href="/"><MobileNavLink onClick={this.closeMenu} >Home</MobileNavLink></Link>
<Link passHref href="/#speakers"><MobileNavLink onClick={this.closeMenu} >Speakers</MobileNavLink></Link>
<Link passHref href="/#schedule"><MobileNavLink onClick={this.closeMenu} >Talks</MobileNavLink></Link>
<Link passHref href="/#sponsors"><MobileNavLink onClick={this.closeMenu} >Sponsors</MobileNavLink></Link>
<Link passHref href="/location"><MobileNavLink onClick={this.closeMenu} >Location</MobileNavLink></Link>
<Link passHref href="/conduct"><MobileNavLink onClick={this.closeMenu} >Code of Conduct</MobileNavLink></Link>
</MobileLinks>
</NavMobileContainer>
)
}
}
export default onClickOutside(MobileMenu)