Skip to content

Commit 7e147d6

Browse files
author
DEVfancybear
committed
bai 1
1 parent 638c714 commit 7e147d6

20 files changed

+58
-26
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

example_1/src/App.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { Component } from "react";
2+
import ItemTodo from "./components/ItemTodo";
3+
import "./App.css";
4+
5+
class App extends Component {
6+
constructor() {
7+
super();
8+
this.todoItems = [
9+
{ title: "Dắt gấu đi chơi", isComplete: true},
10+
{ title: "Đi shopping", isComplete: true},
11+
{ title: "Đi siêu thị"}
12+
];
13+
}
14+
render() {
15+
let a = this.todoItems.length;
16+
return (
17+
<>
18+
{a > 0 &&
19+
this.todoItems.map((item, index) => (
20+
<ItemTodo key={index} item={item} />
21+
))}
22+
{a === 0 && <div>Không có gì</div>}
23+
{/* dùng map để biến 1 arr gồm các obj phải thêm key */}
24+
</>
25+
);
26+
}
27+
}
28+
29+
export default App;
File renamed without changes.

example_1/src/components/ItemTodo.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.item_todo {
2+
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
3+
font-weight: 300;
4+
font-size: 24px;
5+
color: #4d4d4d;
6+
text-align: center;
7+
}
8+
.item_done {
9+
text-decoration: line-through;
10+
opacity: 0.3;
11+
}

example_1/src/components/ItemTodo.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { Component } from "react";
2+
import './ItemTodo.css';
3+
class ItemTodo extends Component {
4+
render() {
5+
const items = this.props.item;
6+
let className = 'item_todo';
7+
if(items.isComplete) {
8+
//thêm class css khi click
9+
className += ' item_done';
10+
}
11+
return (
12+
<div className={className}>
13+
<p>{items.title}</p>
14+
</div>
15+
);
16+
}
17+
}
18+
export default ItemTodo;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/App.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)