All Projects → code-orange → telemachy

code-orange / telemachy

Licence: MIT license
Easy guided tours for Angular apps

Programming Languages

typescript
32286 projects
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to telemachy

GuideChimp
Create interactive guided product tours in minutes with the most non-technical friendly, lightweight and extendable library.
Stars: ✭ 138 (+228.57%)
Mutual labels:  tour
html-tutorial-exercises-course
Learn HTML with an interactive and auto-graded tutorial with dozens of exercises.
Stars: ✭ 23 (-45.24%)
Mutual labels:  tutorials
master
This is an Open-Source, community-driven project for the creation of a documentation hub for Raspberry Pi and ARM Cardano Stake Pool Operators.
Stars: ✭ 18 (-57.14%)
Mutual labels:  tutorials
tutorials-kr
🇰🇷파이토치에서 제공하는 튜토리얼의 한국어 번역을 위한 저장소입니다. (Translate PyTorch tutorials in Korean🇰🇷)
Stars: ✭ 271 (+545.24%)
Mutual labels:  tutorials
KJOverlayTutorial
A Tutorial for iOS
Stars: ✭ 99 (+135.71%)
Mutual labels:  tutorials
2019-20-Classes
https://cc-mnnit.github.io/2019-20-Classes/ - 🎒 💻 Material for Computer Club Classes
Stars: ✭ 42 (+0%)
Mutual labels:  tutorials
angularjs-es6-starter-kit
Basic AngularJS, ES6, Webpack Starter Kit Project which includes Bootstrap 4 also. This is a boilerplate for AngularJS SPA with Bootstrap 4.
Stars: ✭ 28 (-33.33%)
Mutual labels:  tutorials
babel-webpack-react-redux-tutorials
React技术栈一站式系列教程,涉及React、Redux、Babel、Webpack等相关技术
Stars: ✭ 34 (-19.05%)
Mutual labels:  tutorials
k8s-canary
Walkthrough of Canary deployment on Kubernetes
Stars: ✭ 18 (-57.14%)
Mutual labels:  tutorials
tutorials-java
Java Spring related tutorial collection
Stars: ✭ 22 (-47.62%)
Mutual labels:  tutorials
Spring-Kotlin-iThome-2021
iThome ironman 2021 💪
Stars: ✭ 27 (-35.71%)
Mutual labels:  tutorials
aic-mobile-ios
Art Institute of Chicago Official Mobile App
Stars: ✭ 29 (-30.95%)
Mutual labels:  tour
seminars-fivt
Seminars on optimization methods for DIHT MIPT
Stars: ✭ 23 (-45.24%)
Mutual labels:  tutorials
FortranTip
Short instructional Fortran codes associated with Twitter @FortranTip
Stars: ✭ 39 (-7.14%)
Mutual labels:  tutorials
springcloud-course
Spring Cloud 入门教程
Stars: ✭ 48 (+14.29%)
Mutual labels:  tutorials
openCVtutorials
OpenCV Tutorials
Stars: ✭ 12 (-71.43%)
Mutual labels:  tutorials
coding-notes
I'm compiling comprehensive coding tutorials for many different languages and frameworks! 🐲
Stars: ✭ 201 (+378.57%)
Mutual labels:  tutorials
techlab
This repository contains the APPUiO and OpenShift Techlab tutorials.
Stars: ✭ 51 (+21.43%)
Mutual labels:  tutorials
code with me
flutter app and code demos
Stars: ✭ 31 (-26.19%)
Mutual labels:  tutorials
godot recipes
Lessons, tutorials, and guides for game development using the Godot game engine.
Stars: ✭ 135 (+221.43%)
Mutual labels:  tutorials

Telemachy npm Downloads license

Easy guided tours for Angular apps.

Demo

Table of contents

Getting started

Installation

yarn add telemachy
# or
npm install --save telemachy

Import TelemachyModule in your root module (make sure the RouterModule is loaded, Telemachy uses it to automatically start the tour for any compontent that a user navigates to):

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';

import { TelemachyModule } from 'telemachy';

import { AppComponent } from './app.component';

@NgModule({
	imports: [BrowserModule, RouterModule.forRoot([]), TelemachyModule],
	declarations: [AppComponent],
	bootstrap: [AppComponent]
})
export class AppModule {}

Finally, add the <telemachy-tour> component to your root app component (or one that is always loaded when you want to display a tour):

import { Component } from '@angular/core';

@Component({
	selector: 'app-root',
	template: `<telemachy-tour></telemachy-tour><router-outlet></router-outlet>`
})
export class RootComponent {}

Usage

In its easiest form, you can use Telemachy just by implementing the HasGuidedTour interface:

@Component({
	selector: 'app-complex-component',
	templateUrl: './complex-component.component.html'
})
export class ComplexComponent implements HasGuidedTour {
	tourAutoStart() {return true;}
	getTour():TourStep[] {
		return [
			new YoutubeTourStep('l9xU1WpdmVY'),
			new ElementTourStep('#complex-thing', 'Here, I will explain this.'),
			new ElementTourStep('#second-complex-thing', 'Then, I will explain this.'),
			new HTMLTourStep(`Finally, we are <em>done</em>!`)
		];
	}
}

By implementing the optional tourAutoStart() method (and having it return true), Telemachy will automatically start this component's tour whenever it becomes active through the angular router. You can also explicitly say it should be started by calling TelemachyService.startTour(this). In both cases, Telemachy will only show the tour if the persistency layer says the user should see it.

Persistency

By default, Telemachy will always show a user the tour on each visit. If you want to save if a user has already seen a tour, you should provide an alternate implementation for the TourPersistency service.

Telemachy comes with an alternate implementation that uses localstorage to save this state. This implementation depends on phenomnomnominal/angular-2-local-storage. You can use this as follows:

import { LocalStorageModule, LocalStorageService } from 'angular-2-local-storage';
import { TelemachyModule, TourPersistency, LocalstorageTourPersistencyFactory } from 'telemachy';

@NgModule({
	imports: [BrowserModule, LocalStorageModule.withConfig(), TelemachyModule],
	declarations: [AppComponent],
	bootstrap: [AppComponent],
	providers: [
		{provide: TourPersistency, useFactory: LocalstorageTourPersistencyFactory, deps: [LocalStorageService]}
	]
})
export class AppModule {}

We recommend you replace the TourPersistency service with an implementation that saves the user's state in a remote system, for instance through a REST API.

Restarting a tour

You can restart the tour for a currently visible component by calling TelemachyService.restartTour(). To check if there is a currently visible component that has a tour, use TelemachyService.canRestart().

API

TelemachyService

class TelemachyService {
    /**
     * Attempt to start the tour for a component
     * @param component
     */
    startTour(component: HasGuidedTour): void;
    /**
     * Indicates if there is a tour that could be restarted
     *
     * @returns {boolean}
     */
    canRestart(): boolean;
    /**
     * Restarts the tour for a component (no guarantee which) that is visible right now
     */
    restartTour(): void;
    
    /**
    * Adds an event listener that is called at either the start or end of the tour.
    * Types are 'start' or 'end'
    * listener can't be an anonymous function else it is not possible to remove the callback.
    * 
    * @param type string
    * @param listener function
    */
    addEventListener(type: string, listener:() => void): void;
    
    /**
    * Removes an event listener.
    * Types are 'start' or 'end'
    * listener should be the same function as the one that was added.
    * 
    * @param type string
    * @param listener function
    */
    removeEventListener(type: string, listener:() => void): void;
    
    canGoBack(): boolean;
    canFinish(): boolean;
    finish(): void;
    skip(): void;
    next(): void;
    previous(): void;
    private reset();
    private emit();
    subscribeStep(generatorOrNext?: any, error?: any, complete?: any): Subscription;
    readonly progress: number;
    readonly total: number;
}

TourPersistency

class TourPersistency {
    /**
     * Whether a tour should be started
     *
     * @param componentName Name of the component that the user has arrived at
     * @returns {Observable<boolean>}
     */
    shouldStart(componentName: string): Observable<boolean>;
    /**
     * Finish the tour for a component
     * @param componentName
     */
    finish(componentName: string): void;
    /**
     * Skip the tour for a component
     * @param componentName
     */
    skip(componentName: string): void;
}

YoutubeTourStep

/**
 * Tour step that shows a Youtube video in the middle of the page
 */
class YoutubeTourStep extends TourStep {
    /**
     * Video id
     */
    video: string;
    constructor(video: string);
}

HTMLTourStep

/**
 * Tour step that shows some HTML in the middle of the page
 */
class HTMLTourStep extends TourStep {
    /**
     * HTML to display in this step
     */
    body: string;
    constructor(body: string);
}

ElementTourStep

/**
 * Tour step that highlights an element on the page with some explanation
 */
class ElementTourStep extends TourStep {
    /**
     * Element to highlight
     */
    domElement: Element;
    /**
     * HTML to display in this step
     */
    body: string;
    constructor(selector: string, body: string, async?: boolean);
    readonly top: string;
    readonly bottom: string;
    readonly left: string;
    readonly right: string;
    readonly documentHeight: string;
    readonly documentWidth: string;
    readonly toBottom: string;
    readonly toRight: string;
    readonly fromLeft: string;
    readonly fromTop: string;
    readonly height: string;
    readonly width: string;
}

If async is true, the ElementTourStep will attempt to find the element on the page after it has been initialized. If the element isn't available by the time the step should be rendered, the step will be skipped.

Event Listeners

It is possible to add event listeners that are fired add the start of the tour or at the end of the tour when the finished/skipped button is clicked. Possible types: start or end

	let doSomething = () => console.log('something');
	this.TelemachyService.addEventListener('start', doSomething);
	this.TelemachyService.removeEventListener('start', doSomething);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].