blob: 22fc7148192bf578687e7b117fb71dd1f5b966b1 (
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
46
|
import * as _ from 'lodash';
import * as React from 'react';
import Joyride, { CallbackData, Step, StyleOptions } from 'react-joyride';
import { zIndex } from 'ts/utils/style';
export interface OnboardingFlowProps {
steps: Step[];
stepIndex: number;
isRunning: boolean;
onClose: () => void;
}
const joyrideStyleOptions: StyleOptions = {
zIndex: zIndex.overlay,
};
// Wrapper around Joyride with defaults and styles set
export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
private _joyrideRef: React.RefObject<Joyride>;
constructor(props: OnboardingFlowProps) {
super(props);
this._joyrideRef = React.createRef();
}
public render(): React.ReactNode {
return (
<Joyride
ref={this._joyrideRef}
run={this.props.isRunning}
debug={true}
steps={this.props.steps}
stepIndex={this.props.stepIndex}
styles={{ options: joyrideStyleOptions }}
callback={this._handleChange.bind(this)}
/>
);
}
private _handleChange(data: CallbackData): void {
switch (data.action) {
case 'close':
this.props.onClose();
}
}
}
|