Skip to content

Commit bcabc64

Browse files
macmac
authored andcommitted
bug
1 parent abc3c7f commit bcabc64

File tree

6 files changed

+85
-2
lines changed

6 files changed

+85
-2
lines changed

.DS_Store

6 KB
Binary file not shown.

conf/.DS_Store

6 KB
Binary file not shown.

conf/webpack/.DS_Store

6 KB
Binary file not shown.

src/containers/Home/Home.less

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@
2626
display: flex;
2727
flex-direction: column;
2828
align-items: center;
29+
.todoBody {
30+
padding: 50px;
31+
background-color: #66CCFF;
32+
font-family: sans-serif;
33+
}
34+
.todoListMain .todoHeader input{
35+
padding: 10px;
36+
font-size: 16px;
37+
border: 2px solid #FFF
38+
}
39+
.todoListMain .todoHeader button{
40+
padding: 10px;
41+
font-size: 16px;
42+
margin: 10px;
43+
background-color: #0066FF;
44+
color: #FFF;
45+
border: 2px solid #0066FF;
46+
}
47+
.todoListMain .todoHeader button:hover{
48+
background-color: #003399;
49+
border: 2px solid #003399;
50+
cursor: pointer;
51+
}
2952
}
3053
}
3154

src/containers/Home/components/Content.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
import React, { Component } from 'react';
2+
import TodoItems from './TodoItems.js';
23

34
export default class Content extends Component {
5+
constructor(props) {
6+
super(props);
7+
this.state = {
8+
text: "",
9+
item: []
10+
};
11+
this.handleChange = this.handleChange.bind(this);
12+
}
13+
handleChange(event) {
14+
console.log(event.target.value);
15+
this.setState({ text: event.target.value });
16+
}
17+
handleAdd() {
18+
const itemArray = this.state.items;
19+
itemArray.push(
20+
{
21+
text: this.state.text,
22+
}
23+
);
24+
this.setState({
25+
item: itemArray
26+
});
27+
this.setState({text: ""});
28+
console.log(this.state.items);
29+
}
430
render() {
531
return (
632
<div className="content">
7-
<h1>Hello, We are ReactMaker!</h1>
8-
<h2>This is Content Component!</h2>
33+
<div className="todoBody">
34+
<div className="todoListMain">
35+
<div className="todoHeader">
36+
<input
37+
type="text"
38+
value={this.state.text}
39+
onChange={this.handleChange}
40+
/>
41+
<button onClick={this.handleAdd}> add </button>
42+
<TodoItems entries={this.state.item}/>
43+
</div>
44+
</div>
45+
</div>
946
</div>
1047
);
1148
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
export default class TodoItems extends Component {
5+
static propTypes = {
6+
entries: PropTypes.array
7+
}
8+
render() {
9+
const todoEntries = this.props.entries;
10+
11+
function createTasks(item) {
12+
return <li key={item.key}>{item.text}</li>;
13+
}
14+
15+
const listItems = todoEntries.map(createTasks);
16+
17+
return (
18+
<ul className="thelist">
19+
{listItems}
20+
</ul>
21+
);
22+
}
23+
}

0 commit comments

Comments
 (0)