• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redux & React based Notifications center.

redux-notifications

✔️: Use the use-disposable-list (unstyled) hook that can work with any css framework!



⚠️ The previous package re-notif has been deprecated on NPM and renamed to redux-notifications. A list of changes can be found in the Changelog. Please update your applications accordingly.

React & Redux based notifications center.

Thanks to Redux, the notification objects are maintained within Redux Store's State and are fired by Actions.

Implementation

1. Installation

npm install --save redux-notifications

2. The next thing you need to do is to add the redux-notifications reducer to Redux.
import { createStore, combineReducers } from 'redux'
import { reducer as notifReducer } from 'redux-notifications';
combineReducers({
  notifs: notifReducer,
  // ... more reducers here ...
})
3. Add the Notifs component at the root of your app
import { Provider }  from 'react-redux'
import { Notifs } from 'redux-notifications';

<Provider store={store}>
  <div>
    // ... other things like router ...
    <Notifs />
  </div>
</Provider>
4. Optionally import default CSS

redux-notifications uses react-css-transition-group with the following classes:

  • .notif-transition-enter
  • .notif-transition-enter-active
  • .notif-transition-leave
  • .notif-transition-leave-active

To import the default stylesheet:

import 'redux-notifications/lib/styles.css';

Sending notifications

Thanks to Redux, sending notification is simply done by firing an Action:

import { reducer as notifReducer, actions as notifActions, Notifs } from 'redux-notifications';
const { notifSend } = notifActions;

class Demo extends React.Component {
  send() {
    this.props.dispatch(notifSend({
      message: 'hello world',
      kind: 'info',
      dismissAfter: 2000
    }));
  }

  render() {
    <button onClick={this.send}>Send Notification</button>
  }
}

Actions

actions.notifSend({config})

config.message : node [required]

The notification message, can be one of: string, integer, element or array containing these types.

config.kind : string [optional] [default:'info']

The notification kind, can be one of: info, success, warning, danger.

config.id : string [optional] [default:Date.now()]

Set an ID for the notification. If not set, defaults to Date.now().

config.dismissAfter : integer [optional] [default:null]

Auto dismiss the notification after the given number of milliseconds.

actions.notifClear()

Clear all current notifications.

actions.notifDismiss(id)

Dismiss a notification by ID


Notifs Component

<Notifs CustomComponent={ReactComponent}/>

CustomComponent : React component

A custom react component can be used instead of the default Notif component

className : string [optional] [default:null]

Pass a custom classname to the component.

componentClassName : string [optional] [default:'notif']

The base className for each Notif component. Can be used to override CSS styles.

transitionEnterTimeout : integer [optional] [default:600]

Define the react-transition-group enter timeout is milliseconds.

transitionLeaveTimeout : integer [optional] [default:600]

Define the react-transition-group leave timeout is milliseconds.

actionLabel : string

Label for action click

onActionClick : func

Function when action is clicked. Requires actionLabel prop

Development

git clone https://github.com/indexiatech/re-notif.git
cd re-notif
npm install
npm run start

Listening on localhost:9000

More Repositories

1

redux-immutablejs

Redux Immutable facilities.
JavaScript
685
star
2

ember-forms

Smart, Intuitive forms for Ember.js styled with Bootstrap, Multi layouts and Validation support.
JavaScript
218
star
3

ember-components

Rich components for Ember.js framework.
JavaScript
184
star
4

antiquity

Antiquity - A versioned graph extension.
Java
37
star
5

ember-idx-tree

An ambitious Tree Component for Ember.js
JavaScript
27
star
6

ember-idx-wysiwyg

Ambitious WYSIWYG (What you see is what you get) html editor written purely in Ember.js
JavaScript
18
star
7

ember-idx-modal

Ember Indexia Modal
JavaScript
17
star
8

ember-idx-tabs

Ambitious tabs component.
JavaScript
17
star
9

ember-idx-button

An ambitious button with async & styling support for Ember.js
JavaScript
11
star
10

hapi-elastic

Hapi Plugin for Elastic Search
JavaScript
8
star
11

ember-idx-tour

Ambitious Tour for Ember.js
JavaScript
7
star
12

ember-idx-accordion

Ambitious accordion component.
JavaScript
7
star
13

ember-cli-components

Ember Components as ember-cli addon
JavaScript
6
star
14

ember-idx-charts

Ambitious charts for Ember.js
JavaScript
6
star
15

ember-idx-list

Ambitious list of items with selection & states.
JavaScript
3
star
16

gulp-release-flows

Gulp Release flow plugin
JavaScript
2
star
17

indexiatech.github.io

Web site
JavaScript
2
star
18

ember-cli-pegjs

PegJs Ember CLI addon
JavaScript
2
star
19

ember-idx-utils

A set of utilities for Ember.js
JavaScript
2
star
20

hapier

A happier way to use Hapi.
JavaScript
2
star
21

ember-idx-gmaps

Ambitious Google Maps Component for Ember.js
JavaScript
1
star
22

react-helmet

JavaScript
1
star