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

hone

v1.1.0

Published

Hone is the best backdrop and element highlighting utility available for modern browsers.

Downloads

1,097

Readme

Hone

Hone is the best backdrop and element highlighting utility available for modern browsers.

Installation

Install with NPM, Bower, or manually:

$ npm install hone -S
$ bower install hone -S

add the script tag or import/require:

<script src="node_modules/hone/dist/hone.js"></script>

<script src="bower_components/hone/dist/hone.js"></script>

<script src="resources/vender/hone.js"></script>
import Hone from 'hone';

var Hone = require('hone');

There are no dependencies!

API

Instantiate

Start by creating a new Hone instance:

import Hone from 'hone';

const lookAtMe = document.getElementById('showOff'),
    hone = new Hone(lookAtMe);

By default, when you pass an element to the constructor, the Hone instance will become visible immediately.

Options

The constructor takes some options as well. Here are the defaults:

const defaultOptions = {
    classPrefix: 'hone',    //all components are given style classes like "<prefix>-component"
    fixed: false,           //set to true if the element is position: fixed
    borderRadius: 0,        //creates rounded corners (all four or nothing)
    enabled: true,          //controls the visibility and event listeners
    padding: '0',           //adds padding around the target, same format as CSS padding rule
    fullScreen: false       //should the backdrop be full screen (for a modal window)
};

Instance Methods

The Hone instance has a minimal public API:

| Method | Description | | -------------------------- | ---------------------------------------------------------------------- | | Hone#hide() | hides the backdrop | | Hone#show() | shows the backdrop | | Hone#position(target?) | repositions the backdrop, and can position to a new target if provided | | Hone#setOptions(options) | change instance options | | Hone#destroy() | removes all event listeners and DOM elements |

Tips

  • If you are going to be repositioning the Hone instance frequently, even with new targets, create a single Hone instance and use the Hone#position(target) method to reposition instead of creating new instances for each target. (See example)
  • Both constructor parameters are optional. Not providing a target just disables the Hone instance by default.
  • Pass the enabled option into the constructor as false to initially hide the Hone instance

Examples

For an element in a fixed header:

import Hone from 'hone';

const menuItem = document.getElementById('menuItemAbout'),
    hone = new Hone(menuItem, {
        fixed: true
    });

Creating a backdrop behind a modal window:

import Hone from 'hone';

//no target required for a full screen Hone instance
const hone = new Hone({
    fullScreen: true
});

Positioning against a new target:

import Hone from 'hone';

const menuItemAbout = document.getElementById('menuItemAbout'),
    menuItemContact = document.getElementById('menuItemContact'),
    hone = new Hone(); //if no target is provided, it instantiates but does not enable

//position against first menu item
hone.position(menuItemAbout);

//wait for user input maybe? Then position against next menu item
hone.position(menuItemContact);