Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import Joyride, { CallBackProps, STATUS, Step, StoreHelpers } from 'react-joyride';
  4.  
  5. import { getSteps } from "./Walkthroughs";
  6.  
  7. import { endWalkthrough } from '../../actions'
  8.  
  9. export const Walkthrough = ({ walkthrough, endWalkthrough }) => {
  10.  
  11. const handleJoyrideCallback = (data) => {
  12. const { status, type } = data;
  13. const finishedStatuses = [STATUS.FINISHED, STATUS.SKIPPED];
  14.  
  15. if (finishedStatuses.includes(status)) {
  16. endWalkthrough();
  17. }
  18.  
  19. // // tslint:disable:no-console
  20. // console.groupCollapsed(type);
  21. // console.log(data);
  22. // console.groupEnd();
  23. // // tslint:enable:no-console
  24. };
  25.  
  26. const steps = getSteps(walkthrough.pathname);
  27. return (
  28. <Joyride
  29. steps={steps}
  30. run={walkthrough.run}
  31. continuous={true}
  32. scrollToFirstStep={true}
  33. showProgress={true}
  34. showSkipButton={true}
  35. callback={handleJoyrideCallback}
  36.  
  37. floaterProps={{
  38. styles: {
  39. wrapper: {
  40. zIndex: 1000,
  41. },
  42. },
  43. }}
  44. styles={{
  45. options: {
  46. zIndex: 1000,
  47. }
  48. }}
  49. />
  50. );
  51. };
  52.  
  53. const mapStateToProps = store => ({
  54. walkthrough: store.walkthrough,
  55. });
  56.  
  57. const mapDispatchToProps = dispatch => ({
  58. endWalkthrough: () => dispatch(endWalkthrough()),
  59. });
  60.  
  61. export default connect(
  62. mapStateToProps,
  63. mapDispatchToProps
  64. )(Walkthrough)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement