-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add task solution #1514
base: master
Are you sure you want to change the base?
add task solution #1514
Conversation
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.
Good job 👍
Let's make your code better
src/components/TodoList.tsx
Outdated
return ( | ||
<div | ||
data-cy="Todo" | ||
className={classNames('todo', { completed: completed })} | ||
key={id} | ||
> | ||
<label className="todo__status-label"> | ||
<input | ||
data-cy="TodoStatus" | ||
type="checkbox" | ||
className="todo__status" | ||
checked={completed} | ||
onClick={() => { | ||
changeTodo({ ...todo, completed: !completed }); | ||
setUpdatingAndDeletingCompletedTodos([todo]); | ||
}} | ||
/> | ||
</label> | ||
|
||
{editingTitle === id ? ( | ||
<FormEditingTitle | ||
todo={todo} | ||
titleEdit={titleEdit} | ||
setTitleEdit={setTitleEdit} | ||
handleChangeSubmit={handleChangeSubmit} | ||
setEditingTitle={setEditingTitle} | ||
/> | ||
) : ( |
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.
Move this logic to the TodoItem
component
src/components/TodoList.tsx
Outdated
<div data-cy="Todo" className="todo"> | ||
<label className="todo__status-label"> | ||
<input | ||
data-cy="TodoStatus" | ||
type="checkbox" | ||
className="todo__status" | ||
/> | ||
</label> | ||
|
||
<span data-cy="TodoTitle" className="todo__title"> | ||
{tempTodo} | ||
</span> | ||
|
||
{/* Remove button appears only on hover */} | ||
<button type="button" className="todo__remove" data-cy="TodoDelete"> | ||
x | ||
</button> | ||
|
||
{/* overlay will cover the todo while it is being deleted or updated */} | ||
<div data-cy="TodoLoader" className="modal overlay is-active"> | ||
<div | ||
className={classNames( | ||
'modal-background', | ||
'has-background-white-ter', | ||
)} | ||
/> | ||
<div className="loader" /> | ||
</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.
Move these logic to the separate component
); | ||
})} | ||
|
||
{tempTodo && <TempTodoItem tempTodo={tempTodo} />} |
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.
u can use TodoItem component here
https://VictorKomara.github.io/react_todo-app-with-api/