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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tourguide

v0.0.4

Published

JS plugin that helps generate step-by-step instructions and demos in an easy way

Downloads

60

Readme

TourGuide

Build Status npm npm

About

TourGuide is a JavaScript module that helps generate step-by-step instructions and demos in an easy way. It spotlights elements adding small commentary on them. See a demo working on CodePen.

It uses borders and box-shadows to create a spotlight area that will highlight a specific element, displaying commentary text, and animating from one step to another using CSS transitions. It is highly customizable, works on desktop and mobile, and users can opt to use the default controls or create their own using the plugin API.

Initially, it was a CSS-only animation for a Snake & Ladders game. Then it was ported into JavaScript and this module was created.

How to use it

This is a simple 4-step way to start TourGuide:

  1. Download an import the JS library and CSS file into your project. You can do this by:

    1. Downloading/importing the files directly into your project:

      <link rel="stylesheet" href="/css/tourguide.css" />
      <script src="/js/tourguide.js"></script>
    2. Installing the package from npm

      npm i tourguide
    3. Adding the package from yarn

      yarn add tourguide
  2. Add data-sp-next data-attribute to the elements that you want to highlight as part of your instructions.

    There are more data-attributes that can be added, but only the data-sp-next is essential to create the list of steps for the instructions.

  3. Initialize TourGuide with the selector of the initial element of the instructions:

      <script>
      let tour = new TourGuide({
        init: "#step1"
      });
      </script>
  4. With JavaScript, trigger the beginning of the instructions/demo using the start method:

    tour.start();

For more examples on how to start, check the repository demos.

Parameters

| Parameter | Type | Description | | ------------ | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | color | Color | String with the color of the shadow. Default: "rgba(0, 0, 0, 0.5)". | | init | String | Selector of the first element that will be highlighted, and from which the list of steps will be created. This field has no default value. Either this parameter of steps must be specified when starting TourGuide. | | initTrigger | Boolean | Indicates if the first element will also be the trigger of the animation. Default: false. | | next | Boolean | Indicates if the link to the next step will be displayed. Default: true | | nextText | String | Specifies the text of the next step link. Admits HTML. Default: "Next" | | previous | Boolean | Indicates if the link to the previous step will be displayed. Default: true | | previousText | String | Specifies the text of the previous step link. Admits HTML. Default: "Previous" | | shape | square|round | String that indicates the shape of the spotlight: squared or round/elliptical. Default value: "round". | | skip | Boolean | Indicates if the link to skip the instructions will be displayed. Default: true | | skipText | String | Specifies the text of the link to skip instructions. Default: "Skip presentation" | | steps | Array | List with objects that will contain ID, text, and shape of the element to be highlighted (see more below). This field has no default value. Either this parameter of init must be specified when starting TourGuide. |

The structure of the steps list will be as follows:

[
  {
    selector: "selector-of-the-element-to-be-highglighted-(mandatory)",
    text: "text-to-be-displayed-(optional)",
    shape: "shape-of-the-element-(optional)"
  },
  ...
]

So, for example, the following ways of initializing SpolightJS would be equivalent:

Method 1:

<div id="step-1" data-sp-next="#step-2" data-sp-text="This is the first step.">Hello!</div>
<div id="step-2" data-sp-next="#step-3" data-sp-text="This is the last steop." data-sp-shape="round">Good Bye!</div>

<script>
let tourguide = new TourGuide({ init: "#step-1" });
</script>

Method 2:

<div id="step-1">Hello!</div>
<div id="step-2">Good Bye!</div>

<script>
let tourguide = new TourGuide({
                      steps:[
                              { selector: "#step-1", text: "This is the first step." },
                              { selector: "#step-2", text: "This is the last step.", shape: "round" }
                            ]
                    });
</script>

API methods

In order to customize the instructions, you could hide all the controls (next, previous, skip) and use your own using the methods from the provided API, or you could also hide the text associated to each step (via CSS) and design your own instruction text. For some examples of the possibilities, see the demos page.

| Method | Returns | Description | | --------------------------- | ------- | ---------------------------------------------------------------------------- | | getCurrentElement() | Object | Returns the element that is currently highlighted. | | getCurrentElementSelector() | String | Returns the selector provided for the element that is currently highlighted. | | getStep() | Integer | Returns the integer value of the current step (from 1 to no). | | getText() | String | Returns the text associated to the currently highlighted step. | | getTotalSteps() | Integer | Returns the total number of steps in the presentation. | | goToFirstStep() | - | Animates to the first step. | | goToNextStep() | - | Animates to the following step in the presentation. | | goToPreviousStep() | - | Animates to the previous step in the presentation. | | goToStep(n) | - | Animates directly to step n. | | start() | - | Starts the animation from the first step. | | stop() | - | Stops the current animation. |

Browser Support

| Edge Logo 32x32IE/Edge | Firefox LogoFirefox | ChromeChrome | Safari LogoSafari | Opera logoOpera | | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | 9+ | 12+ | 4+ | 4+ | 11.5+ |