Skip to content

Conversation

@AlenaLoik
Copy link
Owner

@AlenaLoik AlenaLoik commented May 7, 2020

DEMO LINK
solution without

  1. (*) Save state of the APP to local storage (Required theory)
  2. (*) Implement saving an edited todo when you click outside of the input

@vkryvytskyi
Copy link

image

В таком состоянии кнопка должна быть активной

image

А в таком нет ![adkjsmhfbsd](https://user-images.githubusercontent.com/38065883/81319425-5133cf00-9098-11ea-8cbf-0eb099a2747a.gif) Когда я так убираю/добавляю одну туду, кнопка markAll должна менять свое состояние

@vkryvytskyi
Copy link

Самое время браться за дополнительные задания)

@vpolets
Copy link

vpolets commented May 12, 2020

image
виділив всі, зняв одну галочку, а "all checked" продовжує горіти

@vpolets
Copy link

vpolets commented May 12, 2020

image
Виділив всі вручну, але "all checked" не горить

@vpolets
Copy link

vpolets commented May 12, 2020

image
Пробілу не вистачає

</div>
<input type="text" className="edit" />
</li>
handleRemuve = (id) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handleRemuve = (id) => {
handleRemove = (id) => {

</div>
<input type="text" className="edit" />
</li>
handleRemuveCompleted = () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handleRemuveCompleted = () => {
handleRemoveCompleted = () => {

Comment on lines +76 to +89
switch (this.state.showParam) {
case 'active':
todoView = [...this.state.todos].filter(todo => (
!todo.completed
));
break;
case 'completed':
todoView = [...this.state.todos].filter(todo => (
todo.completed
));
break;
default:
todoView = [...this.state.todos];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не роби це в рендері, винеси це в функцію getTodos(status)

<h1>todos</h1>
<NewTodo addTodo={this.addTodo} />
</header>
{(this.state.todos.length)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

деструктуровуй стейт

Comment on lines +116 to +136
<footer className="footer">
<span className="todo-count">
{itemLeft}
item left
</span>
<TodosFilter updateTodosToShow={this.updateTodosToShow} />
{
(this.state.todos.filter(todo => (
todo.completed)).length)
? (
<button
onClick={this.handleRemuveCompleted}
type="button"
className="clear-completed"
>
Clear completed
</button>
)
: ('')
}
</footer>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

це окремий компонент, Footer

class NewTodo extends Component {
state = {
content: '',
id: 1,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чому 1? а якщо одразу є якісь завдання?

e.preventDefault();

if (this.state.content) {
this.props.addTodo(this.state);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не передавай весь стан, передавай готове todo наверх. addTodo має приймати todo, а не весь стан

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Але якщо я хочу щоб даний компонент відповідав повністю за створення нової todo, а зверху addTodo лише додавав її в список зі всіма готовими параметрами. Чи це погана практика???

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Якщо в стейті потрібно зберігати як можна менше, тоді я перенесу id & complited у функцію що передає todo. Так добре добре буде?


this.setState(prevState => ({
content: '',
id: prevState.id + 1,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

окей, тут добре)

Comment on lines +8 to +27
<div className={todo.completed ? 'completed' : 'view'}>
<input
checked={todo.completed}
onClick={() => {
toggleComplete(todo.id);
}}
type="checkbox"
className="toggle"
id={`todo-${todo.id}`}
/>
<label htmlFor={`todo-${todo.id}`}>{todo.content}</label>
<button
onClick={() => {
remuve(todo.id);
}}
type="button"
className="destroy"
/>
</div>
<input type="text" className="edit" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo компонент, розбивай логіку на дрібніші компоненти

Comment on lines +7 to +30
<li>
<a
href="#/"
onClick={() => (updateTodosToShow('all'))}
>
All
</a>
</li>
<li>
<a
href="#/active"
onClick={() => (updateTodosToShow('active'))}
>
Active
</a>
</li>
<li>
<a
href="#/completed"
onClick={() => (updateTodosToShow('completed'))}
>
Completed
</a>
</li>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все чим ці три фільтри відрізняються це один рядок. Ти можеш створити комонент Filter який буде приймати цей рядок і підставляти в потрібне місце, а потім через map зробити собі 3 фільтри. Коду менше буде

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants