aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/top_bar/top_bar_menu_item.tsx
blob: 9f15cffbb4900e38e6d4368339550792d9073b89 (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
import { colors, Link } from '@0x/react-shared';
import * as _ from 'lodash';
import * as React from 'react';

import { CallToAction } from 'ts/components/ui/button';

const DEFAULT_STYLE = {
    color: colors.darkestGrey,
};

interface TopBarMenuItemProps {
    title: string;
    path?: string;
    isPrimary?: boolean;
    shouldOpenInNewTab?: boolean;
    style?: React.CSSProperties;
    className?: string;
    isNightVersion?: boolean;
}

interface TopBarMenuItemState {}

export class TopBarMenuItem extends React.Component<TopBarMenuItemProps, TopBarMenuItemState> {
    public static defaultProps: Partial<TopBarMenuItemProps> = {
        isPrimary: false,
        style: DEFAULT_STYLE,
        className: '',
        shouldOpenInNewTab: false,
        isNightVersion: false,
    };
    public render(): React.ReactNode {
        const menuItemColor = this.props.isNightVersion ? 'white' : this.props.style.color;
        const linkColor = _.isUndefined(menuItemColor) ? colors.darkestGrey : menuItemColor;
        const itemContent = this.props.isPrimary ? (
            <CallToAction padding="0.8em 1.5em">{this.props.title}</CallToAction>
        ) : (
            this.props.title
        );
        return (
            <div className={`center ${this.props.className}`} style={{ ...this.props.style, color: menuItemColor }}>
                <Link to={this.props.path} shouldOpenInNewTab={this.props.shouldOpenInNewTab} fontColor={linkColor}>
                    {itemContent}
                </Link>
            </div>
        );
    }
}