Skip to content

Commit 323226d

Browse files
committed
Firebase - Section 10
1 parent c9cf6c9 commit 323226d

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

todos/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
.loaded {
99
opacity: 1;
1010
}
11+
.input-group {
12+
margin-bottom: 15px;
13+
}
1114
</style>
1215
</head>
1316
<body>

todos/src/app.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var App = React.createClass({
2525
To-Do List
2626
</h2>
2727
<Header itemsStore={this.firebaseRefs.items} />
28+
<hr />
2829
<div className={"content " + (this.state.loaded ? 'loaded' : '')}>
2930
<List items={this.state.items} />
3031
</div>

todos/src/list-item.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var React = require('react');
2+
3+
module.exports = React.createClass({
4+
getInitialState: function() {
5+
return {
6+
text: this.props.item.text
7+
}
8+
},
9+
render: function() {
10+
return <div className="input-group">
11+
<span className="input-group-addon">
12+
<input type="checkbox" />
13+
</span>
14+
<input type="text"
15+
className="form-control"
16+
value={this.state.text}
17+
/>
18+
<span className="input-group-btn">
19+
<button className="btn btn-default">
20+
Delete
21+
</button>
22+
</span>
23+
</div>
24+
}
25+
});

todos/src/list.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
var React = require('react');
2+
var ListItem = require('./list-item');
23

34
module.exports = React.createClass({
45
render: function() {
5-
return <ul>
6+
return <div>
67
{this.renderList()}
7-
</ul>
8+
</div>
89
},
910
renderList: function() {
1011
if(this.props.items && Object.keys(this.props.items).length === 0) {
@@ -15,10 +16,15 @@ module.exports = React.createClass({
1516
var children = [];
1617

1718
for(var key in this.props.items) {
19+
var item = this.props.items[key];
20+
item.key = key;
21+
1822
children.push(
19-
<li>
20-
{this.props.items[key].text}
21-
</li>
23+
<ListItem
24+
item={item}
25+
key={key}
26+
>
27+
</ListItem>
2228
)
2329
}
2430

0 commit comments

Comments
 (0)