ht-OwnCraft/static/js/menu.js
2025-01-04 02:40:01 +01:00

29 lines
No EOL
1.2 KiB
JavaScript

// Menu category handling
document.addEventListener('DOMContentLoaded', function() {
// Handle tab switching
const allTabButtons = document.querySelectorAll('[data-tab]');
allTabButtons.forEach(button => {
button.addEventListener('click', function() {
const tabId = this.getAttribute('data-tab');
// Hide all content
document.querySelectorAll('.menu-content').forEach(content => {
content.classList.add('hidden');
});
// Show selected content
document.getElementById(tabId + '-content').classList.remove('hidden');
// Update active states for all buttons with same data-tab
allTabButtons.forEach(btn => {
if (btn.getAttribute('data-tab') === tabId) {
btn.classList.add('bg-pizza-red', 'text-white');
btn.classList.remove('bg-gray-200', 'dark:bg-pizza-darker', 'text-gray-700');
} else {
btn.classList.remove('bg-pizza-red', 'text-white');
btn.classList.add('bg-gray-200', 'dark:bg-pizza-darker', 'text-gray-700');
}
});
});
});
});