Remove type prop and instead infer it from the value of to

This commit is contained in:
Fabio Berger
2018-10-05 14:55:28 +01:00
parent 5f2cd33da0
commit fa6bd34899
16 changed files with 69 additions and 95 deletions

View File

@@ -1,13 +1,5 @@
import { DocsInfo } from '@0xproject/react-docs';
import {
ALink,
colors,
constants as sharedConstants,
Link,
LinkType,
NestedSidebarMenu,
Styles,
} from '@0xproject/react-shared';
import { ALink, colors, constants as sharedConstants, Link, NestedSidebarMenu, Styles } from '@0xproject/react-shared';
import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer';
@@ -177,7 +169,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
path={constants.URL_BLOG}
style={styles.menuItem}
isNightVersion={isNightVersion}
linkType={LinkType.External}
shouldOpenInNewTab={true}
/>
<TopBarMenuItem
title={this.props.translate.get(Key.About, Deco.Cap)}
@@ -285,7 +277,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</MenuItem>
</Link>
)}
<Link to={WebsitePaths.Whitepaper} type={LinkType.External} shouldOpenInNewTab={true}>
<Link to={WebsitePaths.Whitepaper} shouldOpenInNewTab={true}>
<MenuItem className="py2">{this.props.translate.get(Key.Whitepaper, Deco.Cap)}</MenuItem>
</Link>
<Link to={WebsitePaths.About}>
@@ -294,7 +286,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
<Link to={WebsitePaths.Careers}>
<MenuItem className="py2">{this.props.translate.get(Key.Careers, Deco.Cap)}</MenuItem>
</Link>
<Link to={constants.URL_BLOG} type={LinkType.External} shouldOpenInNewTab={true}>
<Link to={constants.URL_BLOG} shouldOpenInNewTab={true}>
<MenuItem className="py2">{this.props.translate.get(Key.Blog, Deco.Cap)}</MenuItem>
</Link>
<Link to={WebsitePaths.FAQ}>

View File

@@ -1,4 +1,4 @@
import { colors, Link, LinkType } from '@0xproject/react-shared';
import { colors, Link } from '@0xproject/react-shared';
import * as _ from 'lodash';
import * as React from 'react';
@@ -12,7 +12,7 @@ interface TopBarMenuItemProps {
title: string;
path?: string;
isPrimary?: boolean;
linkType: LinkType;
shouldOpenInNewTab?: boolean;
style?: React.CSSProperties;
className?: string;
isNightVersion?: boolean;
@@ -25,6 +25,7 @@ export class TopBarMenuItem extends React.Component<TopBarMenuItemProps, TopBarM
isPrimary: false,
style: DEFAULT_STYLE,
className: '',
shouldOpenInNewTab: false,
isNightVersion: false,
};
public render(): React.ReactNode {
@@ -37,7 +38,7 @@ export class TopBarMenuItem extends React.Component<TopBarMenuItemProps, TopBarM
);
return (
<div className={`center ${this.props.className}`} style={{ ...this.props.style, color: menuItemColor }}>
<Link to={this.props.path} type={this.props.linkType} fontColor={linkColor}>
<Link to={this.props.path} shouldOpenInNewTab={this.props.shouldOpenInNewTab} fontColor={linkColor}>
{itemContent}
</Link>
</div>