blob: 350319c63995353b4a8d1e87dc69642afcc546e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import * as _ from 'lodash';
import * as React from 'react';
import Joyride, { Step, StyleOptions } from 'react-joyride';
import { zIndex } from 'ts/utils/style';
interface OnboardingFlowProps {
steps: Step[];
stepIndex: number;
isRunning: boolean;
onClose: () => void;
onChange?: (options: any) => void;
}
const style: StyleOptions = {
zIndex: zIndex.overlay,
};
// 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 {
return (
<Joyride
run={this.props.isRunning}
debug={true}
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);
}
}
|