From cdcf624e9e6fe671611b239f903c2f2cb3097e7c Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 20 Jul 2018 08:52:14 -0700 Subject: Have basic lock and check working in walelt --- .../components/inputs/allowance_state_toggle.tsx | 10 ++++++ .../ts/components/ui/allowance_state_view.tsx | 42 ++++++++++++++++++++++ packages/website/ts/components/wallet/wallet.tsx | 28 ++++++++------- .../ts/containers/inputs/allowance_state_toggle.ts | 26 ++++++++++++++ 4 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 packages/website/ts/components/inputs/allowance_state_toggle.tsx create mode 100644 packages/website/ts/components/ui/allowance_state_view.tsx create mode 100644 packages/website/ts/containers/inputs/allowance_state_toggle.ts diff --git a/packages/website/ts/components/inputs/allowance_state_toggle.tsx b/packages/website/ts/components/inputs/allowance_state_toggle.tsx new file mode 100644 index 000000000..7e8628e64 --- /dev/null +++ b/packages/website/ts/components/inputs/allowance_state_toggle.tsx @@ -0,0 +1,10 @@ +import * as React from 'react'; +import { AllowanceStateView } from 'ts/components/ui/allowance_state_view'; + +export interface AllowanceStateToggleProps {} + +const flip = () => Math.random() < 0.5; + +export const AllowanceStateToggle: React.StatelessComponent = () => ( + +); diff --git a/packages/website/ts/components/ui/allowance_state_view.tsx b/packages/website/ts/components/ui/allowance_state_view.tsx new file mode 100644 index 000000000..55ad3a889 --- /dev/null +++ b/packages/website/ts/components/ui/allowance_state_view.tsx @@ -0,0 +1,42 @@ +import { colors } from '@0xproject/react-shared'; +import * as React from 'react'; +import { styled } from 'ts/style/theme'; + +export type AllowanceState = 'locked' | 'unlocked' | 'loading'; + +export interface AllowanceStateViewProps { + allowanceState: AllowanceState; +} + +export const AllowanceStateView: React.StatelessComponent = ({ allowanceState }) => { + switch (allowanceState) { + case 'locked': + return renderLock(); + case 'unlocked': + return renderCheck(); + case 'loading': + return
'...'
; + default: + return null; + } +}; + +const renderCheck = (color: string = '#37D400') => ( + + + + +); + +const renderLock = () => ( + + + +); diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index 40a8a23ea..84c091b5c 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -29,6 +29,7 @@ import { PlaceHolder } from 'ts/components/wallet/placeholder'; import { StandardIconRow } from 'ts/components/wallet/standard_icon_row'; import { WrapEtherItem } from 'ts/components/wallet/wrap_ether_item'; import { AllowanceToggle } from 'ts/containers/inputs/allowance_toggle'; +import { AllowanceStateToggle } from 'ts/containers/inputs/allowance_state_toggle'; import { Dispatcher } from 'ts/redux/dispatcher'; import { colors } from 'ts/style/colors'; import { @@ -396,10 +397,10 @@ export class Wallet extends React.Component { const shouldShowToggle = !_.isUndefined(config.allowanceToggleConfig); // if we don't have a toggle, we still want some space to the right of the "wrap" button so that it aligns with // the "unwrap" button in the row below - const toggle = shouldShowToggle ? ( - this._renderAllowanceToggle(config.allowanceToggleConfig) - ) : ( -
+ const toggle = ( + + {shouldShowToggle && this._renderAllowanceToggle(config.allowanceToggleConfig)} + ); return (
@@ -412,15 +413,16 @@ export class Wallet extends React.Component { } private _renderAllowanceToggle(config: AllowanceToggleConfig): React.ReactNode { // TODO: Error handling - return ( - this.props.refetchTokenStateAsync(config.token.address)} - /> - ); + // return ( + // this.props.refetchTokenStateAsync(config.token.address)} + // /> + // ); + return ; } private _renderAmount( amount: BigNumber, diff --git a/packages/website/ts/containers/inputs/allowance_state_toggle.ts b/packages/website/ts/containers/inputs/allowance_state_toggle.ts new file mode 100644 index 000000000..6e2698b0b --- /dev/null +++ b/packages/website/ts/containers/inputs/allowance_state_toggle.ts @@ -0,0 +1,26 @@ +import * as React from 'react'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; +import { Blockchain } from 'ts/blockchain'; +import { State } from 'ts/redux/reducer'; +import { BalanceErrs, Token, TokenState } from 'ts/types'; + +import { AllowanceStateToggle as AllowanceStateToggleComponent } from 'ts/components/inputs/allowance_state_toggle'; +import { Dispatcher } from 'ts/redux/dispatcher'; + +interface AllowanceStateToggleProps {} + +interface ConnectedState {} + +interface ConnectedDispatch { + dispatcher: Dispatcher; +} + +const mapStateToProps = (state: State, _ownProps: AllowanceStateToggleProps): ConnectedState => ({}); + +// const mapDispatchTopProps = (dispatch: Dispatch): ConnectedDispatch => ({}); + +export const AllowanceStateToggle: React.ComponentClass = connect( + mapStateToProps, + // mapDispatchTopProps, +)(AllowanceStateToggleComponent); -- cgit