-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,351 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
// sidebar toggle variables | ||
const menuToggler = document.querySelector('.menu-toggler'); | ||
const sideBar = document.querySelector('.side-bar'); | ||
|
||
// page navigation variables | ||
const navItemLinks = document.querySelectorAll('.nav li a'); | ||
const pages = document.querySelectorAll('.page'); | ||
|
||
|
||
// variables for filtering | ||
const filterBtn = document.querySelectorAll('.filter-item'); | ||
const itemCategory = document.querySelectorAll('.item-category'); | ||
|
||
// toggling sidebar in mobile | ||
menuToggler.addEventListener('click', function(){ | ||
sideBar.classList.toggle('active'); | ||
}); | ||
|
||
|
||
// page navigation functionality | ||
|
||
for (let i = 0; i < navItemLinks.length; i++) { | ||
// added onclick event in nav links | ||
navItemLinks[i].addEventListener('click', function(){ | ||
|
||
// collected nav links innertext | ||
const itemLinkText = this.textContent.toLowerCase(); | ||
|
||
// defined page and add active class | ||
for (let i = 0; i < pages.length; i++) { | ||
|
||
// defining page condition | ||
if (pages[i].classList.contains(itemLinkText)) { | ||
// add active class on current page | ||
pages[i].classList.add('active'); | ||
// add active class on clicked nav link | ||
navItemLinks[i].classList.add('active'); | ||
} else { | ||
// remove active class from other pages | ||
pages[i].classList.remove('active'); | ||
// remove active class from other nav links | ||
navItemLinks[i].classList.remove('active'); | ||
} | ||
|
||
} | ||
|
||
}); | ||
} | ||
|
||
// added eventListener in filter buttons | ||
for (let i = 0; i < filterBtn.length; i++) { | ||
filterBtn[i].addEventListener('click', function(){ | ||
|
||
// remove all active class from filter button | ||
for (let i = 0; i < filterBtn.length; i++) { | ||
filterBtn[i].classList.remove('active'); | ||
} | ||
// added active class on filter button clicked | ||
this.classList.add('active'); | ||
|
||
// show item, based on filter button click | ||
for (let i = 0; i < itemCategory.length; i++) { | ||
const itemCategoryText = itemCategory[i].textContent; | ||
console.log(itemCategoryText); | ||
switch (this.textContent) { | ||
case itemCategoryText: | ||
itemCategory[i].parentElement.classList.add('active'); | ||
break; | ||
case 'All': | ||
itemCategory[i].parentElement.classList.add('active'); | ||
break; | ||
default: | ||
itemCategory[i].parentElement.classList.remove('active'); | ||
} | ||
} | ||
}); | ||
} |
Oops, something went wrong.