tour-component
A vuejs, reactjs and angular tour component.
features
- vuejs component
- reactjs component
- angular component
- highlight target element
- scroll to target
install
npm i tour-component
link css
<link rel="stylesheet" href="./node_modules/tour-component/tour.min.css" />
vuejs component demo
npm i vue vue-class-component
import "tour-component/vue";
<tour :data="data"
@update="update($event)">
</tour>
the online demo: https://plantain-00.github.io/tour-component/demo/vue/index.html
reactjs component demo
import { Tour } from "tour-component/react";
<Tour data={this.data}
update={e => this.update(e)}>
</Tour>
the online demo: https://plantain-00.github.io/tour-component/demo/react/index.html
angular component demo
import { TourModule } from "tour-component/angular";
@NgModule({
imports: [BrowserModule, FormsModule, TourModule],
declarations: [MainComponent],
bootstrap: [MainComponent],
})
class MainModule { }
<tour [data]="data"
(update)="update($event)">
</tour>
the online demo: https://plantain-00.github.io/tour-component/demo/angular/index.html
the AOT online demo: https://plantain-00.github.io/tour-component/demo/aot/index.html
properties and events of the component
name | type | description |
---|
data | TourData[] | the data of the tour |
update | (index: number)=> void | triggered when press next or close |
tour data structure
type TourData = {
steps: Step[],
localStorageKey: string;
index: number;
};
type Step = {
left?: string | (() => string);
right?: string | (() => string);
top?: string | (() => string);
bottom?: string | (() => string);
direction: "left" | "right" | "top" | "bottom";
content: string;
next: string;
scrollTop?: number;
targetElementId?: string;
};
change log
import { TourModule } from "tour-component/angular";
import { TourModule } from "tour-component/aot/angular";
import "tour-component/vue";
import "tour-component/dist/vue";
// v2 to v3
move `index` into `data` from as a property
// v1 to v2
move `index` out from `data` as a property
add `update` event