-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTodoCard.tsx
More file actions
43 lines (39 loc) · 861 Bytes
/
TodoCard.tsx
File metadata and controls
43 lines (39 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import checkedIcon from "../assets/icons/checkedIcon.svg";
interface TodoCardProps {
id: number;
text: string;
completed: boolean;
onDelete: (id: number) => void;
}
export default function TodoCard({
id,
text,
completed,
onDelete,
}: TodoCardProps) {
function handleClick() {
onDelete(id);
}
if (completed) {
return (
<li className={`item checked`}>
<div className="CheckedBox">
<img src={checkedIcon} alt="checked" />
</div>
<div className="text">
<del>{text}</del>
</div>
<button className="delBtn">🗑</button>
</li>
);
}
return (
<li className="item">
<div className="UncheckedBox"></div>
<div className="text">{text}</div>
<button className="delBtn" onClick={handleClick}>
🗑
</button>
</li>
);
}