Guided Tour
A wrapper around Shepherd with extra functionality. Make sure to check out the official shepherd docs.
API Summary
Methods
- registerTour(tourName: string, tour: IGuidedTour | string): Promise
- startTour(tourName: string): Shepherd.Tour
- initializeOnQueryParams(queryParam: string = 'tour'): Observable
- Listen to query params to launch a tour
- tourEvent$(str: TourEvents): Observable
- Observable of tour events
export type TourStep = Shepherd.Step.StepOptions;
export type TourStepButton = Shepherd.Step.StepOptionsButton;
export enum ITourEvent {
'click' = 'click',
'pointerover' = 'pointerover',
'keyup' = 'keyup',
'added' = 'added',
'removed' = 'removed',
}
export interface ITourEventOn {
selector?: string;
event?: keyof typeof ITourEvent;
}
export interface ITourEventOnOptions {
timeBeforeShow?: number;
interval?: number;
}
export interface ITourAbortOn extends ITourEventOn {}
export interface ITourOptions extends Shepherd.Tour.TourOptions {
abortOn?: ITourAbortOn[];
}
export interface ITourStepAttachToOptions extends ITourEventOnOptions {
highlight?: boolean;
retries?: number;
skipIfNotFound?: boolean;
else?: string;
goBackTo?: string;
skipFromStepCount?: boolean;
}
export interface ITourStepAdvanceOn extends ITourEventOn {}
export interface ITourStepAdvanceOnOptions extends ITourEventOnOptions {
jumpTo?: string;
allowGoBack?: boolean;
}
export interface ITourStep extends TourStep {
attachToOptions?: ITourStepAttachToOptions;
advanceOnOptions?: ITourStepAdvanceOnOptions;
advanceOn?: ITourStepAdvanceOn[] | ITourStepAdvanceOn | any;
abortOn?: ITourAbortOn[];
count?: number;
}
export interface IGuidedTour extends ITourOptions {
steps: IGuidedTourStep[];
finishButtonText?: string;
dismissButtonText?: string;
}
export interface IGuidedTourStep extends ITourStep {
routing?: {
route: string;
extras?: NavigationExtras;
};
}
export enum TourEvents {
complete = 'complete',
cancel = 'cancel',
hide = 'hide',
show = 'show',
start = 'start',
active = 'active',
inactive = 'inactive',
}
export interface IGuidedTourEvent {
step: any;
previous: any;
tour: any;
}
Setup
import { CovalentGuidedTourModule } from '@covalent/guided-tour';
Usage
import { CovalentGuidedTourService } from '@covalent/guided-tour';
const basicDemoTour: IGuidedTour = {
useModalOverlay: true,
steps: [
{
title: 'Fuel',
text: 'Here are the fuel levels',
attachTo: {
element: '#basic-demo #fuel',
on: 'top',
},
},
{
title: 'Oxygen',
text: 'Here are the Oxygen levels.',
attachTo: {
element: '#basic-demo #oxygen',
on: 'top',
},
},
{
title: 'Global status',
text: 'Here you can see the global status of the vehicle. That is all there is to it!',
attachTo: {
element: '#basic-demo #status',
on: 'top',
},
},
],
};
this._guidedTourService.registerTour('basicDemoTour', basicDemoTour);
this._guidedTourService.startTour('basicDemoTour');
this._guidedTourService
.tourEvent$(TourEvents.show)
.subscribe((event: IGuidedTourEvent) => {
});
<div id="basic-demo">
<button mat-raised-button color="accent" (click)="startTour()">
Start tour
</button>
<meter
id="fuel"
min="0"
max="100"
low="33"
high="66"
optimum="50"
value="50"
></meter>
<progress id="oxygen" max="100" value="70">70%</progress>
<marquee id="status">All systems are running smoothly</marquee>
</div>
Running unit tests
Run nx test angular-guided-tour
to execute the unit tests.