-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from salmanja/013-jan-1-joyride
adding page tour to dashboard/home page
- Loading branch information
Showing
8 changed files
with
254 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Joyride, {Step} from 'react-joyride'; | ||
import React, {useEffect, useState} from 'react'; | ||
|
||
interface PageTourProps { | ||
steps: Step[]; | ||
run: boolean; | ||
onFinish?:()=>void; | ||
} | ||
|
||
const PageTour: React.FC<PageTourProps> =({steps, run, onFinish}) => { | ||
const [shouldRun, setShouldRun] = useState(false); | ||
|
||
useEffect (()=>{ | ||
//always check if tour was seen first before running it | ||
const hasSeenTour = localStorage.getItem("hasSeenTour"); | ||
if(!hasSeenTour && run){ | ||
setShouldRun(true); | ||
} | ||
}, [run]) | ||
|
||
const handleCallback = (data:any)=>{ | ||
const {status} = data; | ||
if (status === 'finished' || status === 'skipped'){ | ||
localStorage.setItem("hasSeenTour", "true"); | ||
setShouldRun(false); | ||
if (onFinish){ | ||
onFinish(); | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<Joyride | ||
steps={steps} | ||
run={shouldRun} | ||
continuous | ||
hideCloseButton | ||
showProgress | ||
showSkipButton | ||
callback={handleCallback} | ||
styles={{ | ||
options: { | ||
primaryColor: "rgba(23, 92, 211, 1)", | ||
zIndex: 1000, | ||
beaconSize: 20, | ||
}, | ||
}} | ||
/> | ||
); | ||
} | ||
export default PageTour; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.