aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/portal/portal_menu.tsx
blob: e073596e227c7bc3d80d8da0e0575f1d548e4046 (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
import { colors, Styles } from '@0xproject/react-shared';
import * as _ from 'lodash';
import * as React from 'react';
import { MenuItem } from 'ts/components/ui/menu_item';
import { Environments, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs';

export interface PortalMenuProps {
    selectedPath?: string;
}

interface MenuItemEntry {
    to: string;
    labelText: string;
    iconName: string;
}

const menuItemEntries: MenuItemEntry[] = [
    {
        to: `${WebsitePaths.Portal}/account`,
        labelText: 'Account Overview',
        iconName: 'zmdi-balance-wallet',
    },
    {
        to: `${WebsitePaths.Portal}/trades`,
        labelText: 'Trade history',
        iconName: 'zmdi-format-list-bulleted',
    },
    {
        to: `${WebsitePaths.Portal}/weth`,
        labelText: 'Wrapped ETH',
        iconName: 'zmdi-circle-o',
    },
    {
        to: `${WebsitePaths.Portal}/direct`,
        labelText: 'Trade direct',
        iconName: 'zmdi-swap',
    },
];

const DEFAULT_LABEL_COLOR = colors.darkerGrey;
const DEFAULT_ICON_COLOR = colors.darkerGrey;
const SELECTED_ICON_COLOR = colors.yellow900;

export const PortalMenu: React.StatelessComponent<PortalMenuProps> = (props: PortalMenuProps) => {
    return (
        <div style={{ paddingLeft: 185 }}>
            {_.map(menuItemEntries, entry => {
                const selected = entry.to === props.selectedPath;
                return (
                    <MenuItem key={entry.to} className="py2" to={entry.to}>
                        <PortalMenuItemLabel title={entry.labelText} iconName={entry.iconName} selected={selected} />
                    </MenuItem>
                );
            })}
        </div>
    );
};

interface PortalMenuItemLabelProps {
    title: string;
    iconName: string;
    selected: boolean;
}
const PortalMenuItemLabel: React.StatelessComponent<PortalMenuItemLabelProps> = (props: PortalMenuItemLabelProps) => {
    const styles: Styles = {
        iconStyle: {
            color: props.selected ? SELECTED_ICON_COLOR : DEFAULT_ICON_COLOR,
            fontSize: 20,
        },
        textStyle: {
            color: DEFAULT_LABEL_COLOR,
            fontWeight: props.selected ? 'bold' : 'normal',
        },
    };
    return (
        <div className="flex">
            <div className="pr1">
                <i style={styles.iconStyle} className={`zmdi ${props.iconName}`} />
            </div>
            <div className="pl1" style={styles.textStyle}>
                {props.title}
            </div>
        </div>
    );
};