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

power-notifier

v1.1.3

Published

POWER NOTIFIER 3000

Downloads

1

Readme

POWER NOTIFIER 3000

Powerful notifier for your webapp.

Highly customizable, yet easy to use. It works perfectly out of box. You don't need to import CSS or declare containers in your html.

Basic usage:

The following lines will display default blue card with title and body

//es6 import
import { notify } from "power-notifier";
notify({
    title: "Title",
    message: "Message body"
});

//require
var Notifier = require("power-notifier");
Notifier.notify({
    title: "Title",
    message: "Message body"
});

This library is based on native Javascript APIs, so it works perfectly with anything that runs in browser. It works with Vanilla js and every Javascript framework (React, Vue, Svelte, Angular).

Styling

Instead of styling in-place, like you do with majority of notification libraries, POWER-NOTIFIER-3000 allows you to declare custom css and then reuse it everywhere.

//some js file/component
import { createStyle } from "power-notifier";
createStyle("POWER-NOTIFIER-3000-SUPER-ERROR-STYLE", {
    header: {
        //css applied to head section
    },
    content: {
        //css applied to body section
    },
    buttonsSection: {
        //css applied to whole buttons section
    },
    button: {
        //css applied to each button
    }
});

//some other js file/component
import { notify } from "power-notifier";
notify({
    title: "Title",
    message: "Message body",
    applyStyle: "POWER-NOTIFIER-3000-SUPER-ERROR-STYLE"
});

It aslo inherits your css styles. It allows you to style your POWER-NOTIFIER-3000 notifications from a stylesheet instead of js.

POWER-NOTIFIER-3000-FAQ

  • Q: Well, I don't want any title for this particular error, only message, is it possible with POWER-NOTIFIER-3000?
  • A: Everything related to the notifications is possible with POWER-NOTIFIER-3000. Just pass only the message to notify, it will figure out that you don't want any title. Same thing for body message:
import { notify } from "power-notifier";

notify({
    message: "This notification has no title"
});

notify({
    title: "This notification has no body"
});
  • Q: And what if I want to do something once notification is gone?
  • A: You can attach a listener to your notification:
import { notify, NotificationUpdate } from "power-notifier";

notify({
    message: "Listener",
    onStateUpdate: function (state) {
        if(state === NotificationUpdate.CLOSED){
            //do some extra cool stuff here
        }
    }
});
  • Q: Will it go away by itself?
  • A: If you want, it will:
import { notify } from "power-notifier";

notify({
    message: "Listener",
    timeout: 5000//go away after 5 seconds
});
  • Q: Why should I use POWER-NOTIFIER-3000?

  • A: It is easy to setup. It is easy to use. It has cool name.

  • Q: And if I need a confirmation? Like Yes/No buttons?

  • A: You can pass them as buttons property to notification

import { notify } from "power-notifier";

notify({
    title: "Notification with buttons",
    message: "This notification has some buttons.",
    buttons: [
        { text: "Answer A", action: "answerA" },
        { text: "Answer B", action: "answerB" }
    ],
    onStateUpdate: function (action) {
        if(action === "answerA"){
            //do things when button A is pressed 
        } else if(action === "answerB"){
            //do things when button B is pressed
        }   
    }
});
  • A: You can also use confirm method which will create Accept/Decline buttons automatically
import { confirm, NotificationUpdate } from "power-notifier";

confirm({
    title: "Confirm",
    message: "This is a confirm notification",
    onStateUpdate: function (action) {
        if(action === NotificationUpdate.ACCEPTED){
            //do things when accepted 
        } else if(action === NotificationUpdate.DECLINED){
            //do things when declined
        }   
    }
});

Input

  • @param title - card title
  • @param message - card message
  • @param timeout - time in milliseconds before automatic closing (if null will not be closed automatically)
  • @param applyStyle - style to apply
  • @param onStateUpdate - triggered for each event (SHOWN, CLOSED, TIME_OUT, ACCEPTED, DECLINED, custom)
  • @param buttons - array of {text, action} buttons
  • @param closeOnClick - close when clicked