Skip to content

Commit bfe18ee

Browse files
committed
copy todo_react_motion to todo_with_test
1 parent 2d80999 commit bfe18ee

25 files changed

+1863
-0
lines changed

chapter-12/todo_with_test/README.md

Lines changed: 1244 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "todo",
3+
"version": "0.1.0",
4+
"private": true,
5+
"devDependencies": {
6+
"react-scripts": "0.8.4",
7+
"redux-immutable-state-invariant": "^1.2.4"
8+
},
9+
"dependencies": {
10+
"react": "^15.4.1",
11+
"react-addons-perf": "^15.4.1",
12+
"react-dom": "^15.4.1",
13+
"react-motion": "^0.4.7",
14+
"react-redux": "^5.0.1",
15+
"redux": "^3.6.0",
16+
"reselect": "^2.5.4"
17+
},
18+
"scripts": {
19+
"start": "react-scripts start",
20+
"build": "react-scripts build",
21+
"test": "react-scripts test --env=jsdom",
22+
"eject": "react-scripts eject"
23+
}
24+
}
24.3 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
7+
<!--
8+
Notice the use of %PUBLIC_URL% in the tag above.
9+
It will be replaced with the URL of the `public` folder during the build.
10+
Only files inside the `public` folder can be referenced from the HTML.
11+
12+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
13+
work correctly both with client-side routing and a non-root public URL.
14+
Learn how to configure a non-root public URL by running `npm run build`.
15+
-->
16+
<title>React App</title>
17+
</head>
18+
<body>
19+
<div id="root"></div>
20+
<!--
21+
This HTML file is a template.
22+
If you open it directly in the browser, you will see an empty page.
23+
24+
You can add webfonts, meta tags, or analytics to this file.
25+
The build step will place the bundled scripts into the <body> tag.
26+
27+
To begin the development, run `npm start`.
28+
To create a production bundle, use `npm run build`.
29+
-->
30+
</body>
31+
</html>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
2+
3+
import {reducer as todoReducer} from './todos';
4+
import {reducer as filterReducer} from './filter';
5+
6+
import Perf from 'react-addons-perf'
7+
8+
const win = window;
9+
win.Perf = Perf
10+
11+
const reducer = combineReducers({
12+
todos: todoReducer,
13+
filter: filterReducer
14+
});
15+
16+
const middlewares = [];
17+
if (process.env.NODE_ENV !== 'production') {
18+
middlewares.push(require('redux-immutable-state-invariant')());
19+
}
20+
21+
const storeEnhancers = compose(
22+
applyMiddleware(...middlewares),
23+
(win && win.devToolsExtension) ? win.devToolsExtension() : (f) => f,
24+
);
25+
26+
const initialState = {
27+
todos: [
28+
{
29+
id: 0,
30+
text: 'First',
31+
completed: true
32+
},
33+
{
34+
id: 1,
35+
text: 'Second',
36+
completed: false
37+
},
38+
{
39+
id: 2,
40+
text: 'Third',
41+
completed: true
42+
}
43+
]
44+
45+
}
46+
export default createStore(reducer, initialState, storeEnhancers);
47+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import {view as Todos} from './todos/';
3+
import {view as Filter} from './filter/';
4+
5+
function TodoApp() {
6+
return (
7+
<div>
8+
<Todos />
9+
<Filter />
10+
</div>
11+
);
12+
}
13+
14+
export default TodoApp;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const FilterTypes = {
2+
ALL: '全部',
3+
COMPLETED: '已完成',
4+
UNCOMPPLETED: '未完成'
5+
}
6+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SET_FILTER = 'FILTER/SET';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {SET_FILTER} from './actionTypes.js';
2+
3+
export const setFilter = filterType => ({
4+
type: SET_FILTER,
5+
filter: filterType
6+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as actions from './actions.js';
2+
import reducer from './reducer.js';
3+
import view from './views/filters.js';
4+
5+
export {actions, reducer, view};

0 commit comments

Comments
 (0)