Skip to content

Commit 3025aac

Browse files
committed
initial
0 parents  commit 3025aac

24 files changed

+17657
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = false
9+
insert_final_newline = true
10+
indent_style = tab
11+
12+
[*.json]
13+
indent_style = space
14+
indent_size = 2

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.publish/*
2+
dist/*
3+
example/dist/*
4+
lib/*
5+
node_modules/*

.eslintrc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true
6+
},
7+
"plugins": [
8+
"react"
9+
],
10+
"rules": {
11+
"curly": [2, "multi-line"],
12+
"quotes": [2, "single", "avoid-escape"],
13+
"react/display-name": 0,
14+
"react/jsx-boolean-value": 1,
15+
"react/jsx-quotes": 1,
16+
"react/jsx-no-undef": 1,
17+
"react/jsx-sort-props": 0,
18+
"react/jsx-sort-prop-types": 1,
19+
"react/jsx-uses-react": 1,
20+
"react/jsx-uses-vars": 1,
21+
"react/no-did-mount-set-state": 1,
22+
"react/no-did-update-set-state": 1,
23+
"react/no-unknown-property": 1,
24+
"react/prop-types": 1,
25+
"react/react-in-jsx-scope": 1,
26+
"react/self-closing-comp": 1,
27+
"react/wrap-multilines": 1,
28+
"semi": 2,
29+
"strict": 0
30+
}
31+
}

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Coverage tools
11+
lib-cov
12+
coverage
13+
coverage.html
14+
.cover*
15+
16+
# Dependency directory
17+
node_modules
18+
19+
# Example build directory
20+
example/dist
21+
.publish
22+
23+
# Editor and other tmp files
24+
*.swp
25+
*.un~
26+
*.iml
27+
*.ipr
28+
*.iws
29+
*.sublime-*
30+
.idea/
31+
*.DS_Store

README.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# react-notification-system-redux
2+
3+
Wrapps [react-notification-system](https://github.com/igorprado/react-notification-system) into a component and exposes actions and reducer.
4+
5+
Open for PR's and contributions!
6+
7+
## Demo & Examples
8+
9+
Live demo: [gor181.github.io/react-notification-system-redux](http://gor181.github.io/rreact-notification-system-redux/)
10+
11+
To build the examples locally, run:
12+
13+
```
14+
npm install
15+
npm start
16+
```
17+
18+
Then open [`localhost:8000`](http://localhost:8000) in a browser.
19+
20+
21+
## Installation via NPM
22+
23+
```
24+
npm install react-notification-system-redux react-notification-system --save
25+
```
26+
27+
## Usage
28+
29+
Import the reducer and pass it to your store:
30+
31+
```
32+
import {createStore, combineReducers} from 'redux';
33+
34+
import {reducer as notifications} from 'react-notification-system-redux';
35+
36+
export function configureStore(initialState = {}) {
37+
return createStore(
38+
combineReducers({
39+
notifications
40+
}),
41+
initialState
42+
);
43+
}
44+
```
45+
46+
Include the Notifications component and pass the data from the reducer by using `connect`:
47+
48+
```
49+
import React, {PropTypes} from 'react';
50+
import {connect} from 'react-redux';
51+
import ReactDOM from 'react-dom';
52+
53+
import Notifications from 'react-notification-system-redux';
54+
55+
class DemoComponent extends React.Component {
56+
57+
render() {
58+
const {notifications} = this.props;
59+
60+
return (
61+
<Notifications notifications={notifications} />
62+
);
63+
}
64+
}
65+
66+
DemoComponent.contextTypes = {
67+
store: PropTypes.object
68+
};
69+
70+
DemoComponent.propTypes = {
71+
notifications: PropTypes.array
72+
};
73+
74+
export default connect(
75+
state => ({ notifications: state.notifications })
76+
)(DemoComponent);
77+
```
78+
79+
Dispatch notification actions from any other component:
80+
81+
```
82+
import React, {PropTypes} from 'react';
83+
import {connect} from 'react-redux';
84+
import ReactDOM from 'react-dom';
85+
86+
import Notifications from 'react-notification-system-redux';
87+
88+
const notificationOpts = {
89+
// uid: 'once-please', // you can specify your own uid if required
90+
title: 'Hey, it\'s good to see you!',
91+
message: 'Now you can see how easy it is to use notifications in React!',
92+
position: 'tr',
93+
autoDismiss: 0,
94+
action: {
95+
label: 'Click me!!',
96+
callback: () => alert('clicked!')
97+
}
98+
};
99+
100+
class OtherComponent extends React.Component {
101+
102+
constructor() {
103+
super();
104+
105+
this.handleClick = this.handleClick.bind(this);
106+
}
107+
108+
handleClick() {
109+
this.context.store.dispatch(
110+
Notifications.success(notificationOpts)
111+
);
112+
}
113+
114+
render() {
115+
const {notifications} = this.props;
116+
117+
return (
118+
<div>
119+
<button onClick={this.handleClick}>
120+
Spawn some notifications!!!
121+
</button>
122+
</div>
123+
);
124+
}
125+
}
126+
127+
OtherComponent.contextTypes = {
128+
store: PropTypes.object
129+
};
130+
131+
export default OtherComponent;
132+
```
133+
134+
There is a working example in example/src/**
135+
136+
### Properties
137+
It accepts all properties as react-notification-system does, actually it pipes them in the react-notification-system.
138+
139+
## Development (`src`, `lib` and the build process)
140+
141+
**NOTE:** The source code for the component is in `src`. A transpiled CommonJS version (generated with Babel) is available in `lib` for use with node.js, browserify and webpack. A UMD bundle is also built to `dist`, which can be included without the need for any build system.
142+
143+
To build, watch and serve the examples (which will also watch the component source), run `npm start`. If you just want to watch changes to `src` and rebuild `lib`, run `npm run watch` (this is useful if you are working with `npm link`).
144+
145+
## Thanks
146+
147+
Jed Watson for making react-component yo builder!
148+
149+
## License
150+
151+
MIT Licensed
152+
Copyright (c) 2016 Goran Udosic && Headstart App.

bower.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "react-notification-system-redux",
3+
"version": "0.0.0",
4+
"description": "Redux wrapper for react-notification-system",
5+
"main": "dist/react-notification-system-redux.min.js",
6+
"homepage": "https://github.com/gor181/react-notification-system-redux",
7+
"authors": [
8+
"Goran Udosic"
9+
],
10+
"moduleType": [
11+
"amd",
12+
"globals",
13+
"node"
14+
],
15+
"keywords": [
16+
"react-notification-system",
17+
"redux",
18+
"notifications",
19+
"react",
20+
"react-component"
21+
],
22+
"license": "MIT",
23+
"ignore": [
24+
".editorconfig",
25+
".gitignore",
26+
"package.json",
27+
"src",
28+
"node_modules",
29+
"example",
30+
"test"
31+
]
32+
}

0 commit comments

Comments
 (0)