Skip to content
This repository was archived by the owner on Dec 24, 2019. It is now read-only.

Commit 3dc59bd

Browse files
author
Patrick Burtchaell
authored
Merge pull request #145 from pburtchaell/pburtchaell-parcel
Implement Parcel
2 parents 63d7b26 + 68f8564 commit 3dc59bd

27 files changed

+21145
-10465
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# top-most EditorConfig file
21
root = true
32

43
[*.js]

.eslintrc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
"es6": true,
77
"mocha": true
88
},
9-
"ecmaFeatures": {
10-
"jsx": true,
11-
"modules": true
12-
},
139
"rules": {
14-
"comma-dangle": [2, "never"],
15-
"indent": [2, 2],
10+
"comma-dangle": [
11+
2,
12+
"never"
13+
],
14+
"indent": [
15+
2,
16+
2
17+
],
1618
"consistent-return": 0,
17-
"react/jsx-indent-props": [2, 2],
19+
"react/jsx-indent-props": [
20+
2,
21+
2
22+
],
1823
"react/jsx-uses-react": 2,
1924
"react/jsx-uses-vars": 2,
2025
"react/jsx-boolean-value": 0,
@@ -38,4 +43,4 @@
3843
"mount": true,
3944
"jsdom": true
4045
}
41-
}
46+
}

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

bin/test.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

examples/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/index.html

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.cache
2+
dist
3+
node_modules
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!doctype html public>
2-
<title>Notification Tree Example</title>
2+
<title>Notification Tree</title>
33
<body>
4-
<a href="/">React Notification Examples</a> / Notification Tree <hr />
4+
<h1>React Notification Examples / Notification Tree</h1>
55
<div id="mount" />
6-
<script src="/__build__/shared.js"></script>
7-
<script src="/__build__/notification-tree.js"></script>
6+
<script async src="./index.js"></script>
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,58 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, Fragment } from 'react';
22
import { render } from 'react-dom';
3-
import { OrderedSet } from 'immutable';
4-
import { NotificationStack } from 'react-notification';
3+
import { NotificationStack } from '../../src/index.js';
54

6-
class Example extends Component {
5+
class NotificationTreeExample extends Component {
76
constructor(props) {
87
super(props);
98

109
this.state = {
11-
notifications: OrderedSet(),
12-
// This is just used for the sake of an example to make sure
13-
// notifications have unique keys. In production, you should have
14-
// a different system for UIDs.
10+
notifications: [],
1511
count: 0
1612
};
1713

14+
this.addNotification = this.addNotification.bind(this);
1815
this.removeNotification = this.removeNotification.bind(this);
1916
}
2017

21-
2218
addNotification() {
2319
const { notifications, count } = this.state;
20+
2421
const id = notifications.size + 1;
2522
const newCount = count + 1;
26-
return this.setState({
23+
24+
this.setState({
2725
count: newCount,
28-
notifications: notifications.add({
26+
notifications: [{
2927
message: `Notification ${id}`,
3028
key: newCount,
3129
action: 'Dismiss',
32-
dismissAfter: 3400,
33-
onClick: () => this.removeNotification(newCount),
34-
})
30+
dismissAfter: 3400
31+
}, ...notifications]
3532
});
3633
}
3734

38-
removeNotification (count) {
35+
removeNotification(notification) {
3936
const { notifications } = this.state;
37+
4038
this.setState({
41-
notifications: notifications.filter(n => n.key !== count)
42-
})
39+
notifications: notifications.filter(n => n.key !== notification.key)
40+
});
4341
}
4442

45-
render () {
43+
render() {
4644
return (
47-
<div>
48-
<button onClick={this.addNotification.bind(this)}>
45+
<Fragment>
46+
<button onClick={this.addNotification}>
4947
Add notification
5048
</button>
5149
<NotificationStack
52-
notifications={this.state.notifications.toArray()}
53-
onDismiss={notification => this.setState({
54-
notifications: this.state.notifications.delete(notification)
55-
})}
50+
notifications={this.state.notifications}
51+
onDismiss={this.removeNotification}
5652
/>
57-
</div>
53+
</Fragment>
5854
);
5955
}
6056
}
6157

62-
render(<Example />, document.querySelector('#mount'));
58+
render(<NotificationTreeExample />, document.querySelector('#mount'));

0 commit comments

Comments
 (0)