|
| 1 | +// @ts-nocheck |
| 2 | +import * as React from 'react'; |
| 3 | +import { useState, useEffect } from 'react'; |
| 4 | +import { useLocation } from 'react-router-dom'; |
| 5 | +import { Steps, Hints } from 'intro.js-react'; |
| 6 | +import 'intro.js/introjs.css'; |
| 7 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
| 8 | +import { |
| 9 | + faQuestion, |
| 10 | +} from '@fortawesome/free-solid-svg-icons'; |
| 11 | + |
| 12 | +export default function Tutorial(): JSX.Element { |
| 13 | + const [stepsEnabled, setStepsEnabled] = useState(false); |
| 14 | + const [initialStep, setInitialStep] = useState(0); |
| 15 | + const [steps, setSteps] = useState([ |
| 16 | + { |
| 17 | + title: 'Reactime Tutorial', |
| 18 | + intro: 'A performance and state managment tool for React apps.', |
| 19 | + position: 'top', |
| 20 | + }, |
| 21 | + { |
| 22 | + title: 'Actions', |
| 23 | + element: '.action-container', |
| 24 | + intro: "<ul><li>Reactime records a snapshot whenever a target application's state is changed</li></ul>", |
| 25 | + position: 'right', |
| 26 | + }, |
| 27 | + { |
| 28 | + element: '.individual-action', |
| 29 | + title: 'Snapshot', |
| 30 | + intro: '<ul><li>Each snapshot allows the user to jump to any previously recorded state.</li> <li>It also detects the amount of renders of each component and average time of rendering</li></ul>.', |
| 31 | + position: 'right', |
| 32 | + }, |
| 33 | + { |
| 34 | + title: 'Timejump', |
| 35 | + element: '.rc-slider', |
| 36 | + intro: '<ul><li>Use the slider to go back in time to a particular state change</li><li>Click the Play button to run through each state change automatically</li></ul>', |
| 37 | + position: 'top', |
| 38 | + }, |
| 39 | + { |
| 40 | + title: 'Lock Button', |
| 41 | + element: '.pause-button', |
| 42 | + intro: '<ul><li>Use button to lock Reactime to the target application\'s tab in the Chrome Browser</li></ul>', |
| 43 | + position: 'top', |
| 44 | + }, |
| 45 | + { |
| 46 | + title: 'Split Button', |
| 47 | + element: '.split-button', |
| 48 | + intro: '<ul> <li>Use button to split Reactime into two windows in order to view multiple tabs simultaneously</li> </ul>', |
| 49 | + position: 'top', |
| 50 | + }, |
| 51 | + { |
| 52 | + title: 'Download Button', |
| 53 | + element: '.export-button', |
| 54 | + intro: '<ul><li>Use button to download a JSON file of all snapshots</li> </ul>', |
| 55 | + position: 'top', |
| 56 | + }, |
| 57 | + { |
| 58 | + title: 'Upload Button', |
| 59 | + element: '.import-button', |
| 60 | + intro: '<ul><li>Use button to upload a previously downloaded JSON file for snapshot comparisons</li></ul>', |
| 61 | + position: 'top', |
| 62 | + }, |
| 63 | + { |
| 64 | + element: '.map-tab', |
| 65 | + title: 'Map Tab', |
| 66 | + intro: '<ul><li>This tab visually displays a component hierarchy tree for your app</li></ul>', |
| 67 | + position: 'bottom', |
| 68 | + }, |
| 69 | + { |
| 70 | + title: 'Performance Tab', |
| 71 | + element: '.performance-tab', |
| 72 | + intro: '<ul><li>User can save a series of state snapshots and use it to analyze changes in component, render performance between current, and previous series of snapshots.</li> <li>User can save a series of state snapshots and use it to analyze changes in component render performance between current and previous series of snapshots.</li></ul>', |
| 73 | + position: 'bottom', |
| 74 | + }, |
| 75 | + { |
| 76 | + title: 'History Tab', |
| 77 | + element: '.history-tab', |
| 78 | + intro: '<ul><li>This tab visually displays a history of each snapshot</li></ul>', |
| 79 | + position: 'bottom', |
| 80 | + }, |
| 81 | + { |
| 82 | + title: 'Web Metrics Tab', |
| 83 | + element: '.web-metrics-tab', |
| 84 | + intro: '<ul> <li>This tab visually displays performance metrics and allows the user to gauge efficiency of their application</li></ul>', |
| 85 | + position: 'bottom', |
| 86 | + }, |
| 87 | + { |
| 88 | + title: 'Tree Tab', |
| 89 | + element: '.tree-tab', |
| 90 | + intro: '<ul><li>This tab visually displays a JSON Tree containing the different components and states</li></ul>', |
| 91 | + position: 'bottom', |
| 92 | + }, |
| 93 | + { |
| 94 | + title: 'Tutorial Complete', |
| 95 | + intro: '<ul><li>Please visit our official Github Repo for more information </li><br> <li><a href="https://github.com/open-source-labs/reactime" target="_blank">Reactime Github</a></li></ul>', |
| 96 | + position: 'top', |
| 97 | + }, |
| 98 | + ]); |
| 99 | + |
| 100 | + const onExit = () => { |
| 101 | + setStepsEnabled(false); |
| 102 | + }; |
| 103 | + const startIntro = () => { |
| 104 | + setStepsEnabled(true); |
| 105 | + }; |
| 106 | + |
| 107 | + return ( |
| 108 | + <> |
| 109 | + <Steps |
| 110 | + enabled={stepsEnabled} |
| 111 | + steps={steps} |
| 112 | + initialStep={initialStep} |
| 113 | + onExit={onExit} |
| 114 | + options={{ |
| 115 | + tooltipClass: 'customTooltip', |
| 116 | + scrollToElement: false, |
| 117 | + showProgress: true, |
| 118 | + showStepNumbers: true, |
| 119 | + showBullets: false, |
| 120 | + exitOnOverlayClick: false, |
| 121 | + doneLabel: 'Done', |
| 122 | + nextLabel: 'Next', |
| 123 | + hideNext: false, |
| 124 | + skipLabel: 'Skip', |
| 125 | + keyboardNavigation: true, |
| 126 | + overlayOpacity: 0.65, |
| 127 | + }} |
| 128 | + /> |
| 129 | + |
| 130 | + <button |
| 131 | + className="howToUse-button" |
| 132 | + type="button" |
| 133 | + onClick={() => startIntro()} |
| 134 | + > |
| 135 | + <FontAwesomeIcon icon={faQuestion} /> |
| 136 | + {' '} |
| 137 | + How to use |
| 138 | + </button> |
| 139 | + </> |
| 140 | + |
| 141 | + ); |
| 142 | +} |
0 commit comments