Giter Site home page Giter Site logo

khuong291 / react-notification Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 0.0 825 KB

🚀A complete and totally customizable component for notifications in React. https://khuong291.github.io/react-notification/

License: MIT License

JavaScript 100.00%
react reactjs notification popup push-notifications alert javascript npm-package

react-notification's Introduction

react-notification

npm version npm Dependency Status devDependency Status Build Status Coverage Status

A complete and totally customizable component for notifications in React

Advanced notification system specification

  • You can request a notification to be displayed.
  • You can request a notification to hide.
  • A notification should not be displayed more than 5 seconds.
  • Multiple notifications can be displayed at the same time.
  • No more than 3 notifications can be displayed at the same time.
  • If a notification is requested while there are already 3 displayed notifications, then queue/postpone it.

Installing

npm install react-notification-popup

Contributing

  1. Fork project
  2. Checkout master branch
  3. Create Feature branch off of the master branch
  4. Create awesome feature/enhancement/bug-fix
  5. Optionally create Issue to discuss feature
  6. Submit pull request from your Feature branch to react-notification's master branch

Using

import React from "react";
import { render } from "react-dom";
import { notification, NotificationContainer } from "react-notification-popup";

notification.config = {
  maxNotifications: 3,
  notificationDisplayTime: 5000
};

const App = () => (
  <div>
    <NotificationContainer />
    <button
      onClick={() => {
        notification.emit(
          {
            providerURL:
              "http://icons.iconarchive.com/icons/johanchalibert/mac-osx-yosemite/1024/finder-icon.png",
            title: "Disk Not Ejected Properly",
            description:
              "Eject Time Machine before disconnecting or turning it off"
          },
          {
            onClick: () => console.log("Click!!"),
            onClose: () => console.log("Close!!")
          }
        );
      }}
    >
      show
    </button>
    <button
      onClick={() => {
        notification.dismissAll();
      }}
    >
      dismissAll
    </button>
  </div>
);

render(<App />, document.getElementById("root"));

Methods

config: ({ maxNotifications, notificationDisplayTime });

Configure notification. This is optional. The default maxNotifications is 3 and notificationDisplayTime is 5s.

emit: (
    {
      providerURL,
      title,
      description,
      closeButtonText = "Close",
      hasCloseButton = true,
      autoClose = true
    },
    { onClick = noop, onClose = noop }
)

Emit notification with some informations and callback handler.

dismissAll: onDismiss = noop;

Removes ALL notifications programatically.

Author

Khuong Pham

License

react-notification-popup is released under the MIT license.
See LICENSE for details.

react-notification's People

Contributors

khuong291 avatar

Stargazers

Mark Villacampa avatar idevnull avatar Sahinur Islam avatar Kevin.Y avatar silvio avatar René van Mil avatar Kollan House avatar Diego avatar Josh Gwosdz avatar Tri Huynh avatar samy kamkar avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.