import './bootstrap'; document.addEventListener('DOMContentLoaded', () => { const codeBlocks = document.querySelectorAll('pre'); codeBlocks.forEach((pre) => { if (!pre.parentElement.classList.contains('relative')) { const wrapper = document.createElement('div'); wrapper.className = 'relative group'; pre.parentNode.insertBefore(wrapper, pre); wrapper.appendChild(pre); } const wrapper = pre.parentElement; const copyButton = document.createElement('button'); copyButton.className = 'absolute top-2 right-2 px-3 py-1.5 bg-gray-700/80 text-white border border-white/20 rounded-md text-xs font-medium cursor-pointer opacity-0 group-hover:opacity-100 transition-all duration-200 ease-in-out flex items-center gap-1 hover:bg-gray-700'; copyButton.innerHTML = ` Copy`; copyButton.addEventListener('click', () => { const code = pre.querySelector('code'); const text = code ? code.textContent : pre.textContent; navigator.clipboard.writeText(text).then(() => { copyButton.classList.remove('bg-gray-700/80', 'border-white/20', 'hover:bg-gray-700'); copyButton.classList.add('!bg-emerald-500/90', 'border-emerald-500'); copyButton.innerHTML = ` Copied!`; setTimeout(() => { copyButton.classList.add('bg-gray-700/80', 'border-white/20', 'hover:bg-gray-700'); copyButton.classList.remove('!bg-emerald-500/90', 'border-emerald-500'); copyButton.innerHTML = `Copy`; }, 2000); }).catch((err) => { console.error('Failed to copy:', err); }); }); wrapper.appendChild(copyButton); }); // Tab switching functionality const tabButtons = document.querySelectorAll('[data-tab]'); const tabContents = document.querySelectorAll('[data-tab-content]'); tabButtons.forEach(button => { button.addEventListener('click', function () { const targetTab = this.dataset.tab; // Remove active class from all buttons tabButtons.forEach(btn => { btn.classList.remove('active', 'border-gta-orange', 'text-gta-orange'); btn.classList.add('border-transparent', 'text-gray-500', 'dark:text-gray-400'); }); // Add active class to clicked button this.classList.remove('border-transparent', 'text-gray-500', 'dark:text-gray-400'); this.classList.add('active', 'border-gta-orange', 'text-gta-orange'); // Hide all tab contents tabContents.forEach(content => { content.classList.add('hidden'); content.classList.remove('active'); }); // Show target tab content const targetContent = document.querySelector(`[data-tab-content="${targetTab}"]`); if (targetContent) { targetContent.classList.remove('hidden'); targetContent.classList.add('active'); } }); }); });