aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/mobileNav.tsx
blob: 1aa8267559236e2209fba1131d67cf1868732f08 (plain) (blame)
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
import * as React from 'react';
import MediaQuery from 'react-responsive';
import styled from 'styled-components';

import { Link } from 'react-router-dom';

import { WrapGrid, WrapProps } from 'ts/components/newLayout';
import { WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants';

interface Props {
    isToggled: boolean;
    toggleMobileNav: () => void;
}

export class MobileNav extends React.PureComponent<Props> {
    public render(): React.ReactNode {
        const { isToggled, toggleMobileNav } = this.props;

        return (
            <MediaQuery maxWidth={800}>
                <Wrap isToggled={isToggled}>
                    <Section>
                        <h4>Products</h4>

                        <ul>
                            <li>
                                <Link to={WebsitePaths.Instant}>0x Instant</Link>
                            </li>
                            <li>
                                <Link to={WebsitePaths.LaunchKit}>0x Launch Kit</Link>
                            </li>
                        </ul>
                    </Section>

                    <Section isDark={true}>
                        <Grid as="ul" isFullWidth={true} isWrapped={true}>
                            <li>
                                <Link to={WebsitePaths.Why}>Why 0x</Link>
                            </li>
                            <li>
                                <Link to={WebsitePaths.AboutMission}>About</Link>
                            </li>
                            <li>
                                <a href={constants.URL_BLOG} target="_blank">
                                    Blog
                                </a>
                            </li>
                        </Grid>
                    </Section>

                    {isToggled && <Overlay onClick={toggleMobileNav} />}
                </Wrap>
            </MediaQuery>
        );
    }
}

const Wrap = styled.nav<{ isToggled: boolean }>`
    width: 100%;
    height: 357px;
    background-color: ${props => props.theme.mobileNavBgUpper};
    color: ${props => props.theme.mobileNavColor};
    transition: ${props => (props.isToggled ? 'visibility 0s, transform 0.5s' : 'visibility 0s 0.5s, transform 0.5s')};
    transform: translate3d(0, ${props => (props.isToggled ? 0 : '-100%')}, 0);
    visibility: ${props => !props.isToggled && 'hidden'};
    position: fixed;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    z-index: 20;
    top: 0;
    left: 0;
    font-size: 20px;

    a {
        padding: 15px 0;
        display: block;
        color: inherit;
    }

    h4 {
        font-size: 14px;
        opacity: 0.5;
    }
`;

const Overlay = styled.div`
    position: absolute;
    width: 100vw;
    height: 100vh;
    top: 100%;
    background: transparent;
    cursor: pointer;
`;

interface SectionProps {
    isDark?: boolean;
}
const Section = styled.div<SectionProps>`
    width: 100%;
    padding: 15px 30px;
    background-color: ${props => (props.isDark ? props.theme.mobileNavBgLower : 'transparent')};
`;

const Grid = styled(WrapGrid)<WrapProps>`
    justify-content: flex-start;

    li {
        width: 50%;
        flex-shrink: 0;
    }
`;