Skip to content

Commit 6030aa9

Browse files
authored
Merge pull request #26 from IT-Cotato/canofmato-week2
박다인 week2
2 parents 7f52ec0 + 5ff33cd commit 6030aa9

File tree

8 files changed

+75
-10
lines changed

8 files changed

+75
-10
lines changed

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import TodoEmpty from "./component/TodoEmpty"
12
import TodoHeader from "./component/TodoHeader"
23
import TodoList from "./component/TodoList"
34

@@ -7,6 +8,9 @@ function App() {
78
<div className="flex flex-col w-[640px] mt-[80px] ml-[445px] mr-[464px] gap-[22px]">
89
<TodoHeader />
910
<TodoList />
11+
12+
<TodoHeader />
13+
<TodoEmpty />
1014
</div>
1115
</>
1216

src/assets/Check.svg

Lines changed: 10 additions & 0 deletions
Loading

src/assets/hero.png

-43.9 KB
Binary file not shown.

src/assets/react.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/assets/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/component/TodoCard.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1+
import { useState } from "react";
2+
import checkIcon from "../assets/Check.svg";
3+
14
interface TodoCardProps {
25
content: string;
6+
checked?: boolean;
37
}
48

5-
export default function TodoCard({ content }: TodoCardProps) {
9+
export default function TodoCard({ content, checked = false }: TodoCardProps) {
10+
const [isChecked, setIsChecked] = useState(checked)
11+
12+
const toggleCheck = () => {
13+
setIsChecked(!isChecked);
14+
};
15+
616
return (
7-
<li className="flex p-[16px] gap-[10px] items-start self-stretch bg-card rounded-[12px] shadow-[0_1px_3px_0_rgba(0,0,0,0.10)]">
8-
<p className="text-body leading-[21px]">{content}</p>
17+
<li
18+
onClick={toggleCheck}
19+
className="flex p-[16px] gap-[10px] items-center self-stretch bg-card rounded-[12px] shadow-[0_1px_3px_0_rgba(0,0,0,0.10)]"
20+
>
21+
<div className={`w-6 h-6 flex items-center justify-center border-[2px] rounded-full transition-colors ${
22+
isChecked
23+
? 'bg-primary/40 border-primary/0'
24+
: 'bg-white border-border'
25+
}`}>
26+
{isChecked && (
27+
<img src={checkIcon} alt="done" className="w-[14px] h-[10px]" />
28+
)}
29+
30+
</div>
31+
<p className={`text-body leading-[21px] transition-all ${
32+
isChecked ? 'line-through text-gray-400 opacity-60' : 'text-gray-900'
33+
}`}
34+
>
35+
{content}
36+
</p>
937
</li>
1038
)
1139
}

src/component/TodoEmpty.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function TodoEmpty() {
2+
return (
3+
<div className="flex flex-col w-[640px] pt-[64px] h-[233px] gap-3 justify-start items-center bg-white rounded-[12px]">
4+
<p className="text-[48px] leading-[72px]">📋</p>
5+
<p className="text-gray-400 text-body leading-[21px]">
6+
아직 할 일이 없어요
7+
</p>
8+
</div>
9+
);
10+
}

src/component/TodoList.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import TodoCard from "./TodoCard";
2+
import TodoEmpty from "./TodoEmpty";
23

34
export default function TodoList() {
5+
6+
const todos = [
7+
{ id: 1, content: "리액트 공식문서 읽기" },
8+
{ id: 2, content: "알고리즘 문제 풀기" },
9+
{ id: 3, content: "운동 30분 하기" },
10+
{ id: 4, content: "프로젝트 회의 준비" },
11+
];
12+
13+
if (todos.length === 0) {
14+
return <TodoEmpty />;
15+
}
16+
417
return (
5-
<ul className="flex flex-col items-start gap-[16px] self-stretch">
6-
<TodoCard content="리액트 공식문서 읽기" />
7-
<TodoCard content="알고리즘 문제 풀기" />
8-
<TodoCard content="운동 30분 하기" />
9-
<TodoCard content="프로젝트 회의 준비" />
18+
<ul className="flex flex-col items-start gap-4 self-stretch">
19+
{todos.map((todo) => (
20+
<TodoCard
21+
key={todo.id}
22+
content={todo.content}
23+
/>
24+
))}
1025
</ul>
1126
)
1227
}

0 commit comments

Comments
 (0)