forked from Ruderverein-Donau-Linz/rowt
[TASK] add filter and change aria-pressed style button
This commit is contained in:
@ -33,6 +33,30 @@ function initToggle() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const monthToggle = <HTMLInputElement>document.querySelector('#filtermonth-js');
|
||||
const months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
|
||||
|
||||
if(monthToggle) {
|
||||
monthToggle.addEventListener('click', () => {
|
||||
monthToggle.ariaPressed = (monthToggle.ariaPressed === 'true') ? 'false' : 'true';
|
||||
const currentMonth = monthToggle.dataset.month;
|
||||
|
||||
if(currentMonth) {
|
||||
const index = months.indexOf(currentMonth);
|
||||
if (index > -1) { // only splice array when item is found
|
||||
months.splice(index, 1); // 2nd parameter means remove one item only
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(months, (month: HTMLElement) => {
|
||||
const notThisMonth = document.querySelectorAll('div[data-month="' + month + '"]');
|
||||
Array.prototype.forEach.call(notThisMonth, (notThisMonth: HTMLElement) => {
|
||||
notThisMonth.classList.toggle('hidden');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initSearch() {
|
||||
|
@ -22,6 +22,6 @@
|
||||
}
|
||||
|
||||
&[aria-pressed='true'] {
|
||||
@apply outline outline-2 outline-offset-2 outline-primary-600;
|
||||
@apply outline outline-2 outline-offset-2 outline-primary-600 bg-primary-100 text-primary-950;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user