![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Hone is the best backdrop and element highlighting utility available for modern browsers.
Hone is the best backdrop and element highlighting utility available for modern browsers.
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!
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.
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)
};
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 |
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)Hone
instance by default.enabled
option into the constructor as false to initially hide the Hone
instanceFor 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);
FAQs
Hone is the best backdrop and element highlighting utility available for modern browsers.
The npm package hone receives a total of 174 weekly downloads. As such, hone popularity was classified as not popular.
We found that hone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.