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

guideline

v1.0.0

Published

A simple guideline tool based on which you can quickly implement new features guidelines for website users.

Downloads

27

Readme

New Features Guideline (新功能指引)

Version npm Build Status Dependencies Known Vulnerabilities License

This is a simple guideline tool based on which you can quickly implement new features guidelines for website users.

Usage

There are two ways to play a guideline, a simple way and an advanced way. The simple way is an encapsulation of the advanced way which can do more setting and control the playing of guideline.

Guideline also supports using keyboard shortcuts to control playback. See the relevant part of API for details

Simple way

const guideline = require('guideline');

const visitTimes = parseInt(localStorage.getItem('visitTimes')) || 0;

if (visitTimes === 0) {
  const guideOptions = [{
    content: 'Welcome, the new features guidelines come online !'
  }, {
    element: document.getElementById('notificationwrapper'),
    content: 'all system messages and notification is here',
    style: 'font-size: 20px; color: red;',
    position: 'top'
  }, {
    element: document.querySelector('.datepicker-hint'),
    content: 'datepicker hint will tell you the datepicker\'s date range restriction',
    position: 'bottom'
  }];

  guideline(guideOptions, function () {
    console.log('guideline is over');
  });
}

Advanced way

const guideline = require('guideline');

// something else ...

const guideOptions = [{
  content: 'Welcome, the new features guidelines come online !'
}, {
  element: document.getElementById('notificationwrapper'),
  content: 'all system messages and notification is here',
  style: 'font-size: 20px; color: red;',
  position: 'top'
}, {
  element: document.querySelector('.datepicker-hint'),
  content: 'datepicker hint will tell you the datepicker\'s date range restriction',
  position: 'bottom'
}];

const gl = new guideline.Guideline(guideOptions, function (total, played) {
  console.log('guideline is over, total valid ', total, 'played ', played);
});

// set hint text maximum width
gl.hintTextMaxWidth = 800
// set hint text font size
gl.hintFontSize = 20

// start the guideline
gl.play();

// autoplay the next hint every 3 seconds
const timer = setInterval(function () {
  if (gl.hasNext()) {
    gl.next();
  } else {
    clearInterval(timer);
    gl.stop();
  }
}, 3000);

API

guideline(configuration, callback)

This is the simple way to play a guideline which accepts two parameters whose description are listed in the relevant sections as follows.

guideline.Guideline Constructor (configuration, callback)

This is the advanced way to play a guideline which parameters are the same as guideline(configuration, callback). It will return a Guideline instance based on whose prototype's method you can do more control during the playing.

configuration - guideline(configuration)

The configuration item should be an array, each of which is an object.

Configuration Subitem Object

Properties:

  • element (HTMLElement, optional) : the guided element. when element is null, the guideline text is centered relative to the browser window.
  • content (string, required) : the guideline text.
  • position (string, optional, defaults to 'bottom') : used to set the location of the guideline text relative to the guided element. enumerated type,value is 'top' or 'bottom'.
  • style (string, optional) : custom style for the guideline text.

callback(total, playedAmount) - guideline(configuration, callback)

callback is a function, which will be invoked when the guideline stops. callback takes two parameters total and playedAmount, representing the total amount of valid hints and the actual playback amount of hints.

Guideline instance properties

  • hintTextMaxWidth (number, defaults to 400) : used to limit the hint text maximum width, unit is pixel.
  • hintFontSize (number, defaults to 24) : used to define the hint text font size, unit is pixel.

Guideline instance method

  • play : start the guideline after doing some settings
  • prev : play the previous hint
  • next : play the next hint, if there's no more hint, stop the guideline and exit
  • hasNext : tell if there is a follow-up hint
  • stop : stop playing the guideline

Keyboard shortcuts

Guideline supports some keyboard shortcuts to play the next or previous hint as follows.

| keyboard | action | | --- | --- | | arrow right | play next | | enter | play next | | space | play next | | arrow left | play previous | | backspace | play previous | | esc | stop playing |

License

MIT