Skip to content

Commit 51447d1

Browse files
committed
feat:week2
1 parent 7f52ec0 commit 51447d1

File tree

8 files changed

+70
-10
lines changed

8 files changed

+70
-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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import TodoCard from "./TodoCard";
22

33
export default function TodoList() {
4+
5+
const todos = [
6+
{ id: 1, content: "리액트 공식문서 읽기" },
7+
{ id: 2, content: "알고리즘 문제 풀기" },
8+
{ id: 3, content: "운동 30분 하기" },
9+
{ id: 4, content: "프로젝트 회의 준비" },
10+
];
11+
412
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="프로젝트 회의 준비" />
13+
<ul className="flex flex-col items-start gap-4 self-stretch">
14+
{todos.map((todo) => (
15+
<TodoCard
16+
key={todo.id}
17+
content={todo.content}
18+
/>
19+
))}
1020
</ul>
1121
)
1222
}

0 commit comments

Comments
 (0)