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

@freelanco/roller

v0.5.6

Published

Light asynchronous intro package.

Downloads

6

Readme

Roller - a gorgeous intro package

The package exports seven classes: Roller, Guide, Overlay, Popover, Focus, Hover and Tip.

Types

  • HighlightGroup - it is object that contains Overlay(optional), Focus and Popover(optional) instances and beforeInsert, afterRemove functions.
  • Position - 'top' | 'bottom' | 'left' | 'right' | 'auto' - position of created helper element according to element on the page.

API

Roller

If you want highlight single element on your page, use Roller:

const roller = new Roller({
  onOverLayClick(group) {
    // some code that may change state of group element or
    // make another job.
  }
})
roller.highlight({
  async beforeInsert(wait) {}, // executes before roller starts highlight element.
  new Overlay(/* options */),
  new Focus(/* options */),
  new Popover(/* options */),
  async afterRemove(wait) {}, // executes after roller ends highlight and removes above elements from DOM.
})

Constructor parameters:

  • options?: Object
    • onOverlayClick?: (group: HighlightGroup, event: MouseEvent): void - this function defines what is need to be done on click on Overlay. By default it closes the whole group.

Methods:

  • highlight: (group: HighlightGroup) => Promise\<void> - highlights group.
  • unHighlight: (group: HighlightGroup) => Promise\<void> - hide group and remove its nodes from page.

Guide

For creating sequence of highlighting of elements you can use Guide.

const guide = new Guide({
  groups: [/* ... */], // This is array of groups of Overlay(optional), Focus and Popover with hooks. Group is the same as accept Roller.,
  overlay: new Overlay(), // This is global overlay for guide object. It can be overridden by overlay in group
  onDone() {
    // Invokes after last group will be highlighted.
  },
  onSkip() {
    // Invokes when user skips guide.
  }
})

After you create Guide, you must call configure() method of it. It is needed for define styles and text for controls:

guide.configure({
  skipButtonText: 'Skip', // default
  // ...
  skipButtonStyles: {
    // ...
  }
})
.start() // Starts guide.

Constructor parameters:

  • options: Object
    • groups: HighlightGroup[],
    • overlay?: Overlay,
    • onDone?: () => void,
    • onSkip?: () => void

Methods:

  • configure: (options?: GuideControllerOptions) => Guide:
    • skipButtonText?: string,
    • prevButtonText?: string,
    • nextButtonText?: string,
    • doneButtonText?: string,
    • footerStyle?: { [string]: string | number },
    • skipButtonStyle?: { [string]: string | number },
    • prevButtonStyle?: { [string]: string | number },
    • nextButtonStyle?: { [string]: string | number },
    • doneButtonStyle?: { [string]: string | number }

All styles keys and value must be valid CSS properties, written in kebab-case.

  • start: () => void - starts guide.
  • move: (step: number) => void - move to specific step. You basically will not use it.
  • cancel: () => void - hide highlighted group.

Hover

This class is created for adding help text on hovering specific element on the page.

const h = new Hover({
  position: 'top',
  offset: 10, // pixels
  hoverStyles: {
    // styles
  },
  onHover: // Function that invokes on element hovering,
  content: 'Some text'
})

Constructor parameters:

  • options: Object
    • position?: Position
    • offset?: number - distance from element on the page to Hover element.
    • hoverStyles?: { [string]: string | number }
    • onHover?: (event: MouseEvent) => Promise\<void>
    • content: string

Methods:

  • attachTo: (element: HTMLElement | string) => void - attach Hover instance to element on the page.
  • detach: () => void - remove Hover instance from the page and detach it from element.

Tip

This class represents tip on the page. It isn't attached to element on the page, but is positioned according to window.

const tip = new Tip({
  // Set position of the tip
  position: 'bottom-right' | 'top-left' | 'bottom-left' | 'center' | 'top-right'(default),
  tipStyles: { ... },
  descriptionStyles: { ... },
  closeButtonStyles: { ... },
  okButtonStyles: { ... },
  text: 'Some text here',
  okButtonText: 'OK', // default
  closeButtonText: 'Close', // default
  onClose(event) {
    // Invokes on closing tip
  },
  onOk(event) {
    // Invokes on clicking OK
  }
})

Focus

It is the main class that represent element that need to be highlighted. It receives options that must contain element property that represents CSS selector of element or HTMLElement itself:

const focus = new Focus('.some-class', {
  async beforeHighlight(node, wait) {
    // some code
    // node - DOM element that is highlighted.
    // `wait` asynchronous function is used if code must wait for some time
  },
  element: '.some-element', // Element that will be highlighted
  async afterHighlight(node, wait) {
    // some code
    // node - DOM element that is highlighted.
    // `wait` asynchronous function is used if code must wait for some time
  }
})
// or
const element = document.querySelector('.some-class')
if (element) {
  const focus = new Focus({ element })
}

Overlay

This class represents overlay on the page. You can set your own initial styles for it, end opacity and optional parameter isolateClickEvents:

const overlay = new Overlay({
  initialStyles: {
    'background-color': 'rgb(234, 54, 95)'
    // you must write valid CSS expressions in kebab-case
  },
  opacity: 0.75, // default
  isolateClickEvents: false // default. If `true` all events that is propagated inside of overlay will be isolated.
})

Popover

This class (if it is presented) represents explanation for highlighted element.

const popover = new Popover({
  position: 'auto', // default. Position of popover according to element.
  offset: '10px', // default. Distance of the popover from element.
  title: 'Some cool title', // Title of the explanation.
  description: 'Description' // Optional. Detailed description of the explanation.,
  styles: {
    // CSS valid styles in kebab-case.
  },
  isolateClickEvents: false // default. If `true` all events that is propagated inside of popover will be isolated.
})

Other

Package is created under MIT-style LICENSE.

Please, push your issues here, if there will be ones.

With ♡ from Freelanco.