mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
29 lines
787 B
TypeScript
29 lines
787 B
TypeScript
import { Controller } from "@hotwired/stimulus"
|
|
import { driver } from "driver.js";
|
|
|
|
|
|
// Connects to data-controller="basic-tour"
|
|
export default class extends Controller {
|
|
|
|
connect () {
|
|
// 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();
|
|
}
|
|
}
|