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-simple-notify

v0.0.17

Published

# React Simple Notify

Downloads

1,641

Readme

Logo

DEMO

React Simple Notify

Installation

Install React Notify using npm or yarn:

npm install react-simple-notify
# or
yarn add react-simple-notify

Simple usage

import { notify, NotifyContainers } from 'react-simple-notify';

function App() {
  const showNotification = () => {
    notify.open({
      render: ({ onClose }) => (
        <div>
          This is a notify!
          <button onClick={onClose}>Close</button>
        </div>
      ),
    });
  };

  return (
    <>
      <button onClick={showNotification}>Show Notify</button>
      <NotifyContainers />
    </>
  );
}

export default App;

Notify API

notify.open(options)

Opens a notification with customizable options.

| Parameter | Type | Description | Default Value | |----|--------------------------|--------------------------------------------------------------------------------------------------------|--------------------------| |id|string (optional)|A unique identifier for the notification. If not provided, a random ID will be generated.|Random ID| |duration|number (optional)|The time in milliseconds before the notification automatically closes. Set to 0 for persistent notifications.|3500| |alignment|NotifyAlignment (optional)|The position on the screen where the notification will appear.|NotifyAlignment.bottomLeft| |variant|string (optional)|Allows specifying a variant for custom styling or behavior.|-| |render|Function|A render function that returns the content of the notification. |-|

notify.close(id)

Closes the notification with the specified ID.

| Parameter | Type | Description | |----|-----------------------|--------------------------------------------------------------------------------------------------------| |id|string|The unique identifier of the notification to close.|

notify.closeAll()

Closes all currently open notifications. This function does not take any parameters.

Config API

config.set(props)

Sets the global configuration for notifications.

| Parameter | Type | Description | Default Value | |----|---------------------------------------------|--------------------------------------------------------------------------------------------------------|------------------------------| |alignment| NotifyAlignment (optional) |Global default alignment for notifications.| NotifyAlignment.bottomLeft | |animationConfig| AnimationConfig (optional) |Configuration for the enter and exit animations of notifications.| - | |notifyComponent| React.ComponentType / ReactNode (optional) |A custom React component or element that will wrap the notification content, allowing for custom layouts.| Fragment | |reverse| boolean (optional)|Determines whether notifications stack in reverse order.| false |

config.reset()

Resets the global configuration for notifications to their default values. This function does not take any parameters.

Customizing Notification Container Styles

--rsn-container-padding: Sets the padding around the notification container. Defaults to 10px, allowing you to control the space between the screen's edge and the notifications.

--rsn-container-gap: Defines the gap between individual notifications. The default value is 10px, which you can adjust to manage the spacing between notifications for visual clarity.

example

:root {
    --rsn-container-padding: 15px;
    --rsn-container-gap: 15px;
}

Example of Custom AnimationConfig:

{
  enter: {
    duration: 300,
    easing: "ease-out",
    keyframes: ({ alignment }) => {
      return [
        { opacity: 0, transform: "translateY(-100%)" },
        { opacity: 1, transform: "translateY(0)" }
      ];
    }
  },
  exit: {
    duration: 200,
    easing: "ease-in",
    keyframes: ({ node }) => {
      return [
        { opacity: 1, transform: "scale(1)" },
        { opacity: 0, transform: "scale(0.5)" }
      ];
    }
  }
}