Skip to content
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

Открывается и закрывается (часть 2) #9

Merged
merged 3 commits into from
Jan 19, 2025

Conversation

harl-i
Copy link
Contributor

@harl-i harl-i commented Jan 16, 2025

@keksobot keksobot changed the title Добавляет решение задания "Открывается и закрывается (часть 2)" Открывается и закрывается (часть 2) Jan 16, 2025
currentCommentsLoaded++;
updateCommentCounters();
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Удали функцию и применяй вместо нее одну строку с classList.toggle

Подробнее можешь почитать в статье https://gomakethings.com/the-mysterious-second-argument-on-the-vanilla-js-classlist.toggle-method/

socialCommentsElement.appendChild(newCommentElement);
}

function updateCommentCounters() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Удали функцию и вынеси две строчки внутрь addCommentAndUpdateCounter

updateLoadCommentsButtonVisibility();
}

function addComment(comment) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

function addComment({avatar, name, commentsList}) {

const currentCommentsCountElement = bigPictureElement.querySelector('.social__comment-shown-count');
const totalCommentsCountElement = bigPictureElement.querySelector('.social__comment-total-count');
const loadCommentsButtonElement = bigPictureElement.querySelector('.social__comments-loader');
const loadingStep = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Оформи как константу плиз

const totalCommentsCountElement = bigPictureElement.querySelector('.social__comment-total-count');
const loadCommentsButtonElement = bigPictureElement.querySelector('.social__comments-loader');
const loadingStep = 5;
let commentsArray = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

У массива не let, а const

loadCommentsButtonElement.classList.toggle('hidden', currentCommentsLoaded >= totalComments);
}

function addComment({avatar, name, commentsList}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

addComment можно вообще вынести в отдельный файл и обозвать например renderComment

@keksobot keksobot merged commit 1802da2 into htmlacademy-javascript:master Jan 19, 2025
1 check passed
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