-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 #1086
base: master
Are you sure you want to change the base?
add task solution #1086
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 improve your code
// #endregion | ||
// #region handlers |
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.
Remove all comments
// #endregion | |
// #region handlers |
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: filter === Filter.all, | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={() => setFilter(Filter.all)} | ||
> | ||
{Filter.all} | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={classNames('filter__link', { | ||
selected: filter === Filter.active, | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => setFilter(Filter.active)} | ||
> | ||
{Filter.active} | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className={classNames('filter__link', { | ||
selected: filter === Filter.completed, | ||
})} | ||
data-cy="FilterLinkCompleted" | ||
onClick={() => setFilter(Filter.completed)} | ||
> | ||
{Filter.completed} | ||
</a> |
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.
Use Object.values(Filter)
and render these options with map()
method
src/components/TodoList/TodoList.tsx
Outdated
<div | ||
key={id} | ||
data-cy="Todo" | ||
className={classNames('todo', { completed: isTodoChecked })} | ||
> | ||
<label className="todo__status-label"> | ||
<input | ||
data-cy="TodoStatus" | ||
type="checkbox" | ||
className="todo__status" | ||
onChange={() => toogleHandler(id)} | ||
checked={isTodoChecked} | ||
/> | ||
</label> | ||
|
||
{editableTodoById === id ? ( | ||
<form onSubmit={event => onSubmit(event, id)}> | ||
<input | ||
ref={todoInputRef} | ||
onBlur={event => onSubmit(event, id)} | ||
data-cy="TodoTitleField" | ||
type="text" | ||
className="todo__title-field" | ||
placeholder="Empty todo will be deleted" | ||
value={editableTitle} | ||
onChange={event => setEditableTitle(event.target.value)} | ||
/> | ||
</form> |
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
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! 👍
DEMO LINK