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

react-toasts-forked-esm

v3.0.9

Published

Simple react alerter.

Downloads

11

Readme

License Version

Lightweight react toasts manager

import { ToastsContainer, ToastsContainerPosition, ToastsStore } from 'react-toasts-forked-esm';
import 'react-toasts-forked-esm/lib/styles.css';

react-toasts is a very simple and lightweight component to create toasts.

alt text

Demo url : https://vashnak.com/react-toasts/

How to use

$ npm install -S react-toasts

You will need to import the ToastsContainer component and the ToastsStore.

import {ToastsContainer, ToastsStore} from 'react-toasts';

function render(){
    return <div>
        <button onClick={() => ToastsStore.success("Hey, you just clicked!")}>Click me</button>
        <ToastsContainer store={ToastsStore}/>
    </div>
}

The use is very easy. ToastsContainer is, as its name suggests, the toast container while ToastsStore is the toasts manager. The ToastsContainer must be linked to the ToastsStore, so we must set it as a parameter (see the code above). It will not work if you forget it!

Now you can simply call one of the 4 functions of the ToastStore (success, info, warning, error):

function n(message: string | HTMLElement, timer?: number = 3000, classNames?: string): void

Like this:

ToastStore.success('Hey, it worked !');

The timer parameter is optional and its default value is 3000ms. The classNames parameter is also optional, if you have multiple classes to add, please separate them with a space ("class1 class2 ...").

The container can have 6 positions, TOP_RIGHT, TOP_LEFT, TOP_CENTER, BOTTOM_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER. By default its position is BOTTOM_RIGHT. You can change it by using the enum ToastsContainerPosition

<ToastContainer position={ToastsContainerPosition.TOP_LEFT}/>

If you want the toasts to have a light background, add the lightBackground property to the ToastsContainer component.

<ToastContainer position={ToastContainer.POSITION.TOP_LEFT} lightBackground/>

Updates

3.0.0

Rewrite with typescript, updated typos, optimized build, now support HTML in toast messages.

2.0.7

Now support line break in toasts (\n).

2.0.8

Added a class on each toasts.

2.0.9

Can now add custom classes to toasts.