Coder Social home page Coder Social logo

bzalasky / re-notif Goto Github PK

View Code? Open in Web Editor NEW

This project forked from indexiatech/re-notif

0.0 2.0 0.0 563 KB

Redux & React based Notifications center.

Home Page: http://indexiatech.github.io/re-notif

License: BSD 3-Clause "New" or "Revised" License

JavaScript 98.84% CSS 1.16%

re-notif's Introduction

re-notif

React & Redux based notifications center.

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

Features such auto dismiss and styling are supported (see below)

Setup

Installation

npm install --save re-notif

Note: for the fade animation to work properly, the css file re-notif/lib/re-notif.css must be included

Enhance reducer

Enhance Your Redux root reducer with the notification reducer:

import { reducer as notifReducer } from 're-notif';
combineReducers({
  notifs: notifReducer,
  ...more reducers here...
})

Notifications Container Placement

In your application DOM tag put the Notifs component

import { Notifs } from 're-notif';
class App extends Component {
  render() {
    <div className="content">
      <Notifs/>
    </div>
  }
}

Sending notifications

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

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

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

render() { Send } }

Demo

Watch the demo or checkout its source code

API

Components

<Notifs theme={object} CustomComponent={ReactComponent}/>

- theme.infoClasses : string [optional]

The CSS classes to attach to an info kind notification.

- theme.successClasses : string [optional]

The CSS classes to attach to an success kind notification.

- theme.warningClasses : string [optional]

The CSS classes to attach to an warning kind notification.

- theme.dangerClasses : string [optional]

The CSS classes to attach to an danger kind notification.

- CustomComponent : React Component

A custom component to render for every notification fired, component will have the following props:

- props.message

The notification's message.


Reducer

The notifications reducer, should be mounted under notifs.


Actions

actions.sendNotif(config:Object)

Send a notification

-config.message : string

The notification message

- config.kind : enum [optional]

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

- config.dismissAfter: integer [optional]

Auto dismiss the notification after the given number of MS.

actions.notifClear()

Clear all current notifications.

re-notif's People

Contributors

asaf avatar bzalasky avatar

Watchers

 avatar James Cloos 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.