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

winjet

v0.0.2

Published

Make elements window-like: a floating titled container, draggable and resizable.

Downloads

3

Readme

License: MIT Build Status

winjet

Make elements window-like: a floating titled container, draggable and resizable.

winjet example

const widget = require('winjet');

const myElm = document.getElementById('target');

widget('My Title', myElm, {options}).mount();

When the first parameter is a string, your widget will get a default header (like in the image above) and the string will be used as the title text. The default header comes with 3 action buttons for closing, maximizing and minimizing the widget.

When the first parameter is an HTMLElement, it will be used as the widget's whole header. Action buttons are not included.

widget(myHeaderElm, myBodyElm, {options});

 

IMPORTANT NOTE: Widget is based on classnames & css. Meaning, some of the API methods only manipulate the widget classnames and results can only be seen by using a matching css. You can use ./default-style.css as a starting point.

 

Options

  • minWidth - Number. Resize minimum width in pixels. (default = 0)
  • minHeight - Number. Resize minimum height in pixels. (default = 0)
  • top - Number. Initial top position in pixels.
  • bottom - Number. Initial bottom position in pixels.
  • left - Number. Initial left position in pixels.
  • right - Number. Initial right position in pixels.
  • id - String. The widget id attribute. No default.
  • classname - String. The widget class attribute. No default.
  • showActions - Boolean. Show action buttons (maximize, minimize, close). (default = true)
  • showClose - Boolean. Show the close button. (default = true)
  • showMinimize - Boolean. Show the minimize button. (default = true)
  • showMaximize - Boolean. Show the maximize button. (default = true)
  • showHeader - Boolean. Show the widget header. (default = true)
  • toggleHeader - Boolean. Toggle the header visibility on hover. Show on enter, hide on leave. (default = false)
  • toggleActions - Boolean. Toggle the action buttons visibility on hover. Show on enter, hide on leave. (default = false)

API

Calling the widget() function returns a Widget instance:

const w = widget(elm);

It has the following methods:

.mount()

Appends the widget to the <body> and binds event listeners.

.unmount()

Removes the widget from the DOM and unbinds event listeners.

.show() / .hide()

Toggle widget visibility.

.showHeader(optionalGrip) / .hideHeader(optionalGrip)

Toggle widget header visibility. If you pass an element or an element selector string, it will be used as the drag grip handle. By default it's the widget title, or the widget body (if there's no header or it's hidden).

.showActions() / .hideActions()

Toggle widget action buttons visibility.

.minimize()

Minimizes the widget by hiding its body, only the header is visible.

.unMinimize()

Reverts the .minimize() by showing the body. Does not maximize.

.maximize()

Maximizes the widget (fullscreen). Disables drag & resize.

.unMaximize()

Reverts the .maximize() to previous widget size. Does not minimize.

.restoreSize()

Reverts both .minimize() & .maximize().

.setTitle(String)

Sets a new widget title.

.setHeader(HTMLElement)

Sets a new custom header. Replaces the default header.

.setBody(HTMLElement)

Sets a new widget body.

.setView(title, body)

Sets a new widget title and body (or header and body).

.destroy()

Kills the Widget instance for good, unbinds events, releases element references.

 

Position:

On initialization, the target element will be placed inside the <body> element and will be given an inline style of position: absolute.

Events

A widget instance holds two instances of draggable-elm & resizable-elm. You can listen to their different events. Check out their docs to learn more.