aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/top_bar
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-01 05:25:33 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-02 05:50:55 +0800
commitda8cf9981eda4a068c22d0107e07b704afda2584 (patch)
treef751e276b3b6b6d0f3f53a27327310760ee6aa5d /packages/website/ts/components/top_bar
parentbe64184cfa11dcabd543161b5d7a6726d4e7924d (diff)
downloaddexon-sol-tools-da8cf9981eda4a068c22d0107e07b704afda2584.tar.gz
dexon-sol-tools-da8cf9981eda4a068c22d0107e07b704afda2584.tar.zst
dexon-sol-tools-da8cf9981eda4a068c22d0107e07b704afda2584.zip
Implement simple menu
Diffstat (limited to 'packages/website/ts/components/top_bar')
-rw-r--r--packages/website/ts/components/top_bar/provider_display.tsx25
-rw-r--r--packages/website/ts/components/top_bar/provider_picker.tsx79
2 files changed, 14 insertions, 90 deletions
diff --git a/packages/website/ts/components/top_bar/provider_display.tsx b/packages/website/ts/components/top_bar/provider_display.tsx
index 18afee4ea..3f29d5ff3 100644
--- a/packages/website/ts/components/top_bar/provider_display.tsx
+++ b/packages/website/ts/components/top_bar/provider_display.tsx
@@ -5,19 +5,21 @@ import RaisedButton from 'material-ui/RaisedButton';
import ActionAccountBalanceWallet from 'material-ui/svg-icons/action/account-balance-wallet';
import Lock from 'material-ui/svg-icons/action/lock';
import * as React from 'react';
+import * as CopyToClipboard from 'react-copy-to-clipboard';
+import { Link } from 'react-router-dom';
import { Blockchain } from 'ts/blockchain';
import { InstallPrompt } from 'ts/components/top_bar/install_prompt';
-import { ProviderPicker } from 'ts/components/top_bar/provider_picker';
import { AccountConnection } from 'ts/components/ui/account_connection';
import { Container } from 'ts/components/ui/container';
import { DropDown } from 'ts/components/ui/drop_down';
import { Identicon } from 'ts/components/ui/identicon';
import { Island } from 'ts/components/ui/island';
+import { SimpleMenu, SimpleMenuItem } from 'ts/components/ui/simple_menu';
import { Text } from 'ts/components/ui/text';
import { Dispatcher } from 'ts/redux/dispatcher';
import { colors } from 'ts/style/colors';
-import { AccountState, ProviderType } from 'ts/types';
+import { AccountState, ProviderType, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { utils } from 'ts/utils/utils';
@@ -76,19 +78,20 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi
const accountState = this._getAccountState();
switch (accountState) {
case AccountState.Ready:
- case AccountState.Locked:
return (
- <ProviderPicker
- dispatcher={this.props.dispatcher}
- networkId={this.props.networkId}
- injectedProviderName={this.props.injectedProviderName}
- providerType={this.props.providerType}
- onToggleLedgerDialog={this.props.onToggleLedgerDialog}
- blockchain={this.props.blockchain}
- />
+ <SimpleMenu>
+ <CopyToClipboard text={this.props.userAddress}>
+ <SimpleMenuItem text="Copy Address to Clipboard" onClick={_.noop} />
+ </CopyToClipboard>
+ <SimpleMenuItem text="Use a Different Wallet..." onClick={this.props.onToggleLedgerDialog} />
+ <Link to={`${WebsitePaths.Portal}/account`} style={{ textDecoration: 'none' }}>
+ <SimpleMenuItem text="Manage Account" onClick={_.noop} />
+ </Link>
+ </SimpleMenu>
);
case AccountState.Disconnected:
return <InstallPrompt onToggleLedgerDialog={this.props.onToggleLedgerDialog} />;
+ case AccountState.Locked:
case AccountState.Loading:
default:
return null;
diff --git a/packages/website/ts/components/top_bar/provider_picker.tsx b/packages/website/ts/components/top_bar/provider_picker.tsx
deleted file mode 100644
index 7937f2e9d..000000000
--- a/packages/website/ts/components/top_bar/provider_picker.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { colors, constants as sharedConstants } from '@0xproject/react-shared';
-import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton';
-import * as React from 'react';
-import { Blockchain } from 'ts/blockchain';
-import { Dispatcher } from 'ts/redux/dispatcher';
-import { ProviderType } from 'ts/types';
-
-interface ProviderPickerProps {
- networkId: number;
- injectedProviderName: string;
- providerType: ProviderType;
- onToggleLedgerDialog: () => void;
- dispatcher: Dispatcher;
- blockchain: Blockchain;
-}
-
-interface ProviderPickerState {}
-
-export class ProviderPicker extends React.Component<ProviderPickerProps, ProviderPickerState> {
- public render(): React.ReactNode {
- const isLedgerSelected = this.props.providerType === ProviderType.Ledger;
- const menuStyle = {
- padding: 10,
- paddingTop: 15,
- paddingBottom: 15,
- };
- // Show dropdown with two options
- return (
- <div style={{ width: 225, overflow: 'hidden' }}>
- <RadioButtonGroup name="provider" defaultSelected={this.props.providerType}>
- <RadioButton
- onClick={this._onProviderRadioChanged.bind(this, ProviderType.Injected)}
- style={{ ...menuStyle, backgroundColor: !isLedgerSelected && colors.grey50 }}
- value={ProviderType.Injected}
- label={this._renderLabel(this.props.injectedProviderName, !isLedgerSelected)}
- />
- <RadioButton
- onClick={this._onProviderRadioChanged.bind(this, ProviderType.Ledger)}
- style={{ ...menuStyle, backgroundColor: isLedgerSelected && colors.grey50 }}
- value={ProviderType.Ledger}
- label={this._renderLabel('Ledger Nano S', isLedgerSelected)}
- />
- </RadioButtonGroup>
- </div>
- );
- }
- private _renderLabel(title: string, shouldShowNetwork: boolean): React.ReactNode {
- const label = (
- <div className="flex">
- <div style={{ fontSize: 14 }}>{title}</div>
- {shouldShowNetwork && this._renderNetwork()}
- </div>
- );
- return label;
- }
- private _renderNetwork(): React.ReactNode {
- const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
- return (
- <div className="flex" style={{ marginTop: 1 }}>
- <div className="relative" style={{ width: 14, paddingLeft: 14 }}>
- <img
- src={`/images/network_icons/${networkName.toLowerCase()}.png`}
- className="absolute"
- style={{ top: 6, width: 10 }}
- />
- </div>
- <div style={{ color: colors.lightGrey, fontSize: 11 }}>{networkName}</div>
- </div>
- );
- }
- private _onProviderRadioChanged(value: string): void {
- if (value === ProviderType.Ledger) {
- this.props.onToggleLedgerDialog();
- } else {
- // tslint:disable-next-line:no-floating-promises
- this.props.blockchain.updateProviderToInjectedAsync();
- }
- }
-}