npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tour-master

v0.1.4

Published

Your next tour library.

Downloads

341

Readme

Tour Master

NPM version

A flexible and customizable tour guide library for web applications, built with TypeScript and Vue.js reactivity system.

Features

  • 🎯 Highly customizable tour steps and popover templates
  • 🎨 Flexible positioning and styling options
  • 🔄 Support for entry/leave hooks for each step
  • 🎭 Customizable overlay and highlighting
  • 📏 Configurable offsets and padding
  • 🎯 Multiple placement options
  • 💪 Written in TypeScript with full type support

Installation

npm install tour-master

Basic Usage

import { Tour } from 'tour-master';

const tour = new Tour({
  steps: [
    {
      element: '#step1', // Can be string ID, HTMLElement, or function
      stages: [ // Optional custom highlight areas
        {
          x: 0,
          y: 0,
          width: 100,
          height: 100,
        },
      ],
    },
    {
      element: document.getElementById('step2'),
      placement: 'top', // Control popover placement
      entry: async (action) => {
        // Do something when entering this step
      },
      leave: async (action) => {
        // Do something when leaving this step
      },
    },
  ],
  popoverTemplate: ({ pre, next, finish, currentStep, currentStepIndex, stepTotal }) => {
    // Return a function that creates and returns your popover element
    return (bindArrowEl) => {
      const el = document.createElement('div');
      // ... configure your popover
      return el;
    };
  },
  // Optional configurations
  popoverOffset: 8,
  popoverPadding: 5,
  zIndex: 1000,
  overlayOpacity: 0.5,
});

// Start the tour
tour.start();

Configuration Options

Tour Configuration

interface TourConfig<T = undefined> {
  steps: Array<TourStep & T>
  popoverTemplate: PopoverTemplate<T>
  popoverArrowPositioned?: PopoverArrowPositionedHandler
  popoverOffset?: number
  popoverPadding?: number
  zIndex?: number
  overlayOpacity?: number
  arrowPadding?: number
  /**
   * If set, the tour will only show once.
   */
  storageKey?: string
  /**
   * If set, the tour will lock the scroll.
   *
   * @default false
   */
  lockScroll?: boolean
  /** call before start */
  onStart?: (() => void) | (() => Promise<void>)
  /** call after finish */
  onFinish?: (() => void) | (() => Promise<void>)
}

Step Options

interface TourStep {
  element?: string | ReferenceElement | (() => ReferenceElement)
  stages?: StageDefinition[] | (() => StageDefinition[])
  entry?: (action: 'pre' | 'next') => void | Promise<void>
  leave?: (action: 'pre' | 'next' | 'finish') => void | Promise<void>
  placement?: Placement
  /** default: false */
  hideOverlay?: boolean
  offset?: number
  padding?: number
  arrowPadding?: number
}

Custom Popover Templates

You can create custom popover templates using vanilla JavaScript or any framework. Here's an example with Vue:

import { defineComponent, h, render } from 'vue';

const tour = new Tour({
  // ... other config
  popoverTemplate: ({ pre, next, finish, currentStep, currentStepIndex, stepTotal }) => {
    return (bindArrowEl) => {
      const component = defineComponent({
        setup() {
          return () => h('div', { class: 'tour-popover' }, [
            h('div', { class: 'content' }, currentStep.content),
            h('div', { class: 'actions' }, [
              h('button', { onClick: pre }, 'Previous'),
              h('button', { onClick: next }, 'Next'),
              h('button', { onClick: finish }, 'Finish'),
            ]),
          ]);
        },
      });

      const container = document.createElement('div');
      render(component, container);
      return container.firstElementChild as HTMLElement;
    };
  },
});

Advanced Features

Custom Stage Definitions

You can define custom highlight areas for each step:

const tour = new Tour({
  steps: [
    {
      element: '#step1',
      stages: () => [{
        x: 100,
        y: 100,
        width: 200,
        height: 50,
      }],
    },
  ],
});

Lifecycle Hooks

Each step supports entry and leave hooks:

const tour = new Tour({
  steps: [
    {
      element: '#step2',
      entry: async (action) => {
        // action will be 'pre' or 'next'
        await someAsyncOperation();
      },
      leave: async (action) => {
        // action will be 'pre', 'next', or 'finish'
        await cleanup();
      },
    },
  ],
});

Multiple Tours Scheduler

You can chain multiple tours together:

const tourScheduler = new TourScheduler({
  tours: new Map([
    ['tour1', tour1],
    ['tour2', tour2],
  ]),
  stateHandler() {
    // Logic to determine which tour to show
    return 'tour1'; // or 'tour2'
  },
});

Examples

Check the playground directory in the repository for complete working examples including:

  • Multiple sequential tours
  • Custom popover styling
  • Tour transitions

License

MIT