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

poppy-popup

v1.0.2

Published

Custom popups to replace vanilla JavaScript prompts

Downloads

4

Readme

PoppyPopup

Custom popups to replace vanilla JavaScript prompts.

ChangeLog

  • Added comments to all code
  • Added support for require.js and AMD
  • Added main.js file to test modules

Installation

  1. Run npm install poppy-popup
  2. Copy style in your project. You can choose between .css or .scss file.
  3. Require it in your project: const PoppyPopup = require('poppy-popup')'
  4. Enjoy using new Prompts!

Usage

To display an alert popup:

PoppyPopup.alert("Hey, pay attention! A popup appears.");

To display a confirm popup:

PoppyPopup.confirm("Do you know how to use this?");

To display a prompt popup:

PoppyPopup.prompt("Write your name:");

All methods accept the popup content (you can use HTML also), next the title of the popup and an object with some options.

PoppyPopup.alert("Popop content", "Title", options);

Default options params:

const options = {
    showBackground: true,
    removeWhenClose: true,
    width: 400 + "px",
    keyboardSupport: true,
    cancelButton: true,
    valueText: "",
    placeholderText: "",
    accept: function() { return true; },
    cancel: function() { return false; }
}
  • showBackground: when the popup appears, it's over a semitransparent black div that prevents missclicks out of the popup.
  • removeWhenClose: when it's set to true, the popup will be removed from the DOM when its closed, otherwise, the popup just disappears but it stays on the DOM.
  • width: the width of the popup, a string with compatible units like em, px, %; i.e. "150px" or "50%".
  • keyboardSupport: sets if Enter and Esc keys should work. Enter to accept and Esc to cancel.
  • cancelButton: sets if cancel button should be present on prompt and confirm popups
  • valueText: the value the input will contain (just prompt).
  • placeholderText: the placeholder the input will contain (just prompt).
  • accept: function that will be called when the user clicks the accept button. On alerts and confirms it gets a param that returns the popup id; in prompts it has the value of the input.
  • cancel: function that will be called when the user clicks the cancel button.

Alert, confirm and prompt have an acceptCallback after options, so you can omit the accept param at options.

And confirm and prompt have a cancelCallback after the accept one so you can omit the cancel param at options.

These are all the params methods accept: (just content is not optional)

PoppyPopup.alert(content, title, options, acceptCallback);
PoppyPopup.confirm(content, title, options, acceptCallback, cancelCallback);
PoppyPopup.prompt(content, title, options, acceptCallback, cancelCallback);

Configuration

All colors and measures are SCSS variables so you can change them and recompile the file in order to replace previous values quickly.

Screenshots