aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/portal/drawer_menu.tsx
blob: 3a8c69a7022705951c563aa975cdebf5724a45ba (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
import { Styles } from '@0xproject/react-shared';
import * as _ from 'lodash';
import * as React from 'react';

import { Blockchain } from 'ts/blockchain';
import { defaultMenuItemEntries, Menu } from 'ts/components/portal/menu';
import { Identicon } from 'ts/components/ui/identicon';
import { Text } from 'ts/components/ui/text';
import { colors } from 'ts/style/colors';
import { ProviderType, WebsitePaths } from 'ts/types';
import { utils } from 'ts/utils/utils';

const IDENTICON_DIAMETER = 45;
const BORDER_RADIUS = '50%';

const styles: Styles = {
    root: {
        backgroundColor: colors.drawerMenuBackground,
        width: '100%',
        height: '100%',
    },
    identicon: {
        borderWidth: 3,
        borderStyle: 'solid',
        borderColor: colors.white,
        borderRadius: BORDER_RADIUS,
        MozBorderRadius: BORDER_RADIUS,
        WebkitBorderRadius: BORDER_RADIUS,
    },
};

export interface DrawerMenuProps {
    selectedPath?: string;
    userAddress?: string;
    injectedProviderName: string;
    providerType: ProviderType;
    blockchain?: Blockchain;
    blockchainIsLoaded: boolean;
}
export const DrawerMenu = (props: DrawerMenuProps) => {
    const relayerItemEntry = {
        to: WebsitePaths.Portal,
        labelText: 'Relayer ecosystem',
        iconName: 'zmdi-portable-wifi',
    };
    const menuItemEntries = _.concat(relayerItemEntry, defaultMenuItemEntries);
    const accountState = utils.getAccountState(
        props.blockchainIsLoaded && !_.isUndefined(props.blockchain),
        props.providerType,
        props.injectedProviderName,
        props.userAddress,
    );
    const displayMessage = utils.getReadableAccountState(accountState, props.userAddress);
    return (
        <div style={styles.root}>
            <Header userAddress={props.userAddress} displayMessage={displayMessage} />
            <Menu selectedPath={props.selectedPath} menuItemEntries={menuItemEntries} />
        </div>
    );
};

interface HeaderProps {
    userAddress?: string;
    displayMessage: string;
}
const Header = (props: HeaderProps) => {
    return (
        <div className="flex flex-center py4">
            <div className="flex flex-column mx-auto items-center">
                <Identicon address={props.userAddress} diameter={IDENTICON_DIAMETER} style={styles.identicon} />
                <Text className="pt2" fontColor={colors.white}>
                    {props.displayMessage}
                </Text>
            </div>
        </div>
    );
};