Skip to content

Commit

Permalink
New tour UI: PrimeNG.
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimio committed Jan 2, 2025
1 parent d9bfe5b commit a00039a
Show file tree
Hide file tree
Showing 37 changed files with 974 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/.angular/cache
/.angular
# Logs
logs
*.log
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> UI tour library for Angular
Angular Material, Ionic, Taiga UI, Ng Bootstrap and Ngx Bootstrap UIs are supported.
Angular Material, Ionic, PrimeNG, Taiga UI, Ng Bootstrap and Ngx Bootstrap UIs are supported.

`ngx-ui-tour` is a fork of __Isaac Mann's__ `ngx-tour`. The project had to be forked since the original is no longer
maintained.
Expand Down Expand Up @@ -72,6 +72,12 @@ Demo and documentation can be found at [hakimio.github.io/ngx-ui-tour](https://h
| 16 | 7 | 6, 7 | 2 |
| 15 | 7 | 6, 7 | 1 |

### PrimeNG tour UI

| Angular | RxJS | PrimeNG | ngx-ui-tour |
|---------|------|---------|-------------|
| 19 | 7 | 19 | 1 |

### Taiga UI tour UI

| Angular | RxJS | Taiga UI | ngx-ui-tour |
Expand Down
7 changes: 7 additions & 0 deletions apps/ngx-ui-tour-demo/src/app/app.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {provideAnimations} from '@angular/platform-browser/animations';
import {provideIonicAngular} from '@ionic/angular/standalone';
import {NG_EVENT_PLUGINS} from '@taiga-ui/event-plugins';
import {TUI_ANIMATIONS_SPEED} from '@taiga-ui/core';
import {providePrimeNG} from 'primeng/config';
import Aura from '@primeng/themes/aura';

export const DEFAULT_TABS = [
`Description`,
Expand Down Expand Up @@ -90,5 +92,10 @@ export const APP_PROVIDERS: (Provider | EnvironmentProviders)[] = [
provideIonicAngular({
mode: 'md'
}),
providePrimeNG({
theme: {
preset: Aura
}
}),
NG_EVENT_PLUGINS
];
5 changes: 5 additions & 0 deletions apps/ngx-ui-tour-demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export const ROUTES: Routes = [
title: 'Ionic',
loadComponent: async () => import('./ion-popover/ion-popover.component')
}),
route({
path: 'prime-ng',
title: 'PrimeNG',
loadComponent: async () => import('./prime-ng-popover/prime-ng-popover.component')
}),
{
redirectTo: 'md-menu',
path: '**'
Expand Down
4 changes: 4 additions & 0 deletions apps/ngx-ui-tour-demo/src/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const pages: TuiDocRoutePages = [{
section: 'Tour UI Libraries',
title: 'Ionic',
route: 'ion-popover'
}, {
section: 'Tour UI Libraries',
title: 'PrimeNG',
route: 'prime-ng'
}, {
section: 'Tour UI Libraries',
title: 'NG Bootstrap',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
```html
<tour-step-template>
<ng-template let-step="step">
<div
[style.width]="step.stepDimensions?.width"
[style.min-width]="step.stepDimensions?.minWidth"
[style.max-width]="step.stepDimensions?.maxWidth"
class="main-container"
>
<div class="title-container">
<div class="title">{{ step?.title }}</div>
<p-button
severity="secondary"
icon="pi pi-times"
ariaLabel="Close"
variant="text"
[rounded]="true"
(click)="tourService.end()"
/>
</div>

<p
class="card-text"
[innerHTML]="step.content"
></p>

<div
class="buttons"
[class.no-progress]="!step.showProgress"
>
<p-button
[disabled]="!tourService.hasPrev(step)"
icon="pi pi-angle-left"
iconPos="left"
severity="secondary"
[label]="step.prevBtnTitle"
(click)="tourService.prev()"
/>
@if (step.showProgress) {
<div class="progress">{{ tourService.steps.indexOf(step) + 1 }} / {{ tourService.steps.length }}</div>
}

@if (tourService.hasNext(step) && !step.nextOnAnchorClick) {
<p-button
icon="pi pi-angle-right"
iconPos="right"
[label]="step.nextBtnTitle"
(click)="tourService.next()"
/>
}
@if (!tourService.hasNext(step)) {
<p-button
[label]="step.endBtnTitle"
(click)="tourService.end()"
/>
}
</div>
</div>
</ng-template>
</tour-step-template>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<tui-doc-page
header="PrimeNG"
package="ngx-ui-tour-primeng"
>
<ng-template pageTab>
<p>
<code>ngx-ui-tour</code> is a UI tour library built for Angular. It's inspired by
<a tuiLink target="_blank" tourAnchor="angular-ui-tour" href="https://benmarch.github.io/angular-ui-tour">angular-ui-tour</a>.
</p>
<p>
<code>TourPrimeNgModule</code> is an implementation of the tour UI that uses
<a tuiLink href="https://primeng.org" target="_blank">PrimeNG</a> Popover to display tour steps.
</p>
<p>
<button
tuiButton
type="button"
(click)="tourService.start()"
tourAnchor="start.tour"
>
Start Demo Tour
</button>
</p>
</ng-template>
<ng-template pageTab>
<app-header tourAnchor="installation" id="installation">Installation</app-header>

<ol>
<li>
<code>npm install ngx-ui-tour-primeng primeng &#64;primeng/themes primeicons</code>
</li>
<li>
Import <code>TourPrimeNgModule</code> into your app module
</li>
<li>
Make sure <code>RouterModule</code> is imported in your app module
</li>
<li>
Make sure PrimeNG is
<a tuiLink href="https://primeng.org/installation" target="_blank">installed correctly</a>
</li>
</ol>
<app-usage
moduleName="TourPrimeNgModule"
></app-usage>
</ng-template>
<ng-template pageTab>
<app-step-config
[isCloseOnOutsideClickVisible]="true"
/>
<app-tour-service-api/>
<app-events/>
</ng-template>
<ng-template pageTab>
<app-faq
disablePageScrollingIntroducedIn="1.0"
/>
</ng-template>
<ng-template pageTab>
<app-hotkeys/>
<app-defaults/>
<app-custom-template
[defaultTemplate]="defaultTemplate"
/>
<app-styling-active-tour-anchor/>
</ng-template>
</tui-doc-page>

<tour-step-template/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app-header {
margin-top: 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import {ChangeDetectionStrategy, Component, inject, type OnInit} from '@angular/core';
import {TuiAddonDoc} from '@taiga-ui/addon-doc';
import {type IStepOption, TourAnchorPrimeNgDirective, TourPrimeNgModule, TourService} from 'ngx-ui-tour-primeng';
import {TuiButton, TuiLink} from '@taiga-ui/core';
import {provideTourDirective, SHARED_COMPONENTS} from '../shared';
import defaultTemplate from './examples/default-template.md' with {loader: 'text'};
import {DELAY_AFTER_NAVIGATION} from '../app.providers';

@Component({
selector: 'app-prime-ng-popover',
imports: [
TuiAddonDoc,
TuiLink,
TourPrimeNgModule,
TuiButton,
SHARED_COMPONENTS
],
templateUrl: './prime-ng-popover.component.html',
styleUrl: './prime-ng-popover.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
provideTourDirective(TourAnchorPrimeNgDirective)
]
})
export default class PrimeNgPopoverComponent implements OnInit {

readonly tourSteps: IStepOption[] = [{
anchorId: 'start.tour',
content: 'Welcome to the Ngx-UI-Tour tour!',
title: 'Welcome'
}, {
anchorId: 'angular-ui-tour',
content: 'Thanks to angular-ui-tour for the inspiration for the library',
title: 'angular-ui-tour'
}, {
anchorId: 'installation',
content: 'First, install the library...',
title: 'Installation',
route: 'prime-ng/Setup'
}, {
anchorId: 'usage',
content: '...then use it.',
title: 'Usage',
route: 'prime-ng/Setup'
}, {
anchorId: 'tourService.start',
content: 'Don\'t forget to actually start the tour.',
title: 'Start the tour',
route: 'prime-ng/Setup'
}, {
anchorId: 'config.anchorId',
content: 'Every step needs an anchor.',
title: 'Anchor',
route: 'prime-ng/API'
}, {
anchorId: 'config.enableBackdrop',
content: 'You can enable backdrop to highlight active element.',
title: 'Backdrop',
enableBackdrop: true,
route: 'prime-ng/API'
}, {
anchorId: 'config.route',
content: 'Tours can span multiple routes.',
title: 'Route',
route: 'prime-ng/API'
}, {
anchorId: 'config.centerAnchorOnScroll',
content: 'Enable this config to keep active anchor element centered when possible.',
title: 'Center active anchor',
route: 'prime-ng/API'
}, {
anchorId: 'config.smoothScroll',
content: 'Enable "smoothScroll" option to smoothly scroll to an active element.',
title: 'Smooth scroll',
route: 'prime-ng/API'
}, {
anchorId: 'config.buttons.custom',
content: 'You can set custom step button names',
title: 'Button Titles',
prevBtnTitle: 'My Prev',
nextBtnTitle: 'My Next',
endBtnTitle: 'My End',
route: 'prime-ng/API',
stepDimensions: {
maxWidth: '350px'
}
}, {
anchorId: 'config.isAsync',
content: 'Mark your step as async if anchor element is added to DOM with a delay',
title: 'Wait for async event',
route: 'prime-ng/API'
}, {
anchorId: 'config.nextOnAnchorClick',
content: 'Click on the config description to go to the next step',
title: 'Next on Anchor Click',
route: 'prime-ng/API',
nextOnAnchorClick: true
}, {
anchorId: 'events',
content: 'You can subscribe to events',
title: 'Events',
route: 'prime-ng/API'
}, {
anchorId: 'hotkeys',
content: 'Try using the hotkeys to navigate through the tour.',
title: 'Hotkeys',
route: 'prime-ng/Misc'
}];
readonly defaultTemplate = defaultTemplate;

protected readonly tourService = inject(TourService);
private readonly delayAfterNavigation = inject(DELAY_AFTER_NAVIGATION);

ngOnInit() {
this.tourService.initialize(this.tourSteps, {
route: 'prime-ng',
delayAfterNavigation: this.delayAfterNavigation
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {TourAnchorConsoleDirective} from 'ngx-ui-tour-console';
import {TourAnchorTuiDropdownDirective} from 'ngx-ui-tour-tui-dropdown';
import {TourAnchorTuiHintDirective} from 'ngx-ui-tour-tui-hint';
import {TourAnchorIonPopoverDirective} from 'ngx-ui-tour-ionic';
import {TourAnchorPrimeNgDirective} from 'ngx-ui-tour-primeng';

export const TOUR_ANCHOR_DIRECTIVE = new InjectionToken<TourAnchorDirective>('TourAnchorDirective');
export const TOUR_ANCHOR_DIRECTIVE_TYPE = new InjectionToken<Type<TourAnchorDirective>>('TourAnchorDirectiveType');
Expand All @@ -40,6 +41,7 @@ interface CustomTourAnchorDirective extends TourAnchorDirective, OnInit, OnDestr
TourAnchorTuiDropdownDirective,
TourAnchorTuiHintDirective,
TourAnchorIonPopoverDirective,
TourAnchorPrimeNgDirective,
{
provide: TOUR_ANCHOR_DIRECTIVE,
useFactory: () => {
Expand Down
2 changes: 2 additions & 0 deletions apps/ngx-ui-tour-demo/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<link rel="mask-icon" href="assets/favicons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="preconnect" href="https://rsms.me/">
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">

<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
Expand Down
7 changes: 7 additions & 0 deletions apps/ngx-ui-tour-demo/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
@import '@ionic/angular/css/core.css';
@import './bootstrap';

.p-popover {
font-family: "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-feature-settings: "cv02", "cv03", "cv04", "cv11";
line-height: normal;
}
@import 'primeicons/primeicons.css';

/* Workaround for white gap at the bottom when tour is started and dark theme is used */
@media (prefers-color-scheme: dark) {
html {
Expand Down
Loading

0 comments on commit a00039a

Please sign in to comment.