Basic integration of tabs UI on theme settings page

This commit is contained in:
Jeremy Rangel
2024-12-30 19:41:59 -08:00
parent 4394776735
commit 2df16e37a8
3 changed files with 82 additions and 141 deletions

View File

@ -36,17 +36,26 @@ document.addEventListener('DOMContentLoaded', function () {
const panes = document.querySelectorAll('.tab-pane');
tabs.forEach(tab => {
tab.addEventListener('click', function (event) {
event.preventDefault();
tab.addEventListener('click', function (event) {
event.preventDefault();
// Remove active class from all tabs and panes
tabs.forEach(link => link.classList.remove('active'));
panes.forEach(pane => pane.classList.remove('active'));
// Remove active class from all tabs and panes
tabs.forEach(link => link.classList.remove('active'));
panes.forEach(pane => pane.classList.remove('active'));
// Add active class to the clicked tab and its corresponding pane
tab.classList.add('active');
const targetPane = document.querySelector(tab.getAttribute('href'));
targetPane.classList.add('active');
});
// Add active class to the clicked tab
tab.classList.add('active');
// Get the target pane
const targetPaneId = tab.dataset.tab;
const targetPane = document.getElementById(targetPaneId);
// Check if targetPane exists before trying to manipulate it
if (targetPane) {
targetPane.classList.add('active');
} else {
console.error(`Tab pane with ID '${targetPaneId}' not found.`);
}
});
});
});
});