aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/ui/simple_menu.tsx
blob: 45ee752e33270bbd855a55473989a194a5149837 (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
import { Link } from '@0x/react-shared';
import * as _ from 'lodash';
import * as React from 'react';
import * as CopyToClipboard from 'react-copy-to-clipboard';

import { Container } from 'ts/components/ui/container';
import { Text } from 'ts/components/ui/text';
import { colors } from 'ts/style/colors';
import { WebsitePaths } from 'ts/types';

export interface SimpleMenuProps {
    minWidth?: number | string;
}

export const SimpleMenu: React.StatelessComponent<SimpleMenuProps> = ({ children, minWidth }) => {
    return (
        <Container
            marginLeft="16px"
            marginRight="16px"
            marginBottom="16px"
            minWidth={minWidth}
            className="flex flex-column"
        >
            {children}
        </Container>
    );
};

SimpleMenu.defaultProps = {
    minWidth: '220px',
};

export interface SimpleMenuItemProps {
    displayText: string;
    onClick?: () => void;
}
export const SimpleMenuItem: React.StatelessComponent<SimpleMenuItemProps> = ({ displayText, onClick }) => {
    // Falling back to _.noop for onclick retains the hovering effect
    return (
        <Container marginTop="16px" className="flex flex-column">
            <Text
                fontSize="14px"
                fontColor={colors.darkGrey}
                onClick={onClick || _.noop.bind(_)}
                hoverColor={colors.mediumBlue}
            >
                {displayText}
            </Text>
        </Container>
    );
};

export interface CopyAddressSimpleMenuItemProps {
    userAddress: string;
    onClick?: () => void;
}
export const CopyAddressSimpleMenuItem: React.StatelessComponent<CopyAddressSimpleMenuItemProps> = ({
    userAddress,
    onClick,
}) => {
    return (
        <CopyToClipboard text={userAddress}>
            <SimpleMenuItem displayText="Copy Address to Clipboard" onClick={onClick} />
        </CopyToClipboard>
    );
};

export interface GoToAccountManagementSimpleMenuItemProps {
    onClick?: () => void;
}
export const GoToAccountManagementSimpleMenuItem: React.StatelessComponent<
    GoToAccountManagementSimpleMenuItemProps
> = ({ onClick }) => {
    return (
        <Link to={`${WebsitePaths.Portal}/account`}>
            <SimpleMenuItem displayText="Manage Account..." onClick={onClick} />
        </Link>
    );
};

export interface DifferentWalletSimpleMenuItemProps {
    onClick?: () => void;
}
export const DifferentWalletSimpleMenuItem: React.StatelessComponent<DifferentWalletSimpleMenuItemProps> = ({
    onClick,
}) => {
    return <SimpleMenuItem displayText="Use Ledger Wallet..." onClick={onClick} />;
};