aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/@next/components/siteWrap.tsx
blob: 57fdcae43ebb821438138c520f56e8721a67d9ad (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import * as React from 'react';
import styled, { ThemeProvider } from 'styled-components';

import { colors } from 'ts/style/colors';

import { Footer } from 'ts/@next/components/footer';
import { Header } from 'ts/@next/components/header';
import { GlobalStyles } from 'ts/@next/constants/globalStyle';

// Note(ez): We'll define the theme and provide it via a prop
// e.g. theme dark/light/etc.
interface Props {
    theme?: 'dark' | 'light' | 'gray';
    children: any;
}

interface State {
    isMobileNavOpen: boolean;
}

// we proabbly want to put this somewhere else (themes)
export interface ThemeInterface {
    [key: string]: {
        bgColor: string;
        darkBgColor: string;
        lightBgColor: string;
        textColor: string;
        paragraphColor: string;
        linkColor: string;
        mobileNavBgUpper: string;
        mobileNavBgLower: string;
        mobileNavColor: string;
        dropdownBg: string;
        dropdownButtonBg: string;
        dropdownColor: string;
        headerButtonBg: string;
        footerBg: string;
        footerColor: string;
    };
}

const GLOBAL_THEMES: ThemeInterface = {
    dark: {
        bgColor: '#000000',
        darkBgColor: '#111A19',
        lightBgColor: '#003831',
        textColor: '#FFFFFF',
        paragraphColor: '#FFFFFF',
        linkColor: colors.brandLight,
        mobileNavBgUpper: '#003831',
        mobileNavBgLower: '#022924',
        mobileNavColor: '#FFFFFF',
        dropdownBg: '#111A19',
        dropdownButtonBg: '#003831',
        dropdownColor: '#FFFFFF',
        headerButtonBg: '#00AE99',
        footerBg: '#181818',
        footerColor: '#FFFFFF',
    },
    light: {
        bgColor: '#FFFFFF',
        textColor: '#000000',
        paragraphColor: '#474747',
        linkColor: colors.brandDark,
        mobileNavBgUpper: '#FFFFFF',
        mobileNavBgLower: '#F3F6F4',
        mobileNavColor: '#000000',
        dropdownBg: '#FBFBFB',
        dropdownButtonBg: '#F3F6F4',
        dropdownColor: '#003831',
        dropdownBorderColor: '#E4E4E4',
        headerButtonBg: '#003831',
        footerBg: '#F2F2F2',
        footerColor: '#000000',
    },
    gray: {
        bgColor: '#e0e0e0',
        textColor: '#000000',
        paragraphColor: '#777777',
        linkColor: colors.brandDark,
        dropdownBg: '#FFFFFF',
        dropdownButtonBg: '#F3F6F4',
        dropdownColor: '#003831',
        headerButtonBg: '#003831',
        footerBg: '#181818',
        footerColor: '#FFFFFF',
    },
};

export class SiteWrap extends React.Component<Props, State> {
    public state = {
        isMobileNavOpen: false,
    };

    public toggleMobileNav = () => {
        this.setState({
            isMobileNavOpen: !this.state.isMobileNavOpen,
        }, () => {
            const overflow = this.state.isMobileNavOpen ? 'hidden' : 'auto';
            document.documentElement.style.overflowY = overflow;
        });
    }

    public render(): React.ReactNode {
        const {
            children,
            theme = 'dark',
        } = this.props;
        const { isMobileNavOpen } = this.state;
        const currentTheme = GLOBAL_THEMES[theme];

        return (
            <>
                <ThemeProvider theme={currentTheme}>
                    <>
                        <GlobalStyles />
                        <Header isNavToggled={isMobileNavOpen} toggleMobileNav={this.toggleMobileNav} />
                        <Main isNavToggled={isMobileNavOpen}>
                            {children}
                        </Main>
                        <Footer/>
                    </>
                </ThemeProvider>
            </>
        );
    }
}

const Main = styled.main<{ isNavtoggled: boolean }>`
    transition: transform 0.5s, opacity 0.5s;
    transform: translate3d(0, ${props => props.isNavToggled ? '357px' : 0}, 0);
    opacity: ${props => props.isNavToggled && '0.5'};
`;