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

quick-toastify

v2.0.3

Published

This is a toast library built with typescript and tailwindcss

Downloads

16

Readme

Quick-Toastify Library

A customizable toast notification library built with Next.js and TypeScript. Easily integrate toast notifications into your Next.js projects with customizable animations, durations, positions, and types. Frontend_System_Design_Questions__Toast_Component___HLD_LLD

Features

  • Customizable Animations: Choose from fade, pop, slide, or bounce animations for both entrance and exit.
  • Multiple Positions: Display notifications in various positions on the screen.
  • Flexible Duration: Set the duration for how long the toast notification should be visible.
  • Icon and Color Variants: Different icons and colors for various types of notifications.
  • Open Source: Contribute or view the source code on GitHub.

Usage

Setup

First, import and use the useToast hook in your component:

import React from "react";
import useToast from "quick-toastify";

export default function Home() {
  const { toastComponent, triggerToast } = useToast("Your position here");

  return (
    <>
      <h1 className="text-white text-3xl text-center mx-4 md:mx-10 mt-6">
        Customize your notifications! Choose from different animations and
        durations to suit your needs.
      </h1>
      <div className="grid place-items-center gap-4 p-4 sm:p-6 md:p-10 grid-cols-1 md:grid-cols-2 lg:grid-cols-4">
        <button
          onClick={() =>
            triggerToast({
              type: "your type here",
              message: "Your messaage",
              duration: duration here in milliseconds,
              animationIn: "animation name",
              animationOut: "animation name",
            })
          }
        >
          Success Fade Animation
        </button>
        {/* More buttons for different types and animations */}
      </div>

      {toastComponent} {/*It's the thing which is most important without the library doesn't work*/}
    </>
  );
}

useToast Hook

  • toastComponent: Render this in your component to display the toast notifications.
  • triggerToast: Function to trigger a toast notification.

Parameters for triggerToast

  • type (optional): The type of notification ("info", "success", "warning", "error"). Default is "info".
  • message: The message to be displayed in the toast.
  • duration (optional): Duration for which the toast will be visible in milliseconds. Default is 3000.
  • animationIn (optional): Animation for the toast entrance ("fade", "pop", "slide", "bounce"). Default is "fade".
  • animationOut (optional): Animation for the toast exit ("fade", "pop", "slide", "bounce"). Default is "fade".

Notification Types

  • info: Provides general information.
    • Icon: AiOutlineInfoCircle
    • Color: #2196f3
  • success: Indicates a successful action.
    • Icon: AiOutlineCheckCircle
    • Color: #4caf50
  • warning: Alerts about potential issues.
    • Icon: AiOutlineWarning
    • Color: #ff9800
  • error: Indicates an error or failure.
    • Icon: AiOutlineCloseCircle
    • Color: #f44336

Positions

You can specify the position of the toast notification on the screen by passing one of the following values to the useToast hook:

  • top-left
  • top-right
  • bottom-left (default)
  • bottom-right

Example

<button
  onClick={() =>
    triggerToast({
      type: "info",
      message: "This is an info notification",
      duration: 3000,
      animationIn: "pop",
      animationOut: "pop",
    })
  }
>
  Info Pop Animation
</button>

Default Values

  • Position: "bottom-left"
  • Animation In: "fade"
  • Animation Out: "fade"
  • Duration: 3000 ms

Contributing

Feel free to open an issue or submit a pull request on GitHub if you have suggestions or improvements.