aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/hamburger.tsx
blob: 435d206cdf9bd8088514c7f783aa4aa4fb199b9d (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
import * as React from 'react';
import styled from 'styled-components';

interface Props {
    isOpen: boolean;
    onClick?: () => void;
}

export const Hamburger: React.FunctionComponent<Props> = (props: Props) => {
    return (
        <StyledHamburger isOpen={props.isOpen} onClick={props.onClick}>
            <span />
            <span />
            <span />
        </StyledHamburger>
    );
};

const StyledHamburger =
    styled.button <
    Props >
    `
    background: none;
    border: 0;
    width: 22px;
    height: 16px;
    position: relative;
    z-index: 25;
    padding: 0;
    outline: none;
    user-select: none;

    @media (min-width: 800px) {
        display: none;
    }

    span {
        display: block;
        background-color: ${props => props.theme.textColor};
        width: 100%;
        height: 2px;
        margin-bottom: 5px;
        transform-origin: 4px 0px;
        transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
            background-color 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
            opacity 0.55s ease;

        &:first-child {
            //transform-origin: 0% 0%;
        }

        &:last-child {
            //transform-origin: 0% 100%;
        }

        ${props =>
            props.isOpen &&
            `
            opacity: 1;
            transform: rotate(45deg) translate(0, 1px);

            &:nth-child(2) {
                opacity: 0;
                transform: rotate(0deg) scale(0.2, 0.2);
            }

            &:last-child {
                transform: rotate(-45deg) translate(1px, -4px);
            }
        `}
    }
`;