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
|
import { Styles } from '@0xproject/react-shared';
import * as _ from 'lodash';
import * as React from 'react';
import { CustomMenuItem } from 'ts/components/ui/custom_menu_item';
import { colors } from 'ts/style/colors';
import { WebsitePaths } from 'ts/types';
export interface MenuTheme {
paddingLeft: number;
textColor: string;
iconColor: string;
selectedIconColor: string;
selectedBackgroundColor: string;
}
export interface MenuItemEntry {
to: string;
labelText: string;
iconName: string;
}
export interface MenuProps {
selectedPath?: string;
theme?: MenuTheme;
menuItemEntries?: MenuItemEntry[];
}
export const defaultMenuItemEntries: 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}/generate`,
labelText: 'Generate order',
iconName: 'zmdi-arrow-right-top',
},
{
to: `${WebsitePaths.Portal}/fill`,
labelText: 'Fill order',
iconName: 'zmdi-arrow-left-bottom',
},
];
const DEFAULT_MENU_THEME: MenuTheme = {
paddingLeft: 30,
textColor: colors.white,
iconColor: colors.white,
selectedIconColor: colors.white,
selectedBackgroundColor: colors.menuItemDefaultSelectedBackground,
};
export const Menu: React.StatelessComponent<MenuProps> = (props: MenuProps) => {
return (
<div>
{_.map(props.menuItemEntries, entry => {
const isSelected = entry.to === props.selectedPath;
return (
<CustomMenuItem key={entry.to} to={entry.to}>
<MenuItemLabel
title={entry.labelText}
iconName={entry.iconName}
selected={isSelected}
theme={props.theme}
/>
</CustomMenuItem>
);
})}
</div>
);
};
Menu.defaultProps = {
theme: DEFAULT_MENU_THEME,
menuItemEntries: defaultMenuItemEntries,
};
interface MenuItemLabelProps {
title: string;
iconName: string;
selected: boolean;
theme: MenuTheme;
}
const MenuItemLabel: React.StatelessComponent<MenuItemLabelProps> = (props: MenuItemLabelProps) => {
const styles: Styles = {
root: {
backgroundColor: props.selected ? props.theme.selectedBackgroundColor : undefined,
paddingLeft: props.theme.paddingLeft,
},
icon: {
color: props.selected ? props.theme.selectedIconColor : props.theme.iconColor,
fontSize: 20,
},
text: {
color: props.theme.textColor,
fontWeight: props.selected ? 'bold' : 'normal',
fontSize: 16,
},
};
return (
<div className="flex py2" style={styles.root}>
<div className="pr1">
<i style={styles.icon} className={`zmdi ${props.iconName}`} />
</div>
<div className="pl1" style={styles.text}>
{props.title}
</div>
</div>
);
};
|