From 3bf12a98a7062f02edb1cd3f4e1209ac34dc55ec Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 20 Jul 2018 09:55:08 -0700 Subject: Implement tooltips --- .../components/inputs/allowance_state_toggle.tsx | 52 ++++++++++++++++++++-- .../ts/components/ui/allowance_state_view.tsx | 12 +++-- 2 files changed, 56 insertions(+), 8 deletions(-) (limited to 'packages') diff --git a/packages/website/ts/components/inputs/allowance_state_toggle.tsx b/packages/website/ts/components/inputs/allowance_state_toggle.tsx index 4a9c99ca7..8908e457b 100644 --- a/packages/website/ts/components/inputs/allowance_state_toggle.tsx +++ b/packages/website/ts/components/inputs/allowance_state_toggle.tsx @@ -1,10 +1,54 @@ +import { colors } from '@0xproject/react-shared'; import * as React from 'react'; -import { AllowanceStateView } from 'ts/components/ui/allowance_state_view'; +import { AllowanceStateView, AllowanceState } from 'ts/components/ui/allowance_state_view'; +import { Token, TokenState } from 'ts/types'; +import ReactTooltip = require('react-tooltip'); export interface AllowanceStateToggleProps {} +export interface AllowanceStateToggleState { + allowanceState: AllowanceState; + token?: Token; + tokenState?: TokenState; +} + +const TOOLTIP_ID = 'AllowanceStateToggleTooltip'; + const flip = () => Math.random() < 0.5; -export const AllowanceStateToggle: React.StatelessComponent = () => ( - -); +export class AllowanceStateToggle extends React.Component { + public state = { + allowanceState: flip() ? AllowanceState.Loading : AllowanceState.Locked, + }; + public render(): React.ReactNode { + return ( +
+ {this._getTooltipContent()} +
+ +
+
+ ); + } + private _getTooltipContent(): React.ReactNode { + switch (this.state.allowanceState) { + case AllowanceState.Loading: + // TODO: support both awaiting confirmation and awaiting transaction. + return 'Please confirm in MetaMask'; + case AllowanceState.Locked: + return ( + + Click to enable WETH for trading + + ); + case AllowanceState.Unlocked: + return ( + + WETH is available for trading + + ); + default: + return null; + } + } +} diff --git a/packages/website/ts/components/ui/allowance_state_view.tsx b/packages/website/ts/components/ui/allowance_state_view.tsx index fce06c664..eecf88c34 100644 --- a/packages/website/ts/components/ui/allowance_state_view.tsx +++ b/packages/website/ts/components/ui/allowance_state_view.tsx @@ -3,7 +3,11 @@ import CircularProgress from 'material-ui/CircularProgress'; import * as React from 'react'; import { styled } from 'ts/style/theme'; -export type AllowanceState = 'locked' | 'unlocked' | 'loading'; +export enum AllowanceState { + Locked, + Unlocked, + Loading, +} export interface AllowanceStateViewProps { allowanceState: AllowanceState; @@ -11,11 +15,11 @@ export interface AllowanceStateViewProps { export const AllowanceStateView: React.StatelessComponent = ({ allowanceState }) => { switch (allowanceState) { - case 'locked': + case AllowanceState.Locked: return renderLock(); - case 'unlocked': + case AllowanceState.Unlocked: return renderCheck(); - case 'loading': + case AllowanceState.Loading: return ; default: return null; -- cgit v1.2.3