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

nonnyalertjs

v1.0.6

Published

NonnyAlertJs is an easy-to-use JavaScript library for alerting users on the frontend. It provides warning alerts, success alerts, and danger alerts based on specific actions. It is especially useful for scenarios such as when a user enters the wrong passw

Downloads

2

Readme

NonnyAlertJs

NonnyAlertJs is an easy-to-use JavaScript library for alerting users on the frontend. It provides warning alerts, success alerts, and danger alerts based on specific actions. It is especially useful for scenarios such as when a user enters the wrong password, clicks the wrong button, successfully registers, or makes a successful payment.

This library is lightweight, well-tested, and designed to minimize the impact on your application's load time. It accepts several arguments: time (in milliseconds) to wait before the alert auto-hides, position for positioning the alerts, textColor for the alert text color, and backgroundColor for the confirmation box's background color.

Usage

To use NonnyAlertJs, follow these steps:

  • Include the NonnyAlertJs library in your project using CDN.
<script src="https://coding-nonny.github.io/alert-notify/dist/alertify.js"></script>
  • Create an instance of AlertNotify by providing the appropriate arguments:
const message = new AlertNotify(time, position);

The arguments time, position are optional. If not provided, default values will be used.
The time and position only works when you are using positioned-modal.

  • Call the alert_message method to display an alert message:
message.alert_message(messageText, messageType,alertType);

The messageText parameter represents the text to be displayed in the alert message, and messageType (optional) represents the type of alert (e.g., "warning", "success", "danger","info").

The alertType determines the type of alert-box you want to use e.g Postioned-modal or fixed-modal. Using the fixed-modal requires that you include alert-box.css from the style folder for proper functionality. Default alertType is fixed-modal.

Fixed Modal

positioned-modal Fixed Modal

Confirmation box Fixed Modal

  • (Optional) Use the shouldAutoHide method to control whether the alert message should auto-hide:
message.shouldAutoHide(autoHide);

The autoHide parameter is a boolean value (default is true). When set to true, the alert message will auto-hide. When set to false, the alert message will remain visible until the user clicks on it.

  • Note
    The autoHide() only works when you are using positioned-modal.

  • (Optional) Use the alert_Confirm method to display a confirmation message:

document.querySelector(".click").onclick =  async () => {
if (await message.alert_Confirm("Do You Think This Is Good?")) {
  message.alert_message("You clicked Yes", "success");
} else {
  message.alert_message("You clicked No", "warning");
}
message.shouldAutoHide(true);
};

Positioning Alerts

NonnyAlertJs provides several positioning options for the alerts. You can use the following values for the position argument: | Position | Description | | --------------- | ----------------------------- | | center | Center of the screen | | bottom-center | Bottom center of the screen | | bottom-right | Bottom right of the screen | | bottom-left | Bottom left of the screen | | top-center | Top center of the screen | | top-left | Top left of the screen | | top-right | Top right of the screen |

Using with React

NonnyAlertJs can also be used in React. To use it in a React component, follow these steps:

  1. Install the NonnyAlertJs package using a package manager like npm:
npm install nonnyalertjs
  1. Import the necessary dependencies:
import React from 'react';
import AlertNotify from 'nonnyalertjs';
import 'nonnyalertjs/style/alert-box.css'; // Import the CSS file
  1. Create an instance of AlertNotify and use it in your React component:
const MyComponent = () => {
const message = new AlertNotify(time, position, textColor, backgroundColor);

const handleConfirmation = async () => {

if (await message.alert_Confirm("Do You Think This Is Good?")) {
  message.alert_message("You clicked Yes", "success");
} else {
  message.alert_message("You clicked No", "warning");
}
message.shouldAutoHide(true);
};

return (
<div>
<button onClick={handleConfirmation}>Click Me</button>
</div>
);
};

export default MyComponent;

or use my already made component notify.jsx located in component folder

Make sure to import the CSS file provided by NonnyAlertJs to ensure the styles are applied correctly.

With these steps, you can now use NonnyAlertJs in your React components and take advantage of its alerting and confirmation features.

Note:

Remember to replace time and position with the desired values when creating the AlertNotify instance.

click here for live example