mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 11:42:19 -05:00
30 lines
821 B
TypeScript
30 lines
821 B
TypeScript
import { Controller } from '@hotwired/stimulus'
|
|
import { driver } from 'driver.js'
|
|
|
|
// Connects to data-controller="basic-tour"
|
|
export default class extends Controller {
|
|
driverObject = null
|
|
completed = []
|
|
|
|
connect (): void {
|
|
// Find tour elements in page
|
|
const tourElements = document.querySelectorAll('[data-tour-title]')
|
|
const tourSteps = [...tourElements].map((stepElement: HTMLElement) => (
|
|
{
|
|
element: '#' + stepElement.id,
|
|
popover: {
|
|
title: stepElement.dataset.tourTitle,
|
|
description: stepElement.dataset.tourDescription
|
|
}
|
|
}
|
|
))
|
|
const driverObj = driver({
|
|
showProgress: true,
|
|
steps: tourSteps
|
|
})
|
|
console.log(tourSteps);
|
|
if ((this.element as HTMLElement).dataset["tourAutostart"])
|
|
driverObj.drive();
|
|
}
|
|
}
|