-
Notifications
You must be signed in to change notification settings - Fork 1
허수빈 week3 과제 #43
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
허수빈 week3 과제 #43
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,27 @@ import checkIcon from "../assets/check.svg"; | |
| type TodoCardProps = { | ||
| text: string; | ||
| done: boolean; | ||
| onDelete: () => void; | ||
| onToggle: () => void; | ||
| }; | ||
|
|
||
| export default function TodoCard({ text, done }: TodoCardProps) { | ||
| export default function TodoCard({ text, done, onDelete, onToggle }: TodoCardProps) { | ||
| return ( | ||
| <div className="todo-card"> | ||
| <div className={`todo-card__check ${done ? "todo-card__check--done" : ""}`}> | ||
| <div | ||
|
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. 완료/미완료처럼 체크 상태를 바꾸는 기능이라면, 지금처럼 |
||
| className={`todo-card__check ${done ? "todo-card__check--done" : ""}`} | ||
| onClick={onToggle} | ||
| > | ||
| {done && ( | ||
| <img src={checkIcon} alt="완료" className="todo-card__check-icon" /> | ||
| )} | ||
| </div> | ||
| <span className={`todo-card__text ${done ? "todo-card__text--done" : ""}`}> | ||
| {text} | ||
| </span> | ||
| <button className="delete-button" onClick={onDelete}> | ||
|
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. 이 삭제 버튼은 아이콘만 있어서 스크린리더 입장에서는 의미가 조금 모호할 수 있어요. aria-label 속성을 붙여두면 버튼의 의미가 더 분명해집니다. |
||
| 🗑️ | ||
| </button> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,59 @@ type Todo = { | |
|
|
||
| type TodoListProps = { | ||
| items: Todo[]; | ||
| inputValue: string; | ||
| onInputChange: (value: string) => void; | ||
| onAdd: () => void; | ||
| onDelete: (id: number) => void; | ||
| onToggle: (id: number) => void; | ||
| onFocus: () => void; | ||
| onBlur: () => void; | ||
| }; | ||
|
|
||
| export default function TodoList({ items }: TodoListProps) { | ||
| if (items.length === 0) { | ||
| return ( | ||
| <div className="todo-empty"> | ||
| <span className="todo-empty__icon">{"📋"}</span> | ||
| <p className="todo-empty__text">{"아직 할 일이 없어요"}</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default function TodoList({ | ||
| items, | ||
| inputValue, | ||
| onInputChange, | ||
| onAdd, | ||
| onDelete, | ||
| onToggle, | ||
| onFocus, | ||
| onBlur, | ||
| }: TodoListProps) { | ||
| return ( | ||
| <div className="todo-list"> | ||
|
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. 이전에도 말씀드렸던 부분인데, 리스트를 보여주는 영역이라면 |
||
| {items.map((item) => ( | ||
| <TodoCard key={item.id} text={item.text} done={item.done} /> | ||
| ))} | ||
| <div className="todo-input-card"> | ||
| <input | ||
| type="text" | ||
| className="todo-input" | ||
| placeholder="새로운 할 일" | ||
| value={inputValue} | ||
| onChange={(e) => onInputChange(e.target.value)} | ||
| onKeyDown={(e) => e.key === "Enter" && onAdd()} | ||
| onFocus={onFocus} | ||
| onBlur={onBlur} | ||
| /> | ||
| <button className="add-button" onClick={onAdd}> | ||
| 추가 | ||
| </button> | ||
| </div> | ||
|
|
||
| {items.length === 0 ? ( | ||
| <div className="todo-empty"> | ||
| <span className="todo-empty__icon">{"📋"}</span> | ||
| <p className="todo-empty__text">{"아직 할 일이 없어요"}</p> | ||
| </div> | ||
| ) : ( | ||
| items.map((item) => ( | ||
| <TodoCard | ||
| key={item.id} | ||
| text={item.text} | ||
| done={item.done} | ||
| onDelete={() => onDelete(item.id)} | ||
| onToggle={() => onToggle(item.id)} | ||
| /> | ||
| )) | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
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.
CSS에서 Pretendard를 사용하고 있는데 현재 프로젝트에는 이 폰트를 실제로 불러오는 코드가 보이지 않아요. 의도한 폰트를 쓰고 싶다면 import까지 같이 넣어두면 더 좋겠습니다.