feat(services-cards): add accordion feature to section

This commit is contained in:
2025-08-16 21:44:13 -05:00
parent d742364f46
commit b109387471
9 changed files with 231 additions and 102 deletions

17
src/scripts/services.js Normal file
View File

@@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function() {
const accordionHeaders = document.querySelectorAll('.accordion-header');
accordionHeaders.forEach(header => {
header.addEventListener('click', function() {
const content = this.nextElementSibling;
// Check if maxHeight has a value. If it does, the accordion is open.
if (content.style.maxHeight) {
content.style.maxHeight = null; // Close the accordion
} else {
// The accordion is closed, open it by setting max-height to its scroll height
content.style.maxHeight = content.scrollHeight + 'px';
}
});
});
});