1.0.6 • Published 7 years ago

react-light-notifications v1.0.6

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

react-light-notifications

Travis npm package Coveralls

šŸ’” Note: This project is a modified version of react-notifications.

LIVE DEMO

Installation

yarn add react-light-notifications

or

npm i react-light-notifications

Example

import {
  NotificationContainer,
  NotificationManager
} from "react-light-notifications";
import "react-light-notifications/lib/main.css";

const App = () => (
  <div>
    <button
      onClick={() => {
        NotificationManager.info({
          title: 'Information Title',
          message: 'Information message',
          onClick: () => {
            console.log('Clicked on the notification');
          }
        });
      }}
    >
      Info
    </button>

    <NotificationContainer />
  </div>
);

export default App;

Notification Types

NotificationManager.success({
  title: 'Success Title',
  message: 'Success message'
});

NotificationManager.error({
  title: 'Error Title',
  message: 'Error message'
});

NotificationManager.info({
  title: 'Info Title',
  message: 'Info message'
});

NotificationManager.warning({
  title: 'Warning Title',
  message: 'Warning message'
});

Custom

NotificationManager.custom({
  title: 'Custom Title',
  message: 'Custom message',
  bgColor: 'purple',
  iconClassName: 'custom-icon'
});

Options

NameTypeDefault
titlestringnull
messagestringnull
showCloseButtonbooltrue
timeOutnumber5000
priorityboolfalse
onClickfunctionempty

The following options are only available on custom type:

NameTypeDefault
bgColorstringnull
iconClassNamestringnull

Example:

/**
 *
 * @param {object} options
 * @param {string} options.title
 * @param {string} options.message
 * @param {bool} options.showCloseButton
 * @param {bool} options.timeOut
 * @param {bool} options.priority
 * @param {function} options.onClick
 * @param {function} options.bgColor
 * @param {function} options.iconClassName
 */
NotificationManager.custom({
  title: 'Custom Title',
  message: 'Custom message',
  showCloseButton: true,
  timeout:400,
  priority: false,
  bgColor: 'purple',
  iconClassName: 'custom-icon',
  onClick: () => {
    console.log('NOTIFICATION ON CLICK');
  }
});
1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago