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

customizable-toast-notification

v3.0.3

Published

A highly customizable toast notification library for modern web applications.

Downloads

112

Readme

🌟 Connect with Me!

Please feel free to connect or reach out for feedback, suggestions, or any kind of requirements or fixes—just anything—at:

📧 [email protected]

Your support is highly appreciated! 🙌 If you'd like to show some love, please leave a message of appreciation and don't forget to add your message when supporting me through the QR code below! 💬💖

Support Me

will surely revert! ---->

Customizable Toast Notification Library

A simple and highly customizable toast notification library for modern JavaScript applications. This library allows you to easily display toast notifications with various configurations to enhance user experience.

Table of Contents

Features

  • Display notifications of different types: info, success, error, and warning.
  • Customizable background and text colors.
  • Support for custom messages and default messages.
  • Adjustable display duration and positioning on the screen.
  • Close button functionality for user control.
  • Animation effects for a smooth appearance and disappearance.

Installation

You can install the library via npm:

npm install customizable-toast-notification

Usage

To use the toast notification library, you need to import it in your JavaScript or TypeScript file:

import { createToast, setDefaultColors, setDefaultMessages } from 'customizable-toast-notification';

// Create a toast notification
createToast({
  message: 'This is a custom message!',
  duration: 5000, // Duration in milliseconds
  position: 'top-right', // Position of the toast
  type: 'success', // Type of notification
  backgroundColor: 'green', // Custom background color
  textColor: 'white', // Custom text color
  showCloseButton: true, // Show close button
  animationDuration: '0.5s', // Duration of the animations
  animationEasing: 'ease', // Easing function for the animations
});

API Reference

createToast

Creates a toast notification with the provided options.

Parameters

  • options (Object): Options for the toast notification.
    • message (string, optional): The message to display in the toast. Defaults based on type if not provided.
    • duration (number, optional): The duration the toast should be displayed, in milliseconds (default is 3000).
    • position (string, optional): The position of the toast on the screen (default is 'bottom-right').
    • type (string, optional): The type of the toast (info, success, error, warning, default is 'info').
    • backgroundColor (string, optional): Custom background color for the toast notification.
    • textColor (string, optional): Custom text color for the toast notification (default is 'white').
    • showCloseButton (boolean, optional): Whether to show a close button (default is false).
    • animationDuration (string, optional): Duration of the fade-in and fade-out animations (default is '0.5s').
    • animationEasing (string, optional): Easing function for the animations (default is 'ease').

Example

createToast({
  message: 'Operation completed successfully!',
  type: 'success',
});

setDefaultColors

Sets default colors for different toast types.

Parameters

  • newColors (Object): New colors to set for toast types, where keys are the toast types (info, success, error, warning).

Example

setDefaultColors({
  info: 'blue',
  success: 'green',
  error: 'red',
  warning: 'orange',
});

setDefaultMessages

Sets default messages for different toast types.

Parameters

  • newMessages (Object): New messages to set for toast types, where keys are the toast types (info, success, error, warning).

Example

setDefaultMessages({
  info: 'This is an informational message!',
  success: 'Your action was successful!',
  error: 'An error has occurred!',
  warning: 'This is a warning message!',
});

Examples

Basic Usage

createToast({
  message: 'Welcome to our website!',
  duration: 4000,
  type: 'info',
});

Custom Colors and Messages

setDefaultColors({
  success: '#28a745',
  error: '#dc3545',
});

setDefaultMessages({
  success: 'Data saved successfully!',
  error: 'Failed to save data.',
});

createToast({
  type: 'success',
  message: 'Data saved successfully!',
});

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.