-
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
todo app #1053
base: master
Are you sure you want to change the base?
todo app #1053
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.
src/components/Footer.tsx
Outdated
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: isActive === IsActiveTab.All, | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={() => { | ||
setIsActiveTab(IsActiveTab.All); | ||
}} | ||
> | ||
All | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={classNames('filter__link', { | ||
selected: isActive === IsActiveTab.Active, | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => { | ||
setIsActiveTab(IsActiveTab.Active); | ||
}} | ||
> | ||
Active | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className={classNames('filter__link', { | ||
selected: isActive === IsActiveTab.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 Object.values(your enum)
and render these options with map()
method
src/components/Footer.tsx
Outdated
type="button" | ||
className="todoapp__clear-completed" | ||
data-cy="ClearCompletedButton" | ||
onClick={() => handleClearCompleted()} |
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.
onClick={() => handleClearCompleted()} | |
onClick={handleClearCompleted} |
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
{!isFocused && ( | ||
<> | ||
<span | ||
data-cy="TodoTitle" | ||
className="todo__title" | ||
onDoubleClick={() => setIsFocused(true)} | ||
> | ||
{title} | ||
</span> | ||
|
||
<button | ||
type="button" | ||
className="todo__remove" | ||
data-cy="TodoDelete" | ||
onClick={() => handleClick(Actions.delete)} | ||
> | ||
× | ||
</button> | ||
</> | ||
)} | ||
|
||
{isFocused && ( |
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.
you can simplify it using the ternary operator
|
||
export const App: React.FC = () => { | ||
const { todos } = useContext(TodosContext); | ||
const [isActive, setIsActiveTab] = useState(IsActiveTab.All); |
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.
const [isActive, setIsActiveTab] = useState(IsActiveTab.All); | |
const [activeTab, setActiveTab] = useState(IsActiveTab.All); |
DEMO LINK