diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-05-23 06:18:22 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-05-25 01:52:11 +0800 |
commit | b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7 (patch) | |
tree | 951170665292c24f2bd3720ad21200185d7e2e54 /packages/website/ts/components/onboarding | |
parent | 7af77d3eb0a73a0bd27898f5d3842c7dc7afef77 (diff) | |
download | dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar.gz dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar.bz2 dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar.lz dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar.xz dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.tar.zst dexon-sol-tools-b4e1ce59f9d5500667228f4ab1a2c9c4ca087ca7.zip |
Fix issue where modal can be out of sync with app state
Diffstat (limited to 'packages/website/ts/components/onboarding')
-rw-r--r-- | packages/website/ts/components/onboarding/onboarding_flow.tsx | 24 | ||||
-rw-r--r-- | packages/website/ts/components/onboarding/portal_onboarding_flow.tsx | 17 |
2 files changed, 31 insertions, 10 deletions
diff --git a/packages/website/ts/components/onboarding/onboarding_flow.tsx b/packages/website/ts/components/onboarding/onboarding_flow.tsx index 5bbf84e1b..1d98d5901 100644 --- a/packages/website/ts/components/onboarding/onboarding_flow.tsx +++ b/packages/website/ts/components/onboarding/onboarding_flow.tsx @@ -8,6 +8,8 @@ interface OnboardingFlowProps { steps: Step[]; stepIndex?: number; isRunning: boolean; + onClose: () => void; + onChange?: (options: any) => void; } const style: StyleOptions = { @@ -16,16 +18,28 @@ const style: StyleOptions = { // Wrapper around Joyride with defaults and styles set export class OnboardingFlow extends React.Component<OnboardingFlowProps> { + public static defaultProps: Partial<OnboardingFlowProps> = { + onChange: _.noop, + }; + public render(): React.ReactNode { - const { steps, stepIndex, isRunning } = this.props; return ( <Joyride - run={isRunning} + run={this.props.isRunning} debug={true} - steps={steps} - stepIndex={stepIndex} + steps={this.props.steps} + stepIndex={this.props.stepIndex} styles={{ options: style }} + callback={this._handleChange.bind(this)} /> ); } -}; + + private _handleChange(options: any): void { + switch (options.action) { + case 'close': + this.props.onClose(); + } + this.props.onChange(options); + } +} diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx index 57b209fac..9bccd0a9c 100644 --- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx +++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx @@ -1,29 +1,36 @@ import * as React from 'react'; +import { Step } from 'react-joyride'; import { OnboardingFlow } from 'ts/components/onboarding/onboarding_flow'; export interface PortalOnboardingFlowProps { stepIndex: number; isRunning: boolean; + setOnboardingShowing: (isShowing: boolean) => void; } -const steps = [ +const steps: Step[] = [ { target: '.wallet', - content: 'Hey!', + content: 'You are onboarding right now!', placement: 'right', disableBeacon: true, }, ]; -export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlow> { +export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowProps> { public render(): React.ReactNode { return ( <OnboardingFlow steps={steps} stepIndex={this.props.stepIndex} isRunning={this.props.isRunning} + onClose={this._handleClose.bind(this)} /> - ) + ); } -}; + + private _handleClose(): void { + this.props.setOnboardingShowing(false); + } +} |