aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/components')
-rw-r--r--packages/website/ts/components/documentation/docs_content_top_bar.tsx171
-rw-r--r--packages/website/ts/components/documentation/docs_logo.tsx22
-rw-r--r--packages/website/ts/components/documentation/tutorial_button.tsx76
-rw-r--r--packages/website/ts/components/dropdowns/developers_drop_down.tsx50
-rw-r--r--packages/website/ts/components/ui/container.tsx1
-rw-r--r--packages/website/ts/components/ui/link.tsx42
6 files changed, 334 insertions, 28 deletions
diff --git a/packages/website/ts/components/documentation/docs_content_top_bar.tsx b/packages/website/ts/components/documentation/docs_content_top_bar.tsx
new file mode 100644
index 000000000..9b86c7296
--- /dev/null
+++ b/packages/website/ts/components/documentation/docs_content_top_bar.tsx
@@ -0,0 +1,171 @@
+import { DocsInfo, DocsMenu } from '@0xproject/react-docs';
+import {
+ colors,
+ constants as sharedConstants,
+ MenuSubsectionsBySection,
+ NestedSidebarMenu,
+ Styles,
+} from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import Drawer from 'material-ui/Drawer';
+import * as React from 'react';
+import { DocsLogo } from 'ts/components/documentation/docs_logo';
+import { Container } from 'ts/components/ui/container';
+import { Link } from 'ts/components/ui/link';
+import { Deco, Key, WebsitePaths } from 'ts/types';
+import { constants } from 'ts/utils/constants';
+import { Translate } from 'ts/utils/translate';
+
+export interface DocsContentTopBarProps {
+ location: Location;
+ translate: Translate;
+ menu?: DocsMenu;
+}
+
+interface DocsContentTopBarState {
+ isDrawerOpen: boolean;
+}
+
+interface MenuItemInfo {
+ title: string;
+ url: string;
+ iconUrl: string;
+ textStyle: React.CSSProperties;
+}
+
+export class DocsContentTopBar extends React.Component<DocsContentTopBarProps, DocsContentTopBarState> {
+ constructor(props: DocsContentTopBarProps) {
+ super(props);
+ this.state = {
+ isDrawerOpen: false,
+ };
+ }
+ public componentWillReceiveProps(nextProps: DocsContentTopBarProps): void {
+ if (nextProps.location.pathname !== this.props.location.pathname) {
+ this.setState({
+ isDrawerOpen: false,
+ });
+ }
+ }
+ public render(): React.ReactNode {
+ const menuItemInfos: MenuItemInfo[] = [
+ {
+ title: this.props.translate.get(Key.Github, Deco.Cap),
+ url: constants.URL_GITHUB_ORG,
+ iconUrl: '/images/developers/github_icon.svg',
+ textStyle: { color: colors.linkSectionGrey },
+ },
+ {
+ title: this.props.translate.get(Key.Forum, Deco.Cap),
+ url: constants.URL_FORUM,
+ iconUrl: '/images/developers/forum_icon.svg',
+ textStyle: { color: colors.linkSectionGrey },
+ },
+ {
+ title: this.props.translate.get(Key.LiveChat, Deco.Cap),
+ url: constants.URL_ZEROEX_CHAT,
+ iconUrl: '/images/developers/chat_icon.svg',
+ textStyle: { color: colors.lightLinkBlue, fontWeight: 'bold' },
+ },
+ ];
+ return (
+ <Container height={80}>
+ <Container className="flex items-center lg-pt3 md-pt3 sm-pt1 relative" width="100%">
+ <div className="col col-2 sm-hide xs-hide">
+ <Link
+ to={WebsitePaths.Home}
+ style={{ color: colors.linkSectionGrey }}
+ className="flex items-center text-decoration-none"
+ >
+ <i className="zmdi zmdi-chevron-left bold" style={{ fontSize: 16 }} />
+ <div className="pl1" style={{ fontSize: 16 }}>
+ 0xproject.com
+ </div>
+ </Link>
+ </div>
+ <div className="col col-4 md-hide sm-hide xs-hide" />
+ <div className="col col-6 md-pl4 md-ml4 sm-hide xs-hide">
+ <div className="flex items-center justify-between right" style={{ width: 300 }}>
+ {this._renderMenuItems(menuItemInfos)}
+ </div>
+ </div>
+ <div className="lg-hide md-hide">
+ <DocsLogo height={30} containerStyle={{ paddingTop: 6, paddingLeft: 18 }} />
+ </div>
+ <div className="md-hide lg-hide absolute" style={{ right: 18, top: 12 }}>
+ <div
+ style={{
+ fontSize: 30,
+ color: 'black',
+ cursor: 'pointer',
+ }}
+ >
+ <i
+ className="zmdi zmdi-menu"
+ style={{ color: colors.grey700 }}
+ onClick={this._onMenuButtonClick.bind(this)}
+ />
+ </div>
+ </div>
+ </Container>
+ <div
+ style={{
+ width: '100%',
+ height: 1,
+ backgroundColor: colors.grey300,
+ marginTop: 11,
+ }}
+ />
+ {this._renderDrawer()}
+ </Container>
+ );
+ }
+ private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode {
+ const menuItems = _.map(menuItemInfos, menuItemInfo => {
+ return (
+ <a
+ key={`menu-item-${menuItemInfo.title}`}
+ href={menuItemInfo.url}
+ target="_blank"
+ className="text-decoration-none"
+ style={{
+ fontSize: 16,
+ }}
+ >
+ <div className="flex">
+ <img src={menuItemInfo.iconUrl} width="18" />
+ <div className="flex items-center" style={{ ...menuItemInfo.textStyle, paddingLeft: 4 }}>
+ {menuItemInfo.title}
+ </div>
+ </div>
+ </a>
+ );
+ });
+ return menuItems;
+ }
+ private _renderDrawer(): React.ReactNode {
+ return (
+ <Drawer
+ open={this.state.isDrawerOpen}
+ docked={false}
+ openSecondary={true}
+ onRequestChange={this._onMenuButtonClick.bind(this)}
+ >
+ <div className="clearfix pl1">
+ <NestedSidebarMenu
+ topLevelMenu={this.props.menu}
+ menuSubsectionsBySection={{}}
+ shouldDisplaySectionHeaders={true}
+ shouldReformatMenuItemNames={false}
+ onMenuItemClick={this._onMenuButtonClick.bind(this)}
+ />
+ </div>
+ </Drawer>
+ );
+ }
+ private _onMenuButtonClick(): void {
+ this.setState({
+ isDrawerOpen: !this.state.isDrawerOpen,
+ });
+ }
+}
diff --git a/packages/website/ts/components/documentation/docs_logo.tsx b/packages/website/ts/components/documentation/docs_logo.tsx
new file mode 100644
index 000000000..570a81bca
--- /dev/null
+++ b/packages/website/ts/components/documentation/docs_logo.tsx
@@ -0,0 +1,22 @@
+import * as React from 'react';
+import { Link } from 'react-router-dom';
+import { WebsitePaths } from 'ts/types';
+
+export interface DocsLogoProps {
+ height: number;
+ containerStyle?: React.CSSProperties;
+}
+
+export const DocsLogo: React.StatelessComponent<DocsLogoProps> = props => {
+ return (
+ <div style={props.containerStyle}>
+ <Link to={`${WebsitePaths.Docs}`} className="text-decoration-none">
+ <img src="/images/docs_logo.svg" height={props.height} />
+ </Link>
+ </div>
+ );
+};
+
+DocsLogo.defaultProps = {
+ containerStyle: {},
+};
diff --git a/packages/website/ts/components/documentation/tutorial_button.tsx b/packages/website/ts/components/documentation/tutorial_button.tsx
new file mode 100644
index 000000000..22480888e
--- /dev/null
+++ b/packages/website/ts/components/documentation/tutorial_button.tsx
@@ -0,0 +1,76 @@
+import { colors } from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { Link } from 'react-router-dom';
+import { Text } from 'ts/components/ui/text';
+import { Deco, Key, TutorialInfo } from 'ts/types';
+import { Translate } from 'ts/utils/translate';
+
+export interface TutorialButtonProps {
+ translate: Translate;
+ tutorialInfo: TutorialInfo;
+}
+
+export interface TutorialButtonState {
+ isHovering: boolean;
+}
+
+export class TutorialButton extends React.Component<TutorialButtonProps, TutorialButtonState> {
+ constructor(props: TutorialButtonProps) {
+ super(props);
+ this.state = {
+ isHovering: false,
+ };
+ }
+ public render(): React.ReactNode {
+ return (
+ <Link
+ to={this.props.tutorialInfo.location}
+ style={{ textDecoration: 'none' }}
+ onMouseEnter={this._onHover.bind(this)}
+ onMouseLeave={this._onHoverOff.bind(this)}
+ >
+ <div
+ className="flex relative"
+ style={{
+ borderRadius: 4,
+ border: `1px solid ${this.state.isHovering ? colors.lightLinkBlue : '#dfdfdf'}`,
+ padding: 20,
+ marginBottom: 15,
+ backgroundColor: this.state.isHovering ? '#e7f1fd' : colors.white,
+ }}
+ >
+ <div className="col col-1 flex items-center sm-pr3">
+ <img src={this.props.tutorialInfo.iconUrl} height={40} />
+ </div>
+ <div className="pl2 col col-10">
+ <Text Tag="div" fontSize="18" fontColor={colors.lightLinkBlue} fontWeight="bold">
+ {this.props.translate.get(this.props.tutorialInfo.title as Key, Deco.Cap)}
+ </Text>
+ <Text Tag="div" fontColor="#555555" fontSize="16">
+ {this.props.translate.get(this.props.tutorialInfo.description as Key, Deco.Cap)}
+ </Text>
+ </div>
+ <div className="col col-1 flex items-center justify-end">
+ <div className="right">
+ <i
+ className="zmdi zmdi-chevron-right bold"
+ style={{ fontSize: 26, color: colors.lightLinkBlue }}
+ />
+ </div>
+ </div>
+ </div>
+ </Link>
+ );
+ }
+ private _onHover(_event: React.FormEvent<HTMLInputElement>): void {
+ this.setState({
+ isHovering: true,
+ });
+ }
+ private _onHoverOff(): void {
+ this.setState({
+ isHovering: false,
+ });
+ }
+}
diff --git a/packages/website/ts/components/dropdowns/developers_drop_down.tsx b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
index d66e75722..7d310df72 100644
--- a/packages/website/ts/components/dropdowns/developers_drop_down.tsx
+++ b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
@@ -1,9 +1,10 @@
import { colors } from '@0xproject/react-shared';
+import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
import * as React from 'react';
-import { Link } from 'react-router-dom';
import { Container } from 'ts/components/ui/container';
import { DropDown } from 'ts/components/ui/drop_down';
+import { Link } from 'ts/components/ui/link';
import { Text } from 'ts/components/ui/text';
import { Deco, Key, ObjectMap, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants';
@@ -11,55 +12,48 @@ import { Translate } from 'ts/utils/translate';
interface LinkInfo {
link: string;
- shouldOpenNewTab: boolean;
+ shouldOpenInNewTab?: boolean;
}
const gettingStartedKeyToLinkInfo1: ObjectMap<LinkInfo> = {
[Key.BuildARelayer]: {
link: `${WebsitePaths.Wiki}#Build-A-Relayer`,
- shouldOpenNewTab: false,
},
- [Key.IntroTutorial]: {
+ [Key.OrderBasics]: {
link: `${WebsitePaths.Wiki}#Create,-Validate,-Fill-Order`,
- shouldOpenNewTab: false,
},
};
const gettingStartedKeyToLinkInfo2: ObjectMap<LinkInfo> = {
- [Key.TradingTutorial]: {
- link: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`,
- shouldOpenNewTab: false,
- },
- [Key.EthereumDevelopment]: {
+ [Key.DevelopOnEthereum]: {
link: `${WebsitePaths.Wiki}#Ethereum-Development`,
- shouldOpenNewTab: false,
+ },
+ [Key.UseSharedLiquidity]: {
+ link: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`,
},
};
const popularDocsToLinkInfos: ObjectMap<LinkInfo> = {
[Key.ZeroExJs]: {
link: WebsitePaths.ZeroExJs,
- shouldOpenNewTab: false,
},
[Key.Connect]: {
link: WebsitePaths.Connect,
- shouldOpenNewTab: false,
},
[Key.SmartContract]: {
link: WebsitePaths.SmartContracts,
- shouldOpenNewTab: false,
},
};
const usefulLinksToLinkInfo: ObjectMap<LinkInfo> = {
[Key.Github]: {
link: constants.URL_GITHUB_ORG,
- shouldOpenNewTab: true,
+ shouldOpenInNewTab: true,
},
[Key.Whitepaper]: {
link: WebsitePaths.Whitepaper,
- shouldOpenNewTab: true,
+ shouldOpenInNewTab: true,
},
[Key.Sandbox]: {
link: constants.URL_SANDBOX,
- shouldOpenNewTab: true,
+ shouldOpenInNewTab: true,
},
};
@@ -128,7 +122,7 @@ export class DevelopersDropDown extends React.Component<DevelopersDropDownProps,
}}
>
<Link
- to={WebsitePaths.ZeroExJs}
+ to={WebsitePaths.Docs}
className="text-decoration-none"
style={{
color: colors.lightBlueA700,
@@ -168,18 +162,18 @@ export class DevelopersDropDown extends React.Component<DevelopersDropDownProps,
const links = _.map(keyToLinkInfo, (linkInfo: LinkInfo, key: string) => {
i++;
const isLast = i === numLinks;
- const linkText = this.props.translate.get(key as Key, Deco.CapWords);
+ const linkText = this.props.translate.get(key as Key, Deco.Cap);
return (
<div className={`pr1 pt1 ${!isLast && 'pb1'}`} key={`dev-dropdown-link-${key}`}>
- {linkInfo.shouldOpenNewTab ? (
- <a target="_blank" className="text-decoration-none" style={linkStyle} href={linkInfo.link}>
- {linkText}
- </a>
- ) : (
- <Link to={linkInfo.link} className="text-decoration-none" style={linkStyle}>
- {linkText}
- </Link>
- )}
+ <Link
+ to={linkInfo.link}
+ isExternal={!!linkInfo.shouldOpenInNewTab}
+ shouldOpenInNewTab={linkInfo.shouldOpenInNewTab}
+ className="text-decoration-none"
+ style={linkStyle}
+ >
+ {linkText}
+ </Link>
</div>
);
});
diff --git a/packages/website/ts/components/ui/container.tsx b/packages/website/ts/components/ui/container.tsx
index f2ae68b70..1e0bfd959 100644
--- a/packages/website/ts/components/ui/container.tsx
+++ b/packages/website/ts/components/ui/container.tsx
@@ -15,6 +15,7 @@ export interface ContainerProps {
paddingRight?: StringOrNum;
paddingLeft?: StringOrNum;
backgroundColor?: string;
+ background?: string;
borderRadius?: StringOrNum;
maxWidth?: StringOrNum;
maxHeight?: StringOrNum;
diff --git a/packages/website/ts/components/ui/link.tsx b/packages/website/ts/components/ui/link.tsx
new file mode 100644
index 000000000..252199457
--- /dev/null
+++ b/packages/website/ts/components/ui/link.tsx
@@ -0,0 +1,42 @@
+import * as React from 'react';
+import { Link as ReactRounterLink } from 'react-router-dom';
+
+export interface LinkProps {
+ to: string;
+ isExternal?: boolean;
+ shouldOpenInNewTab?: boolean;
+ style?: React.CSSProperties;
+ className?: string;
+}
+
+export const Link: React.StatelessComponent<LinkProps> = ({
+ style,
+ className,
+ isExternal,
+ to,
+ shouldOpenInNewTab,
+ children,
+}) => {
+ if (isExternal) {
+ return (
+ <a target={shouldOpenInNewTab && '_blank'} className={className} style={style} href={to}>
+ {children}
+ </a>
+ );
+ } else {
+ return (
+ <ReactRounterLink to={to} className={className} style={style}>
+ {children}
+ </ReactRounterLink>
+ );
+ }
+};
+
+Link.defaultProps = {
+ isExternal: false,
+ shouldOpenInNewTab: false,
+ style: {},
+ className: '',
+};
+
+Link.displayName = 'Link';