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

alert-js

v1.0.1

Published

A small js library for alerts

Downloads

3

Readme

alert-js

A small js library for alerts

####View a demo here

Alert-js is an easy way to integrate userfriendly, smoothly animated, in material design held alerts. Use them to display important information that needs to be seen NOW and let the user take actions. The action buttons have ripple effects, which are also styleable. You can show alerts with one function call and detect the clicked action just as easily. Users can also dismiss an alert by pressing esc and click the right-most action with enter. If you try to show an alert while one is already open, it gets stored in a queue and shown after the current one gets closed.

Setup

With npm:1. At the root of your index, type npm install ripple-js into the command line.2. Add the tag <script src="node_modules/alert-js/alert.min.js"></script> to your index file. If you want to show alerts on finished load, also add the script tag <script src="node_modules/ripple-js/ripple.min.js"></script> BEFORE!

Properties

  • accentColor stringSets the color of the action buttons and also the ripple effect for all future alerts°Corresponds to the css color and ripple-color property. Click here for more information°_Example:_ alert.accentColor = "green";°_Default value:_ "orange"
  • rippleOpacity FloatChange the opacity of the ripple for all future alerts°Corresponds to the ripple-opacity property. Click here for more information°_Example:_ alert.rippleOpacity = 0.3;°_Default value:_ 0.6
  • ripplePressExpandTime FloatChange how long the ripple takes to fully expand while it is being pressed for all future alerts°Corresponds to the ripple-press-expand-time property. Click here for more information°_Example:_ alert.ripplePressExpandTime = 3.3;°_Default value:_ 1.5
  • rippleReleaseExpandTime FloatSet in which time the ripple completes the ripple when the user lets go of it for all future alerts°Corresponds to the ripple-release-expand-time property. Click here for more information°_Example:_ alert.rippleReleaseExpandTime = 0.5;°_Default value:_ 0.3
  • rippleLeaveCollapseTime FloatChange how long the ripple takes to cancel°Corresponds to the ripple-leave-collapse-time property. Click here for more information°_Example:_ alert.rippleLeaveCollapseTime = 0.1;°_Default value:_ 0.4
  • open Boolean read-onlyTrue, when an alert is open and false otherwise°_Example:_ var isAlertOpen = alert.open;

###Methods

  • show()Call this function to display an alert. If an alert is already open, it gets stored in the queue°Parameters:  text: String    The text the alert should display. You can use html elements and style attributes just like in the document.  actions: Array of Strings optional    For every entry a corresponding button will be displayed in the alert. If ommited or empty, only an "OK" button will be displayed  options: Object optional    If you don't want to apply the global options to this alert, you can change the settings for only this alert with all properties (except open) described here. Possible example: {accentColor: "blue", rippleOpacity: 0.7}  mode String optional    Change how the queue should behave with one of the three following options:       "replace" This clears the queue, closes the old alert and instantly shows the new one       "next-in-queue" Instead of putting the alert at the end of the queue, this places the alert as the next one in the waiting queue       "next" Use this to show the new alert instantly instead of the current one, but preserve the queue°Return value:  The function returns a Promise, which resolves to the action the user clicked. See the examples for working code°Examples:   -alert.show("Hello world"); The most simple form of an alert.  -alert.show("We couldn't find your position for one of the following reasons:<ul><li>Your device doesn't support gps</li><li>You didn't grant us access to your position</li><li>The device can't find it's position</li></ul>"); You can use html tags just as you would expect.  -alert.show("Do you want to switch to our mobile website?", ["No", "Yes"]); While you should build responsive websites, this approach is also possible.  -alert.show("If you prefer green more...", [], {accentColor: "green"}); How to change the settings for only this alert. Note how actions is empty, so only "OK" will be displayed.  -alert.show("This information is so important that it needs to be displayed instantly, instead of all other alerts!", [], {}, "replace"); This will clear the queue and display the alert instantly.  -alert.show("Dou you want to delete this photo? There is no going back!", ["Cancel", "OK"]).then(function(action) { if(action == "OK") { //delete the photo }}); Detect what action the user clicks with this pattern.
  • hide()Use this to hide the alert without that the user needs to take an action.°_Example:_ alert.hide();
  • clearQueue()This does what it sound like, it clears the queue of waiting alerts.°_Example:_ alert.clearQueue();

Tips & Notes

  • If you wan to hide the current alert and also the one in the queue, call alert.clearQueue(); before calling alert.hide();.
  • This library uses my other library, ripple-js, which you can find here.
  • If you use ripple-js otherwhere in your project or want to show alerts on page load, import ripple-js before importing alert-js. If those uses don't fit your use case, you don't need to import ripple-js, as it will be imported automatically.
  • If you don't want to have a ripple effect, set rippleOpacity to 0.