Make tooltip appear to the left of the toggle when onboarding in progress

This commit is contained in:
fragosti
2018-07-24 15:09:47 -07:00
parent 3890f8224d
commit 5b6cf447e5
6 changed files with 20 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import ReactTooltip = require('react-tooltip');
import { Blockchain } from 'ts/blockchain';
import { AllowanceState, AllowanceStateView } from 'ts/components/ui/allowance_state_view';
import { Container } from 'ts/components/ui/container';
import { PointerDirection } from 'ts/components/ui/pointer';
import { Text } from 'ts/components/ui/text';
import { Dispatcher } from 'ts/redux/dispatcher';
import { BalanceErrs, Token, TokenState } from 'ts/types';
@@ -21,6 +22,7 @@ export interface AllowanceStateToggleProps {
userAddress: string;
onErrorOccurred?: (errType: BalanceErrs) => void;
refetchTokenStateAsync: () => Promise<void>;
tooltipDirection?: PointerDirection;
}
export interface AllowanceStateToggleState {
@@ -33,6 +35,7 @@ const DEFAULT_ALLOWANCE_AMOUNT_IN_BASE_UNITS = new BigNumber(2).pow(256).minus(1
export class AllowanceStateToggle extends React.Component<AllowanceStateToggleProps, AllowanceStateToggleState> {
public static defaultProps = {
onErrorOccurred: _.noop.bind(_),
tooltipDirection: PointerDirection.Right,
};
private static _getAllowanceState(tokenState: TokenState): AllowanceState {
if (!tokenState.isLoaded) {
@@ -62,7 +65,7 @@ export class AllowanceStateToggle extends React.Component<AllowanceStateTogglePr
<div
data-tip={true}
data-for={tooltipId}
data-place="right"
data-place={this.props.tooltipDirection}
onClick={this._onToggleAllowanceAsync.bind(this)}
>
<AllowanceStateView allowanceState={this.state.allowanceState} />

View File

@@ -24,7 +24,7 @@ export const OnboardingTooltip: React.StatelessComponent<OnboardingTooltipProps>
);
};
OnboardingTooltip.defaultProps = {
pointerDisplay: 'left',
pointerDisplay: PointerDirection.Left,
};
OnboardingTooltip.displayName = 'OnboardingTooltip';

View File

@@ -24,6 +24,7 @@ import { TradeHistory } from 'ts/components/trade_history/trade_history';
import { Container } from 'ts/components/ui/container';
import { FlashMessage } from 'ts/components/ui/flash_message';
import { Image } from 'ts/components/ui/image';
import { PointerDirection } from 'ts/components/ui/pointer';
import { Text } from 'ts/components/ui/text';
import { Wallet } from 'ts/components/wallet/wallet';
import { GenerateOrderForm } from 'ts/containers/generate_order_form';
@@ -355,6 +356,9 @@ export class Portal extends React.Component<PortalProps, PortalState> {
onAddToken={this._onAddToken.bind(this)}
onRemoveToken={this._onRemoveToken.bind(this)}
refetchTokenStateAsync={this._refetchTokenStateAsync.bind(this)}
toggleTooltipDirection={
this.props.isPortalOnboardingShowing ? PointerDirection.Left : PointerDirection.Right
}
/>
</Container>
{!isMobile && <Container marginTop="8px">{this._renderStartOnboarding()}</Container>}

View File

@@ -2,7 +2,12 @@ import { colors } from '@0xproject/react-shared';
import * as React from 'react';
import { styled } from 'ts/style/theme';
export type PointerDirection = 'top' | 'right' | 'bottom' | 'left';
export enum PointerDirection {
Top = 'top',
Right = 'right',
Bottom = 'bottom',
Left = 'left',
}
export interface PointerProps {
className?: string;

View File

@@ -14,6 +14,7 @@ import { DropDown, DropdownMouseEvent } from 'ts/components/ui/drop_down';
import { IconButton } from 'ts/components/ui/icon_button';
import { Identicon } from 'ts/components/ui/identicon';
import { Island } from 'ts/components/ui/island';
import { PointerDirection } from 'ts/components/ui/pointer';
import {
CopyAddressSimpleMenuItem,
DifferentWalletSimpleMenuItem,
@@ -67,6 +68,7 @@ export interface WalletProps {
onRemoveToken: () => void;
refetchTokenStateAsync: (tokenAddress: string) => Promise<void>;
style: React.CSSProperties;
toggleTooltipDirection?: PointerDirection;
}
interface WalletState {
@@ -420,6 +422,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
blockchain={this.props.blockchain}
token={config.token}
tokenState={config.tokenState}
tooltipDirection={this.props.toggleTooltipDirection}
refetchTokenStateAsync={async () => this.props.refetchTokenStateAsync(config.token.address)}
/>
);

View File

@@ -2,6 +2,7 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { Blockchain } from 'ts/blockchain';
import { PointerDirection } from 'ts/components/ui/pointer';
import { State } from 'ts/redux/reducer';
import { BalanceErrs, Token, TokenState } from 'ts/types';
@@ -14,6 +15,7 @@ interface AllowanceStateToggleProps {
token: Token;
tokenState: TokenState;
refetchTokenStateAsync: () => Promise<void>;
tooltipDirection?: PointerDirection;
}
interface ConnectedState {