Skip to content

Commit b681bd5

Browse files
author
lewis617
committed
add TodoList demo
0 parents  commit b681bd5

30 files changed

+2212
-0
lines changed

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/myReact.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TodoList/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
prod/css
3+
prod/js

TodoList/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# TodoList by react & webpack
2+
3+
[Demo] http://lab.crazycoder.cc/todo
4+
5+
## Usage
6+
7+
First step: install the modules
8+
# npm install
9+
10+
Second step: install webpack webpack-server
11+
# npm install -g webpack webpack-dev-server
12+
13+
Third step: You can run a webpack-server and then visit http://localhost:8080
14+
# npm run dev
15+
16+
If you want to combile the js and css files
17+
# npm run prod
18+
19+
## License
20+
21+
MIT (http://www.opensource.org/licenses/mit-license.php)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
import ClassNames from 'classnames';
3+
4+
/**
5+
* '+' UIs
6+
*/
7+
class AddItem extends React.Component {
8+
9+
closePop() {
10+
this.props.hidePop();
11+
}
12+
13+
preventCls(event) {
14+
event.stopPropagation();
15+
}
16+
17+
addItem(e) {
18+
e.preventDefault();
19+
let name = React.findDOMNode(this.refs.name).value.trim(),
20+
desc = React.findDOMNode(this.refs.desc).value.trim();
21+
22+
if (!name) {
23+
alert('task name cannot be empty');
24+
React.findDOMNode(this.refs.name).focus();
25+
return;
26+
}
27+
28+
if (!desc) {
29+
alert('task description cannot be empty');
30+
React.findDOMNode(this.refs.desc).focus();
31+
return;
32+
}
33+
34+
React.findDOMNode(this.refs.name).value = '';
35+
React.findDOMNode(this.refs.desc).value = '';
36+
37+
this.props.addTask(name, desc);
38+
this.props.hidePop();
39+
}
40+
41+
render() {
42+
let classes = ClassNames({
43+
'addpop': true,
44+
'show': this.props.needShow
45+
});
46+
47+
return (
48+
<div className={classes} onClick={this.closePop.bind(this)}>
49+
<div className="add-input" onClick={this.preventCls.bind(this)}>
50+
<h3>Add Task</h3>
51+
<div className="form-group">
52+
<label>name</label>
53+
<input type="text" ref="name" />
54+
</div>
55+
<div className="form-group">
56+
<label>desc</label>
57+
<textarea ref="desc"></textarea>
58+
</div>
59+
<div className="form-group">
60+
<button onClick={this.addItem.bind(this)}>Submit</button>
61+
</div>
62+
<span className="fa fa-close pop-cls" onClick={this.closePop.bind(this)}></span>
63+
</div>
64+
</div>
65+
);
66+
}
67+
}
68+
69+
export default AddItem;

TodoList/app/components/item.jsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import {Link} from 'react-router';
3+
4+
class Item extends React.Component {
5+
render() {
6+
let task = this.props.task;
7+
if (task.state === 0) {
8+
return (
9+
<li>
10+
<p className="task-name">{task.name}<span>{task.created}</span></p>
11+
<p><i className="fa fa-clock-o unfinished"></i></p>
12+
<Link to={`/task/${task.id}`}></Link>
13+
</li>
14+
);
15+
} else {
16+
return (
17+
<li>
18+
<p className="task-name">{task.name}<span>{task.created}</span></p>
19+
<p><i className="fa fa-check-square-o finished"></i></p>
20+
<Link to={`/task/${task.id}`}></Link>
21+
</li>
22+
);
23+
}
24+
}
25+
}
26+
27+
export default Item;

0 commit comments

Comments
 (0)