Skip to content

Commit

Permalink
Firebase - Section 10
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jun 5, 2015
1 parent c9cf6c9 commit 323226d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
3 changes: 3 additions & 0 deletions todos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
.loaded {
opacity: 1;
}
.input-group {
margin-bottom: 15px;
}
</style>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions todos/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var App = React.createClass({
To-Do List
</h2>
<Header itemsStore={this.firebaseRefs.items} />
<hr />
<div className={"content " + (this.state.loaded ? 'loaded' : '')}>
<List items={this.state.items} />
</div>
Expand Down
25 changes: 25 additions & 0 deletions todos/src/list-item.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var React = require('react');

module.exports = React.createClass({
getInitialState: function() {
return {
text: this.props.item.text
}
},
render: function() {
return <div className="input-group">
<span className="input-group-addon">
<input type="checkbox" />
</span>
<input type="text"
className="form-control"
value={this.state.text}
/>
<span className="input-group-btn">
<button className="btn btn-default">
Delete
</button>
</span>
</div>
}
});
16 changes: 11 additions & 5 deletions todos/src/list.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var React = require('react');
var ListItem = require('./list-item');

module.exports = React.createClass({
render: function() {
return <ul>
return <div>
{this.renderList()}
</ul>
</div>
},
renderList: function() {
if(this.props.items && Object.keys(this.props.items).length === 0) {
Expand All @@ -15,10 +16,15 @@ module.exports = React.createClass({
var children = [];

for(var key in this.props.items) {
var item = this.props.items[key];
item.key = key;

children.push(
<li>
{this.props.items[key].text}
</li>
<ListItem
item={item}
key={key}
>
</ListItem>
)
}

Expand Down

0 comments on commit 323226d

Please sign in to comment.