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-toast-fly

v0.0.14

Published

ToastFly is a lightweight and customizable React toast notification library designed to deliver smooth and stylish notifications in your React applications.

Downloads

24

Readme

ToastFly

ToastFly is a lightweight and customizable React toast notification library designed to deliver smooth and stylish notifications in your React applications.

Features

  • Customizable: Easily adjust the look and behavior of notifications to match your application's design.
  • Simple API: A straightforward API for triggering notifications.
  • TypeScript Support: Built with TypeScript for better development experience and type safety.
  • Flexible: Support for various toast types and progress indicators.

Installation

To install ToastFly, use npm or yarn:

pnpm add react-toast-fly
# or
npm install react-toast-fly
# or
yarn add react-toast-fly

Usage

To use the react-toast-fly you need to install tailwind css first. All the styling are customizable with tailwind css.

Installation

we created a wrapper component and a toast function.

    • ToastProvider: It provides a wrapper around all the components and it receives globalOptions props that provides the basics for the toast notifications. it provides all the option below.
<ToastProvider
	globalOption={{
		turn: true,
		duration: 1000,
		isStacked: true,
		successIcon: SuccessIconComponent,
		warningIcon: WarningIconComponent,
		errorIcon: ErrorIconComponent,
		infoIcon: InfoIconComponent,
		direction: 'rtl' // ltr
	}}
>
	{/*- children -*/}
</ToastProvider>
  • turn: if it sets to true, all the notifications are paused and only the last one will get an interval. when the last one is finished, the next one will get an interval
  • duration: A straightforward API for triggering notifications.
  • isStacked: Built with TypeScript for better development experience and type safety.
  • direction: Support for various toast types and progress indicators.
  • Icons: Easily adjust the look and behavior of notifications to match your application's design.
    • push: this is a function that generates toast. you can call it on the client side of your react app to generate toast
    <button
	onClick={() => {
		push({
			title: 'test',
			duration: 1000,
			progress: Progress.Both,
			type: ToastType.SUCCESS,
			content: 'example content',
			duration:100,
			id:"some id"
		})
	}}
>Show</button>

content and icons can be react components.

    const ContentComponent = ()=>{
        return <div><strong>Content</strong></div>
    }
	
    <button
	onClick={() => {
		push({
			title: 'test',
			duration: 1000,
			progress: Progress.Both,
			type: ToastType.SUCCESS,
			content:ContentComponent,
		})
	}}
>Show</button>

Next js Installation

In order to work with next js app router, the ToastProvider needs to be imported in a client component and then the client component needs to be imported in the main layout. also the css needs to be imported as well

As an example

'use client'
import React, {ReactNode} from 'react';
import {useRouter} from "next/navigation";
import {ToastProvider} from "react-toast-fly";
import {NextUIProvider} from "@nextui-org/react";
import {ThemeProvider as NextThemesProvider} from "next-themes";

import "react-toast-fly/dist/style.css"

export default function NextUiProvider({children}: { children: ReactNode }) {
	const {push} = useRouter();
	return (
		<ToastProvider
			globalOption={{
				turn: true,
				isStacked: true,
			}}
		>
			<NextUIProvider navigate={push}>
				<NextThemesProvider forcedTheme="dark" attribute="class" defaultTheme="dark">
					{children}
				</NextThemesProvider>
			</NextUIProvider>
		</ToastProvider>
	);
}



 In the Main layout of Next js App router
 
		<html dir="rtl" lang="fa-IR" className={`${dana.variable} font-sans scroll-smooth dark`} style={{colorScheme: 'dark'}}>
		<body>
		<NextUiProvider>
			<Main>
				{children}
			</Main>
		</NextUiProvider>
		</body>
		</html>