-
Notifications
You must be signed in to change notification settings - Fork 1
박다인 week2 #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
박다인 week2 #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,39 @@ | ||
| import { useState } from "react"; | ||
| import checkIcon from "../assets/Check.svg"; | ||
|
|
||
| interface TodoCardProps { | ||
| content: string; | ||
| checked?: boolean; | ||
| } | ||
|
|
||
| export default function TodoCard({ content }: TodoCardProps) { | ||
| export default function TodoCard({ content, checked = false }: TodoCardProps) { | ||
| const [isChecked, setIsChecked] = useState(checked) | ||
|
|
||
| const toggleCheck = () => { | ||
| setIsChecked(!isChecked); | ||
| }; | ||
|
Comment on lines
+10
to
+14
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이번주 읽을 거리에서 다룬 내용은 아니긴 한데, 이전 상태를 기준으로 토글하는 업데이트라면
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 좋은 정보 감사합니다~! 다음에 반영해보도록 하겠습니다! |
||
|
|
||
| return ( | ||
| <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)]"> | ||
| <p className="text-body leading-[21px]">{content}</p> | ||
| <li | ||
| onClick={toggleCheck} | ||
| 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)]" | ||
| > | ||
| <div className={`w-6 h-6 flex items-center justify-center border-[2px] rounded-full transition-colors ${ | ||
| isChecked | ||
| ? 'bg-primary/40 border-primary/0' | ||
| : 'bg-white border-border' | ||
| }`}> | ||
| {isChecked && ( | ||
| <img src={checkIcon} alt="done" className="w-[14px] h-[10px]" /> | ||
| )} | ||
|
|
||
| </div> | ||
| <p className={`text-body leading-[21px] transition-all ${ | ||
| isChecked ? 'line-through text-gray-400 opacity-60' : 'text-gray-900' | ||
| }`} | ||
| > | ||
| {content} | ||
| </p> | ||
| </li> | ||
|
Comment on lines
+17
to
37
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todolist의 완료 토글은 의미상 |
||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export default function TodoEmpty() { | ||
| return ( | ||
| <div className="flex flex-col w-[640px] pt-[64px] h-[233px] gap-3 justify-start items-center bg-white rounded-[12px]"> | ||
| <p className="text-[48px] leading-[72px]">📋</p> | ||
| <p className="text-gray-400 text-body leading-[21px]"> | ||
| 아직 할 일이 없어요 | ||
| </p> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,27 @@ | ||
| import TodoCard from "./TodoCard"; | ||
| import TodoEmpty from "./TodoEmpty"; | ||
|
|
||
| export default function TodoList() { | ||
|
|
||
| const todos = [ | ||
| { id: 1, content: "리액트 공식문서 읽기" }, | ||
| { id: 2, content: "알고리즘 문제 풀기" }, | ||
| { id: 3, content: "운동 30분 하기" }, | ||
| { id: 4, content: "프로젝트 회의 준비" }, | ||
| ]; | ||
|
|
||
| if (todos.length === 0) { | ||
| return <TodoEmpty />; | ||
| } | ||
|
|
||
| return ( | ||
| <ul className="flex flex-col items-start gap-[16px] self-stretch"> | ||
| <TodoCard content="리액트 공식문서 읽기" /> | ||
| <TodoCard content="알고리즘 문제 풀기" /> | ||
| <TodoCard content="운동 30분 하기" /> | ||
| <TodoCard content="프로젝트 회의 준비" /> | ||
| <ul className="flex flex-col items-start gap-4 self-stretch"> | ||
| {todos.map((todo) => ( | ||
| <TodoCard | ||
| key={todo.id} | ||
| content={todo.content} | ||
| /> | ||
| ))} | ||
|
Comment on lines
+6
to
+24
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이번 주 과제는 완료 여부를 |
||
| </ul> | ||
| ) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다음주에는 이 부분을 리스트의 길이에 따라 분기처리 해주시면 좋을것같아요