modularizated scripts

This commit is contained in:
2021-11-18 14:40:40 -03:00
parent ea76370282
commit b7e95b8d96
9 changed files with 377 additions and 335 deletions

39
scripts/navbarLogica.js Normal file
View File

@@ -0,0 +1,39 @@
const navbarLogica = async (activeCategory, globalProductos, enviarProductoAlCheckout, checkout, totalLogica, stylesLogica, definirProductos) => {
const childrenNavbar = document.querySelectorAll('.exposicion-de-productos nav ul li.button')
childrenNavbar.forEach(children => {
children.addEventListener('click', () => {
globalProductos = []
activeCategory = children.innerText
makeThisCategoryActive()
definirProductos(globalProductos, activeCategory, enviarProductoAlCheckout, checkout, totalLogica, stylesLogica)
})
})
const makeThisCategoryActive = () => {
childrenNavbar.forEach(children => {
if (!children.children[0]) {
if (activeCategory === children.innerText) {
children.classList.add('active')
}
else if (children.classList.contains('active')) {
children.classList.remove('active')
}
}
})
}
makeThisCategoryActive()
}
export default navbarLogica