1
Fork 0
tildes-shepherd/source/tours/types.ts

59 lines
1.6 KiB
TypeScript
Raw Normal View History

import type Shepherd from "shepherd.js";
2023-07-02 10:04:29 +00:00
/** All available tour IDs. */
export enum TourId {
InterfaceAccountSettings = "interface-account-settings",
InterfaceHomepage = "interface-homepage",
Introduction = "introduction",
}
2023-07-02 10:04:29 +00:00
/** Requirements of a tour to be checked before the tour is started. */
export type TourRequirement = {
2023-07-02 10:04:29 +00:00
/**
* This tour requires that the user must be logged in. Only set this to true
* if the tour goes to pages only accessible by logged in users.
*/
mustBeLoggedIn: boolean;
2023-07-02 10:04:29 +00:00
/** The {@link URL.pathname} to run the tour at. */
path: string;
};
2023-07-02 10:04:29 +00:00
/** An individual tour step event handler. */
export type TourStepEvent = {
2023-07-02 10:04:29 +00:00
/**
* - The "show" event will be called when the step is displayed.
* - The "destroy" event will be called when the step is finished.
*/
event: "show" | "destroy";
2023-07-02 10:04:29 +00:00
/** The handler for this step event. */
handler: Parameters<Shepherd.Step["on"]>[1];
};
2023-07-02 10:04:29 +00:00
/** All the tour data collected in one place. */
export type TourData = {
2023-07-02 10:04:29 +00:00
/** A short description of the tour for use in the options page. */
description: string;
2023-07-02 10:04:29 +00:00
/** Whether this tour should be shown in the options page. */
displayInOptionsPage: boolean;
2023-07-02 10:04:29 +00:00
/** All event handlers to be added to this tour's steps. */
eventHandlers: Array<{
eventHandlers: TourStepEvent[];
stepId: string;
}>;
2023-07-02 10:04:29 +00:00
/** The unique ID for this tour. */
id: TourId;
2023-07-02 10:04:29 +00:00
/** The requirements this tour must match before starting it. */
requirements: TourRequirement;
2023-07-02 10:04:29 +00:00
/** All the steps this tour will take. */
steps: Shepherd.Step.StepOptions[];
2023-07-02 10:04:29 +00:00
/** The title of the tour for use in the options page. */
title: string;
};