Add tabs to lcp-ui js and css

This commit is contained in:
Jeremy Rangel
2024-12-30 19:23:48 -08:00
parent a8b4dc6b70
commit 4394776735
2 changed files with 59 additions and 2 deletions

View File

@ -31,4 +31,22 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
document.addEventListener('DOMContentLoaded', function () {
const tabs = document.querySelectorAll('.tab-link');
const panes = document.querySelectorAll('.tab-pane');
tabs.forEach(tab => {
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'));
// 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');
});
});
});

View File

@ -237,4 +237,43 @@ Version: 1.0
} }
/* LCP TABS */
/* Simple styles for tabs */
#myTab {
list-style-type: none;
padding: 0;
margin: 0;
}
#myTab li {
display: inline-block;
margin-right: 10px;
}
.tab-link {
cursor: pointer;
text-decoration: none;
padding: 10px 20px;
background-color: lightgray;
color: black;
border: 1px solid #ccc;
border-radius: 5px;
}
.tab-link.active {
background-color: #007bff;
color: white;
}
/* Style for the content panes */
.tab-pane {
display: none;
padding: 20px;
border: 1px solid #ccc;
border-top: none;
}
.tab-pane.active {
display: block;
}