Skip to content

Commit

Permalink
mobile menu ready
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinaHranovska committed Feb 14, 2024
1 parent f0f5f5c commit a7166fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
width: 100%;
}

.backdrop-button.active-link {
background: var(--white-color);
color: var(--text-dark);
}

.header-logo {
font-weight: 700;
font-size: 16px;
Expand Down
23 changes: 20 additions & 3 deletions src/js/burger-menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const favoritesButton = document.querySelector('.link-favorites');
const homeButton = document.querySelector('.link-home');

(() => {
const refs = {
openModalBtn: document.querySelector('.burger-menu-open'),
Expand All @@ -14,7 +11,23 @@ const homeButton = document.querySelector('.link-home');
refs.openModalBtn.addEventListener('click', function () {
toggleModal();
disableScroll();

//Для активної лінки
const homeButtons = document.getElementsByClassName('js-main-link-home');
const favoritesButtons = document.getElementsByClassName('js-main-link-favorites');
const currentPath = window.location.pathname;
const targetPage = 'favorites.html';

if (currentPath === '/' + targetPage) {
Array.from(favoritesButtons).forEach(button => button.classList.add('active-link'));
Array.from(homeButtons).forEach(button => button.classList.remove('active-link'));
} else {
Array.from(homeButtons).forEach(button => button.classList.add('active-link'));
Array.from(favoritesButtons).forEach(button => button.classList.remove('active-link'));
}

});

refs.closeModalBtn.addEventListener('click', function () {
toggleModal();
enableScroll();
Expand Down Expand Up @@ -43,6 +56,10 @@ const homeButton = document.querySelector('.link-home');
}
})();


const favoritesButton = document.querySelector('.link-favorites');
const homeButton = document.querySelector('.link-home');

window.addEventListener('load', () => {
if (window.location.pathname.endsWith('favorites.html')) {
favoritesButton.classList.add('active-link');
Expand Down

0 comments on commit a7166fa

Please sign in to comment.