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

@simondmc/popup-js

v1.4.3

Published

A sleek and highly customizable JavaScript library used to generate full-screen infographic popups with minimal effort.

Downloads

32

Readme

popup-js

A sleek and highly customizable JavaScript library used to generate full-screen infographic popups with minimal effort.

Installation

Install popup-js with the following script tag:

<script src="https://cdn.jsdelivr.net/npm/@simondmc/[email protected]/popup.min.js"></script>

Documentation

A full documentation is available here.

Usage/Examples

Create a popup by instantiating the Popup class with customization parameters.

const myPopup = new Popup({
    id: "my-popup",
    title: "My First Popup",
    content: `
        An example popup.
        Supports multiple lines.`,
});

Display the popup by calling the .show() method.

myPopup.show();

Examples of a more complex popup:

/* A demo popup showing a lot of the library features. */
const popup = new Popup({
    id: "demo-popup",
    title: "Demo Popup",
    content: `
        This is a demo of the popup library.
        big-margin§This line has a larger top margin.
        This is an example of {a-https://example.com}[a link].
        This is an example of {btn-red-button}[a red button].
        This text is {red}[red] {bold green}[bold green] {blue}[blue]].
        This text has a                lot of spaces.
        big-margin space-out§This line and the next {btn-b1}[Button 1]
        space-out§are left aligned. {btn-b2}[Button 2]
        big-margin§This text {shadow}[has {white}[some] shadow].`,
    titleColor: "#4842f5",
    backgroundColor: "#bff7ff",
    showImmediately: true,
    sideMargin: "15%",
});
/* A popup from one of my projects showing its usage. */
const infoPopup = new Popup({
    id: "color-info",
    title: "Color Guesser",
    content: `
        You are presented with a color.
        Estimate the hex code of the color.
        Six characters, ranging from 00-FF for 3 channels.
        Values are in {a-https://learn.sparkfun.com/tutorials/hexadecimal/hex-basics}[Base-16].
        big-margin§{bold}[#{red}[E4]{green}[F2]{blue}[DB]]
        big-margin§{black bold}[#000000] is black.             {white bold shadow}[#FFFFFF] is white.
        big-margin§Good luck.`,
    titleColor: "rgb(92, 0, 95)",
    titleMargin: "0",
    backgroundColor: "#ffebfe",
    showImmediately: true,
    showOnce: true,
});

Color Guesser Popup Showcase

Cheat Sheet

Below is a table of all the parameters you can use to customize your popup.

| Parameter | Type | Default | Description | | -------------------- | ---------- | --------------- | ---------------------------------------------------------------------------------------------------- | | id | string | popup | The ID of the popup (must be unique). | | title | string | Popup Title | The title of the popup. | | content | string | Popup Content | The content of the popup. | | titleColor | color | #000000 | The color of the title. | | backgroundColor | color | #FFFFFF | The color of the popup background. | | textColor | color | #000000 | The color of the content. | | closeColor | color | #000000 | The color of the close button. | | linkColor | color | #383838 | The color of links. | | fixedHeight | boolean | false | Whether the popup should have a fixed height. | | widthMultiplier | number | 1 | How wide should the popup be relatively to the default width. | | heightMultiplier | number | 0.66 | How tall should the popup be relatively to the default width (only used if fixedHeight is true). | | fontSizeMultiplier | number | 1 | How large should the content font be relatively to the default content font size. | | font | string | Inter | The popup font. | | titleMargin | length | 2% | The space between the popup title and content. | | sideMargin | length | 3% | The space between the content and the edge of the popup. | | lineSpacing | length | auto | The spacing between lines in the popup body. | | buttonWidth | length | fit-content | The width of buttons in the popup body. | | borderWidth | length | 0 | The width of the popup border. | | borderColor | color | #000000 | The color of the popup border. | | borderRadius | length | 15px | The popup border radius (controls how rounded the corners are). | | showImmediately | boolean | false | Whether the popup should be shown immediately after being created (usually on page load). | | showOnce | boolean | false | Whether the popup should only be shown once. | | hideCloseButton | boolean | false | Whether the popup should display without a close button. | | hideTitle | boolean | false | Whether the popup should display without a title. | | disableScroll | boolean | true | Whether page scrolling should be disabled while the popup is open. | | underlineLinks | boolean | false | Whether links should be underlined. | | allowClose | boolean | true | Whether the popup should be closeable by the user. | | textShadow | string | none | The text shadow of the popup body. | | fadeTime | time | 0.3s | The time it should take for the popup to fade in and out. | | hideCallback | function | undefined | A function to be called when the popup is closed. | | loadCallback | function | undefined | A function to be called when the popup - and all its elements - are first loaded. | | css | string | "" | Custom CSS to be applied to the popup. |

For a full explanation of the parameters, see the documentation.

License

This project is released under the MIT license.

Contributing

Contributions are always welcome!

If you want a feature which currently doesn't exist, feel free to open a pull request.