-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c867b63
commit a93f0a4
Showing
11 changed files
with
276 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
type TodoFooterProps = {}; | ||
|
||
export const TodoFooter: React.FC<TodoFooterProps> = () => { | ||
return ( | ||
<footer className="todoapp__footer" data-cy="Footer"> | ||
<span className="todo-count" data-cy="TodosCounter"> | ||
3 items left | ||
</span> | ||
|
||
{/* Active link should have the 'selected' class */} | ||
<nav className="filter" data-cy="Filter"> | ||
<a href="#/" className="filter__link selected" data-cy="FilterLinkAll"> | ||
All | ||
</a> | ||
|
||
<a href="#/active" className="filter__link" data-cy="FilterLinkActive"> | ||
Active | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className="filter__link" | ||
data-cy="FilterLinkCompleted" | ||
> | ||
Completed | ||
</a> | ||
</nav> | ||
|
||
{/* this button should be disabled if there are no completed todos */} | ||
<button | ||
type="button" | ||
className="todoapp__clear-completed" | ||
data-cy="ClearCompletedButton" | ||
> | ||
Clear completed | ||
</button> | ||
</footer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useCallback, useContext } from 'react'; | ||
import { TodoContext } from '../context/TodoContext'; | ||
import { Todo } from '../type'; | ||
|
||
type TodoHeaderProps = {}; | ||
|
||
export const TodoHeader: React.FC<TodoHeaderProps> = () => { | ||
const { todos, setTodos } = useContext(TodoContext); | ||
|
||
console.log(todos) | ||
|
||
return ( | ||
<header className="todoapp__header"> | ||
{/* this button should have `active` class only if all todos are completed */} | ||
<button | ||
type="button" | ||
className="todoapp__toggle-all active" | ||
data-cy="ToggleAllButton" | ||
/> | ||
|
||
{/* Add a todo on form submit */} | ||
<form> | ||
<input | ||
data-cy="NewTodoField" | ||
type="text" | ||
className="todoapp__new-todo" | ||
placeholder="What needs to be done?" | ||
/> | ||
</form> | ||
</header> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
type TodoItemProps = {}; | ||
|
||
export const TodoItem: React.FC<TodoItemProps> = () => { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
|
||
type TodoListProps = {}; | ||
|
||
export const TodoList: React.FC<TodoListProps> = () => { | ||
return ( | ||
<section className="todoapp__main" data-cy="TodoList"> | ||
{/* This is a completed todo */} | ||
<div data-cy="Todo" className="todo completed"> | ||
<label className="todo__status-label"> | ||
<input | ||
data-cy="TodoStatus" | ||
type="checkbox" | ||
className="todo__status" | ||
checked | ||
/> | ||
</label> | ||
|
||
<span data-cy="TodoTitle" className="todo__title"> | ||
Completed Todo | ||
</span> | ||
|
||
{/* Remove button appears only on hover */} | ||
<button type="button" className="todo__remove" data-cy="TodoDelete"> | ||
× | ||
</button> | ||
</div> | ||
|
||
{/* This todo is an active todo */} | ||
<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"> | ||
Not Completed Todo | ||
</span> | ||
|
||
<button type="button" className="todo__remove" data-cy="TodoDelete"> | ||
× | ||
</button> | ||
</div> | ||
|
||
{/* This todo is being edited */} | ||
<div data-cy="Todo" className="todo"> | ||
<label className="todo__status-label"> | ||
<input | ||
data-cy="TodoStatus" | ||
type="checkbox" | ||
className="todo__status" | ||
/> | ||
</label> | ||
|
||
{/* This form is shown instead of the title and remove button */} | ||
<form> | ||
<input | ||
data-cy="TodoTitleField" | ||
type="text" | ||
className="todo__title-field" | ||
placeholder="Empty todo will be deleted" | ||
value="Todo is being edited now" | ||
/> | ||
</form> | ||
</div> | ||
|
||
{/* This todo is in loadind state */} | ||
<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"> | ||
Todo is being saved now | ||
</span> | ||
|
||
<button type="button" className="todo__remove" data-cy="TodoDelete"> | ||
× | ||
</button> | ||
</div> | ||
</section> | ||
); | ||
}; |
Oops, something went wrong.