-
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 #1065
base: master
Are you sure you want to change the base?
add task solution #1065
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.
Great work! 🔥
src/components/Footer.tsx
Outdated
return ( | ||
<footer className="todoapp__footer" data-cy="Footer"> | ||
<span className="todo-count" data-cy="TodosCounter"> | ||
{`${activeTodoCount} ${activeTodoCount === 1 ? 'item' : 'items'} left`} |
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 helper variable and use it here
src/components/Footer.tsx
Outdated
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: filter === TodoFilter.All, | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={() => setFilter(TodoFilter.All)} | ||
> | ||
All | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={classNames('filter__link', { | ||
selected: filter === TodoFilter.Active, | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => setFilter(TodoFilter.Active)} | ||
> | ||
Active | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className={classNames('filter__link', { | ||
selected: filter === TodoFilter.Completed, | ||
})} | ||
data-cy="FilterLinkCompleted" | ||
onClick={() => setFilter(TodoFilter.Completed)} | ||
> | ||
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(TodoFilter)
and render these options with map()
method
src/components/Header.tsx
Outdated
{todos.length > 0 && ( | ||
<button | ||
type="button" | ||
className={`todoapp__toggle-all ${todos.every(todo => todo.completed) ? 'active' : ''}`} |
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 the classnames library for add classes with condition, fix it everywere
src/components/TodoApp.tsx
Outdated
<div className="todoapp__content"> | ||
<Header /> | ||
|
||
{todos.length > 0 && ( |
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.
{todos.length > 0 && ( | |
{!!todos.length && ( |
src/components/TodoItem.tsx
Outdated
return ( | ||
<div | ||
data-cy="Todo" | ||
className={classNames('todo', { completed: todo.completed })} |
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 destructuring for todo
DEMO LINK