Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: typescript integration in tutorials.js file #281

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/simulator/src/tutorials.js → src/simulator/src/tutorials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Driver from 'driver.js'

export const tour = [
interface TourStep extends Driver.Step {
className?: string;
}

export const tour: TourStep[] = [
{
element: '#guide_1',
className: 'guide_1',
Expand Down Expand Up @@ -98,11 +102,16 @@ export const tour = [
]

// Not used currently

interface HighlightStep extends Driver.Step {
showButtons?: boolean;
}

export const tutorialWrapper = () => {
const panelHighlight = new Driver()
document.querySelector('.panelHeader').addEventListener('click', (e) => {
document.querySelector('.panelHeader')?.addEventListener('click', (e) => {
if (localStorage.tutorials === 'next') {
panelHighlight.highlight({
const step: HighlightStep = {
element: '#guide_1',
showButtons: false,
popover: {
Expand All @@ -111,17 +120,16 @@ export const tutorialWrapper = () => {
'Select any element by clicking on it & then click anywhere on the grid to place the element.',
position: 'right',
offset:
e.target.nextElementSibling.offsetHeight +
e.target.offsetTop -
((e.target as HTMLElement).nextElementSibling as HTMLElement)?.offsetHeight +
(e.target as HTMLElement).offsetTop -
45,
},
})
};
panelHighlight.highlight(step);
localStorage.setItem('tutorials', 'done')
}
}, {
once: true,
})
document.querySelector('.icon').addEventListener('click', () => {
}, {once: true,})
document.querySelector('.icon')?.addEventListener('click', () => {
panelHighlight.reset(true)
})
}
Expand All @@ -134,10 +142,10 @@ const animatedTourDriver = new Driver({
})

export function showTourGuide() {
document.querySelector('.draggable-panel .maximize').click();
(document.querySelector('.draggable-panel .maximize') as HTMLButtonElement)?.click();
animatedTourDriver.defineSteps(tour)
animatedTourDriver.start()
localStorage.setItem('tutorials_tour_done', true)
localStorage.setItem('tutorials_tour_done', 'true')
}

export default showTourGuide
Loading