Vegeta2308/electrohaven-components-hub
0
1// Tab functionality2document.addEventListener('DOMContentLoaded', function() {3 // Module tabs4 const tabButtons = document.querySelectorAll('.tab-btn');5 const tabContents = document.querySelectorAll('.tab-content');6 7 tabButtons.forEach(button => {8 button.addEventListener('click', () => {9 // Remove active class from all buttons and contents10 tabButtons.forEach(btn => btn.classList.remove('active'));11 tabContents.forEach(content => content.classList.remove('active'));12 13 // Add active class to clicked button14 button.classList.add('active');15 16 // Show corresponding content17 const tabId = button.getAttribute('data-tab');18 document.getElementById(tabId).classList.add('active');19 });20 });21 22 // Smooth scrolling for anchor links23 document.querySelectorAll('a[href^="#"]').forEach(anchor => {24 anchor.addEventListener('click', function(e) {25 e.preventDefault();26 27 const targetId = this.getAttribute('href');28 if (targetId === '#') return;29 30 const targetElement = document.querySelector(targetId);31 if (targetElement) {32 window.scrollTo({33 top: targetElement.offsetTop - 80,34 behavior: 'smooth'35 });36 }37 });38 });39});