Skip to content

Commit c9e4821

Browse files
committed
Merge branch 'develop'
2 parents 8cf571c + c1f6765 commit c9e4821

12 files changed

+488
-397
lines changed

.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modeules/
2+
dist/
3+
example/

.eslintrc

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"extends": "airbnb/legacy",
3+
"env": {
4+
"browser": true,
5+
"node": true
6+
},
7+
"plugins": [
8+
"react"
9+
],
10+
"ecmaFeatures": {
11+
"jsx": true
12+
},
13+
"rules": {
14+
"react/display-name": [2, { "acceptTranspilerName": true }],
15+
"react/jsx-curly-spacing": [2, "always"],
16+
"react/jsx-no-duplicate-props": 2,
17+
"react/jsx-no-undef": 2,
18+
"react/jsx-quotes": 0,
19+
"react/jsx-uses-react": 2,
20+
"react/jsx-uses-vars": 2,
21+
"react/no-did-mount-set-state": 2,
22+
"react/no-did-update-set-state": 2,
23+
"react/no-multi-comp": 2,
24+
"react/no-unknown-property": 2,
25+
"react/prop-types": 2,
26+
"react/react-in-jsx-scope": 2,
27+
"react/require-extension": 2,
28+
"react/self-closing-comp": 2,
29+
"react/wrap-multilines": 2,
30+
"react/sort-comp": 0,
31+
32+
"quotes": [2, "single", "avoid-escape"],
33+
"jsx-quotes": [2, "prefer-single"],
34+
"comma-dangle": [2, "never"],
35+
"indent": [2, 2],
36+
"object-curly-spacing": [2, "always"],
37+
"no-undef": 2,
38+
"no-underscore-dangle": 0,
39+
"func-names": 0,
40+
"no-else-return": 0,
41+
"no-console": 0,
42+
"no-throw-literal": 0,
43+
"id-length": 0
44+
}
45+
}

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
A complete and totally customizable notification system for React applications.
66

7+
Initially built for [Eterpret](http://dev.eterpret.com) @ [Scalable Path](http://www.scalablepath.com).
8+
79
![Example gif](example/example.gif "Example gif")
810

911
## Demo
@@ -18,6 +20,22 @@ For now this component is only available as CommonJS module. Install via NPM run
1820
npm install react-notification-system
1921
```
2022

23+
### Important
24+
25+
For **React 0.14.x**, use version 0.2.x:
26+
27+
```
28+
npm install [email protected]
29+
```
30+
31+
For **React 0.13.x**, use version 0.1.x:
32+
33+
```
34+
npm install [email protected]
35+
```
36+
37+
38+
2139
## Using
2240

2341
For optimal appearance, this component **must be rendered on a top level HTML element** in your application to avoid position conflicts.

example/build/app.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"prepublish": "npm run build",
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"watch": "watch 'npm run build' ./src",
10-
"build": "jsx ./src ./dist"
10+
"build": "jsx -x jsx ./src ./dist & jsx ./src ./dist",
11+
"lint": "eslint src --ext .jsx,.js"
1112
},
1213
"repository": {
1314
"type": "git",
@@ -31,6 +32,9 @@
3132
"object-assign": "^4.0.1"
3233
},
3334
"devDependencies": {
35+
"eslint": "^1.6.0",
36+
"eslint-config-airbnb": "^0.1.0",
37+
"eslint-plugin-react": "^3.5.1",
3438
"react-tools": "^0.13.2",
3539
"watch": "^0.16.0"
3640
}

src/helpers.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
var Helpers = {
2-
timer: function(callback, delay) {
3-
var timerId, start, remaining = delay;
2+
Timer: function(callback, delay) {
3+
var timerId;
4+
var start;
5+
var remaining = delay;
46

57
this.pause = function() {
6-
clearTimeout(timerId);
7-
remaining -= new Date() - start;
8+
clearTimeout(timerId);
9+
remaining -= new Date() - start;
810
};
911

1012
this.resume = function() {
11-
start = new Date();
12-
clearTimeout(timerId);
13-
timerId = setTimeout(callback, remaining);
13+
start = new Date();
14+
clearTimeout(timerId);
15+
timerId = setTimeout(callback, remaining);
1416
};
1517

1618
this.clear = function() {
1719
clearTimeout(timerId);
18-
}
20+
};
1921

2022
this.resume();
2123
}
22-
}
24+
};
2325

2426
module.exports = Helpers;

src/notification-container.js renamed to src/notification-container.jsx

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
var React = require('react');
22
var NotificationItem = require('./notification-item');
33
var Constants = require('./constants');
4-
var Helpers = require('./helpers');
54

65
var NotificationContainer = React.createClass({
76

87
propTypes: {
98
position: React.PropTypes.string.isRequired,
10-
notifications: React.PropTypes.array.isRequired
9+
notifications: React.PropTypes.array.isRequired,
10+
getStyles: React.PropTypes.object
1111
},
1212

1313
_style: {},
@@ -17,34 +17,35 @@ var NotificationContainer = React.createClass({
1717
this._style = this.props.getStyles.container(this.props.position);
1818

1919
if (this.props.getStyles.overrideWidth && (this.props.position === Constants.positions.tc || this.props.position === Constants.positions.bc)) {
20-
this._style['marginLeft'] = -(this.props.getStyles.overrideWidth / 2);
20+
this._style.marginLeft = -(this.props.getStyles.overrideWidth / 2);
2121
}
2222
},
2323

2424
render: function() {
2525
var self = this;
26+
var notifications;
2627

2728
if ([Constants.positions.bl, Constants.positions.br, Constants.positions.bc].indexOf(this.props.position) > -1) {
2829
this.props.notifications.reverse();
2930
}
3031

31-
var notifications = this.props.notifications.map(function(notification) {
32+
notifications = this.props.notifications.map(function(notification) {
3233
return (
3334
<NotificationItem
34-
ref={'notification-' + notification.uid}
35-
key={notification.uid}
36-
notification={notification}
37-
getStyles={self.props.getStyles}
38-
onRemove={self.props.onRemove}
39-
noAnimation={self.props.noAnimation}
40-
allowHTML={self.props.allowHTML}
35+
ref={ 'notification-' + notification.uid }
36+
key={ notification.uid }
37+
notification={ notification }
38+
getStyles={ self.props.getStyles }
39+
onRemove={ self.props.onRemove }
40+
noAnimation={ self.props.noAnimation }
41+
allowHTML={ self.props.allowHTML }
4142
/>
4243
);
4344
});
4445

4546
return (
46-
<div className={'notifications-' + this.props.position} style={this._style}>
47-
{notifications}
47+
<div className={ 'notifications-' + this.props.position } style={ this._style }>
48+
{ notifications }
4849
</div>
4950
);
5051
}

0 commit comments

Comments
 (0)