From 48b0b5481982b378277e517380cdd343773c7c64 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 16 May 2018 17:23:39 -0700 Subject: Add loading component --- packages/website/ts/components/portal/loading.tsx | 21 +++++ packages/website/ts/components/portal/portal.tsx | 92 ++++++++++++---------- .../ts/components/relayer_index/relayer_index.tsx | 14 ++-- 3 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 packages/website/ts/components/portal/loading.tsx (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/portal/loading.tsx b/packages/website/ts/components/portal/loading.tsx new file mode 100644 index 000000000..d804dd1b8 --- /dev/null +++ b/packages/website/ts/components/portal/loading.tsx @@ -0,0 +1,21 @@ +import CircularProgress from 'material-ui/CircularProgress'; +import * as React from 'react'; + +const CIRCULAR_PROGRESS_SIZE = 40; +const CIRCULAR_PROGRESS_THICKNESS = 5; + +export interface LoadingProps { + isLoading: boolean; + content: React.ReactNode; +} +export const Loading = (props: LoadingProps) => { + if (props.isLoading) { + return ( +
+ +
+ ); + } else { + return
{props.content}
; + } +}; diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 81afe57e5..bcb8e60ef 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -1,7 +1,6 @@ import { colors, Styles } from '@0xproject/react-shared'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; import * as DocumentTitle from 'react-document-title'; import { Link, Route, RouteComponentProps, Switch } from 'react-router-dom'; @@ -13,6 +12,7 @@ import { PortalDisclaimerDialog } from 'ts/components/dialogs/portal_disclaimer_ import { EthWrappers } from 'ts/components/eth_wrappers'; import { AssetPicker } from 'ts/components/generate_order/asset_picker'; import { BackButton } from 'ts/components/portal/back_button'; +import { Loading } from 'ts/components/portal/loading'; import { Menu } from 'ts/components/portal/menu'; import { Section } from 'ts/components/portal/section'; import { TextHeader } from 'ts/components/portal/text_header'; @@ -283,7 +283,7 @@ export class Portal extends React.Component { ); } private _renderAccountManagement(): React.ReactNode { - return this.props.blockchainIsLoaded ? ( + return ( @@ -291,18 +291,6 @@ export class Portal extends React.Component { - ) : ( - // TODO: consolidate this loading component with the one in relayer_index -
-
-
- -
-
-
); } private _renderEthWrapper(): React.ReactNode { @@ -310,14 +298,19 @@ export class Portal extends React.Component {
} body={ - + } /> } /> @@ -328,10 +321,15 @@ export class Portal extends React.Component {
} body={ - + } /> } /> @@ -342,10 +340,15 @@ export class Portal extends React.Component {
} body={ - + } /> } /> @@ -358,18 +361,23 @@ export class Portal extends React.Component {
} body={ - + } /> } /> diff --git a/packages/website/ts/components/relayer_index/relayer_index.tsx b/packages/website/ts/components/relayer_index/relayer_index.tsx index d8b06010b..b327c9817 100644 --- a/packages/website/ts/components/relayer_index/relayer_index.tsx +++ b/packages/website/ts/components/relayer_index/relayer_index.tsx @@ -60,14 +60,12 @@ export class RelayerIndex extends React.Component -
- {_.isUndefined(this.state.error) ? ( - - ) : ( - - )} -
+
+ {_.isUndefined(this.state.error) ? ( + + ) : ( + + )}
); } else { -- cgit