Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 00ea1ed

Browse files
committed
Use Babel 6
Use Redux-devtools 3 Remove umd build Update deps
1 parent 98e940c commit 00ea1ed

11 files changed

+115
-102
lines changed

.babelrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"stage": 0,
3-
"loose": "all"
2+
"plugins": ["transform-react-jsx"],
3+
"presets": ["es2015", "stage-0"]
44
}

.eslintignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
lib
22
**/node_modules
3-
**/webpack.config.js
4-
examples/**/server.js

.eslintrc

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"rules": {
99
"react/jsx-uses-react": 2,
1010
"react/jsx-uses-vars": 2,
11-
"react/react-in-jsx-scope": 2
11+
"react/react-in-jsx-scope": 2,
12+
"no-console": 0,
13+
// Temporarily disabled due to babel-eslint issues:
14+
"block-scoped-var": 0,
15+
"padded-blocks": 0
1216
},
1317
"plugins": [
1418
"react"

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
node_modules
22
*.log
33
.DS_Store
4-
dist
54
lib
65
coverage
76
.idea

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ src
44
test
55
examples
66
coverage
7+
.idea

package.json

+24-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
22
"name": "redux-devtools-chart-monitor",
33
"version": "0.1.0",
4-
"description": "Monitor for Redux dev tools to visualize your store as a chart",
5-
"main": "lib/ChartMonitor.js",
4+
"description": "Chart monitor for Redux DevTools",
5+
"main": "lib/index.js",
66
"scripts": {
77
"clean": "rimraf lib dist",
88
"build": "babel src --out-dir lib",
9-
"build:umd": "webpack src/ChartMonitor.js dist/redux-devtools-chart-monitor.js && NODE_ENV=production webpack src/ChartMonitor.js dist/redux-devtools-chart-monitor.min.js",
109
"lint": "eslint src examples",
11-
"prepublish": "npm run lint && npm run clean && npm run build && npm run build:umd"
10+
"prepublish": "npm run lint && npm run clean && npm run build"
1211
},
1312
"repository": {
1413
"type": "git",
1514
"url": "https://github.com/romseguy/redux-devtools-chart-monitor.git"
1615
},
1716
"keywords": [
1817
"redux",
19-
"monitor",
18+
"devtools",
19+
"flux",
20+
"react",
2021
"chart"
2122
],
2223
"author": "romseguy",
@@ -26,20 +27,27 @@
2627
},
2728
"homepage": "https://github.com/romseguy/redux-devtools-chart-monitor",
2829
"devDependencies": {
29-
"babel": "^5.5.8",
30-
"babel-core": "^5.6.18",
31-
"babel-eslint": "^3.1.15",
32-
"babel-loader": "^5.1.4",
33-
"eslint": "^0.23",
34-
"eslint-config-airbnb": "0.0.6",
35-
"eslint-plugin-react": "^2.3.0",
30+
"babel-cli": "^6.1.2",
31+
"babel-core": "^6.1.2",
32+
"babel-eslint": "^4.1.4",
33+
"babel-loader": "^6.0.1",
34+
"babel-plugin-transform-react-jsx": "^6.0.18",
35+
"babel-preset-es2015": "^6.1.2",
36+
"babel-preset-stage-0": "^6.1.2",
37+
"eslint": "^1.10",
38+
"eslint-config-airbnb": "2.0.0",
39+
"eslint-plugin-react": "^3.11.3",
3640
"rimraf": "^2.3.4",
37-
"webpack": "^1.9.6"
41+
"webpack": "^1.11.0"
42+
},
43+
"peerDependencies": {
44+
"react": "^0.14.0",
45+
"redux-devtools": "^3.0.0-beta-3"
3846
},
3947
"dependencies": {
40-
"d3-state-visualizer": "^0.4.4",
48+
"d3-state-visualizer": "^0.5.0",
4149
"deepmerge": "^0.2.10",
42-
"react": "^0.13.3",
43-
"redux-devtools": "^2.1.2"
50+
"react-pure-render": "^1.0.2",
51+
"redux-devtools-themes": "^1.0.0"
4452
}
4553
}

src/ChartMonitor.js

+65-41
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import React, { PropTypes, Component } from 'react';
2-
import * as themes from 'redux-devtools/lib/react/themes';
2+
import shouldPureComponentUpdate from 'react-pure-render/function';
3+
import * as themes from 'redux-devtools-themes';
4+
import { ActionCreators } from 'redux-devtools';
35
import deepmerge from 'deepmerge';
6+
7+
import reducer from './reducers';
48
import Chart from './Chart';
9+
const { reset, rollback, commit, sweep, toggleAction } = ActionCreators;
510

611
const styles = {
712
container: {
@@ -14,50 +19,76 @@ const styles = {
1419
}
1520
};
1621

17-
export default class ChartMonitor extends Component {
18-
constructor(props) {
19-
super(props);
20-
}
22+
class ChartMonitor extends Component {
23+
static reducer = reducer;
2124

2225
static propTypes = {
23-
computedStates: PropTypes.array.isRequired,
24-
currentStateIndex: PropTypes.number.isRequired,
25-
monitorState: PropTypes.object.isRequired,
26-
stagedActions: PropTypes.array.isRequired,
27-
skippedActions: PropTypes.object.isRequired,
28-
reset: PropTypes.func.isRequired,
29-
commit: PropTypes.func.isRequired,
30-
rollback: PropTypes.func.isRequired,
31-
sweep: PropTypes.func.isRequired,
32-
toggleAction: PropTypes.func.isRequired,
33-
jumpToState: PropTypes.func.isRequired,
34-
setMonitorState: PropTypes.func.isRequired,
26+
dispatch: PropTypes.func,
27+
computedStates: PropTypes.array,
28+
actionsById: PropTypes.object,
29+
stagedActionIds: PropTypes.array,
30+
skippedActionIds: PropTypes.array,
31+
monitorState: PropTypes.shape({
32+
initialScrollTop: PropTypes.number
33+
}),
34+
35+
preserveScrollTop: PropTypes.bool,
3536
select: PropTypes.func.isRequired,
36-
visibleOnLoad: PropTypes.bool
37+
theme: PropTypes.oneOfType([
38+
PropTypes.object,
39+
PropTypes.string
40+
])
3741
};
3842

3943
static defaultProps = {
4044
select: (state) => state,
41-
monitorState: {isVisible: true},
4245
theme: 'nicinabox',
43-
visibleOnLoad: true
46+
preserveScrollTop: true
4447
};
4548

49+
shouldComponentUpdate = shouldPureComponentUpdate;
50+
51+
constructor(props) {
52+
super(props);
53+
this.handleToggleAction = this.handleToggleAction.bind(this);
54+
this.handleReset = this.handleReset.bind(this);
55+
this.handleRollback = this.handleRollback.bind(this);
56+
this.handleSweep = this.handleSweep.bind(this);
57+
this.handleCommit = this.handleCommit.bind(this);
58+
}
59+
60+
handleRollback() {
61+
this.props.dispatch(rollback());
62+
}
63+
64+
handleSweep() {
65+
this.props.dispatch(sweep());
66+
}
67+
68+
handleCommit() {
69+
this.props.dispatch(commit());
70+
}
71+
72+
handleToggleAction(id) {
73+
this.props.dispatch(toggleAction(id));
74+
}
75+
76+
handleReset() {
77+
this.props.dispatch(reset());
78+
}
79+
4680
getTheme() {
47-
let theme;
48-
49-
if (typeof this.props.theme === 'string') {
50-
if (typeof themes[this.props.theme] !== 'undefined') {
51-
theme = themes[this.props.theme];
52-
} else {
53-
console.warn('DevTools theme ' + this.props.theme + ' not found, defaulting to nicinabox');
54-
theme = themes.nicinabox;
55-
}
56-
} else {
57-
theme = this.props.theme;
81+
let { theme } = this.props;
82+
if (typeof theme !== 'string') {
83+
return theme;
84+
}
85+
86+
if (typeof themes[theme] !== 'undefined') {
87+
return themes[theme];
5888
}
5989

60-
return theme;
90+
console.warn('DevTools theme ' + theme + ' not found, defaulting to nicinabox');
91+
return themes.nicinabox;
6192
}
6293

6394
getChartStyle() {
@@ -98,15 +129,6 @@ export default class ChartMonitor extends Component {
98129
return deepmerge(defaultOptions, props);
99130
}
100131

101-
componentWillMount() {
102-
let visibleOnLoad = this.props.visibleOnLoad;
103-
const { monitorState } = this.props;
104-
this.props.setMonitorState({
105-
...monitorState,
106-
isVisible: visibleOnLoad
107-
});
108-
}
109-
110132
render() {
111133
const theme = this.getTheme();
112134

@@ -117,3 +139,5 @@ export default class ChartMonitor extends Component {
117139
);
118140
}
119141
}
142+
143+
export default ChartMonitor;

src/actions.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const SOME_ACTION = '@@redux-devtools-chart-monitor/SOME_ACTION';
2+
export function someAction(data) {
3+
return { type: SOME_ACTION, data };
4+
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default from './ChartMonitor';

src/reducers.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { SOME_ACTION } from './actions';
2+
3+
function someAction(state = 0, action, props) {
4+
return action.type === SOME_ACTION ?
5+
action.data :
6+
state;
7+
}
8+
9+
export default function reducer(state = {}, action, props) {
10+
return {
11+
someState: someAction(state.someAction, action, props)
12+
};
13+
}

webpack.config.js

-39
This file was deleted.

0 commit comments

Comments
 (0)