-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
dom-js #83
dom-js #83
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 job! See some comments below.
changing a few variables, replaced map with for, created main function showSeasonsGot.
If I understood the comments correctly, I corrected your remarks. Please, check the changes. |
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.
Don't forget to update your local repository. Your demo not last version.
Please, check the changes. |
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.
Your variable data
does not change its content, so you can not pass it constantly as an argument to functions.
In your main function showSeasonsGot
, leave only function calls and event handlers.
item.classList.remove(activeClassSelector); | ||
}); | ||
btns[i].classList.add(activeClassSelector); | ||
}; |
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.
I recommend to create a variable styleList
which have properties with className. Because if in css some class was changed in code we must found and edit all rows with this className.
const styleList = {
activeItemMenu: 'side-menu__btn_active',
...........................
}
const toggleActiveClass = (activeBtn = 0) => {
const btnList= document.querySelectorAll('.side-menu__btn');
btnList.forEach(btn=> {
if(btn.dataset.id !== activeBtn) {
btn.classList.remove(activeClassSelector);
} else {
btn.classList.add(activeClassSelector);
}
});
};
I fixed all. Please, check the changes. |
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.
Three changes and I approve your work)
}; | ||
|
||
const renderContent = (i = 0, arr = data) => { | ||
const {title, descr, img} = arr[i]; |
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 Array.filter()
to select data.
item.classList.remove(styleList.itemMenu); | ||
}); | ||
btns[i].classList.add(styleList.itemMenu); | ||
}; |
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.
If you want to get something from an array you rather use the array methods. You can try the example I offered you earlier or do something different.
|
||
const toggleBurger = () => { | ||
btnBurger.addEventListener('click', () => { | ||
body.classList.toggle(styleList.lock); |
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.
Separate this function and event listener.
const toggleBurger = () => { .... }
btnBurger.addEventListener('click', toggleBurger);
added prop id in obj data, changes function: renderBtns, renderContent, toggleActiveClass, toggleBurger
I changes all). Please, check the changes and approve my work) |
DOM
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.