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

toastjs-react

v1.0.12

Published

This is a toast message library

Downloads

5

Readme

Installation

Follow the instructions to install ToastJS-React

$ npm install toastjs-react

Usage

Add ToastJS-React CSS file to your index.js.

import 'toastjs-react/index.css'

You must add your app components or elements between

<ToastContainer>

component.

import { ToastContainer } from 'toastjs-react'

return (
  <ToastContainer maxMessageCount={5} position="center">
    <App />
  </ToastContainer>
);

You can limit your max toasts in your projects using below.

Change Your Maximum Toast

maxMessageCount={5} // Optional, default = 10

Change Your Toast Positin

position={"left"|"right"|"center"} // Optional, default = "right"

You could have many toasts in your screen. ToastJS-React is going to add them to a queue. It will show them in order. For example: You have 8 toasts. And you set your max toast = 5 then firstly you are going to see 5 toasts until they become to fade out. Next, you are going to see other 3 toasts.

Show Your Toast

 // Import useGlobalMessage Hook
 import { useGlobalMessage } from 'toastjs-react';
 
 // Call It In Your Component
 const toast = useGlobalMessage();

 // And Show It!
 toast.show({
    type: "success",
    message: "You have been added your item succesfully.",
    autoCloseWithTimeout: true,
    timeout: 2000,
});

Product Name Screen Shot

Properties

    {
        // Message Which Will Be Shown
        message:string,

        // Type
        type:"info"|"error"|"success"|"warning",

        /* 
        * You can add a timeout for your toast. After this time it will be fade out. 
        * Optional, default = 1000ms
        */
        timeout:number,

        /*
        * If you want to close your toast after timeout. You must set it as "true".
        * Optional, default = false
        */
        autoCloseWithTimeout:boolean,

        /*
        * There is an animation in your toast but you can deactive it below.
        * Optional
        */
        animation:{
            /* 
            * If you do not want to any animation. Set it as "false".
            * Optional, default = true 
            */
            slideAnimation:boolean

            /*
            * You can also add a duration for your animation.
            * Optional, default = 1000
            */
            animationDuration:number
        },

        /*
        * This is your header. You can add an element. It would change depends your type.
        * If you want to custom header change it.
        * Optional, default = null
        */
        header:React.ReactElement,

        /*
        * This is your body. You can add an element.
        * If you want to custom body change it.
        * Optional, default = null
        */
        body:React.ReactElement,

        /*
        * You can change your toast class name with this properties.
        * Optional, default = ".message_wrapper"
        */
        className:string,

        /*
        * This is title of toast. Depends your type.
        * If you want to custom title change it.
        * Optional, default = ""
        */
        title:string,

        /*
        * This is button of toast.
        * Optional
        */
        button:{
            /* 
            * Change class name for your custom style. 
            * Optional, default = ""
            */
            className?:string,

            /* 
            * Change title for your custom button title. 
            * Optional, default = "OK"
            */
            title?:string
        },

        /*
        * You do not have to use our toast component. You can create a custom and define it.
        * Optional, default = null
        */
        Component?: React.FC,

        /*
        * You can use to fetch with promise
        * Also, you can take error or success response and no matter what 'hasError' is 
        * successComponent is for when the result is successfull otherwise errorComponent but if promise is in fetching, Component will be shown by default
        */
        fetchingOptions?:{
           promise: Promise<any>
           errorComponent: (response?:any)=>React.ReactElement
           successComponent: (response?:any)=>React.ReactElement
           response: (response: object, hasError: boolean) => void
        }

    }

Built With

React

License

Distributed under the MIT License.