feat: position filter

This commit is contained in:
Rico van Zelst
2023-11-08 21:40:51 +01:00
parent c7eae5d41a
commit 00018878e0
5 changed files with 68 additions and 8 deletions

View File

@@ -0,0 +1,35 @@
document.addEventListener('DOMContentLoaded', function () {
const laneFilters = document.querySelectorAll('.lane-filter');
const championDivs = document.querySelectorAll('.champ-card');
laneFilters.forEach((filter) => {
filter.addEventListener('click', function () {
const selectedLane = filter.getAttribute('data-lane');
if (filter.classList.contains('opacity-100')) {
// If the filter is already active, unselect it and show all
championDivs.forEach((championDiv) => {
championDiv.style.display = 'block';
});
filter.classList.remove('opacity-100');
filter.classList.add('opacity-40');
} else {
// If the filter is not active, activate it and filter champions
laneFilters.forEach((otherFilter) => {
otherFilter.classList.remove('opacity-100');
otherFilter.classList.add('opacity-40');
});
filter.classList.remove('opacity-40');
filter.classList.add('opacity-100');
championDivs.forEach((championDiv) => {
if (selectedLane === 'All' || championDiv.classList.contains('POS-' + selectedLane)) {
championDiv.style.display = 'block';
} else {
championDiv.style.display = 'none';
}
});
}
});
});
});