|
|
|
|
|
const $ = (sel, ctx = document) => ctx.querySelector(sel); |
|
|
const $$ = (sel, ctx = document) => Array.from(ctx.querySelectorAll(sel)); |
|
|
|
|
|
|
|
|
const menuBtn = $('#menuBtn'); |
|
|
const mobileNav = $('#mobileNav'); |
|
|
if (menuBtn && mobileNav) { |
|
|
menuBtn.addEventListener('click', () => { |
|
|
const expanded = menuBtn.getAttribute('aria-expanded') === 'true'; |
|
|
menuBtn.setAttribute('aria-expanded', String(!expanded)); |
|
|
mobileNav.classList.toggle('hidden'); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
$$('a[href^="#"]').forEach(a => { |
|
|
a.addEventListener('click', e => { |
|
|
const href = a.getAttribute('href'); |
|
|
if (!href || href === '#') return; |
|
|
const target = $(href); |
|
|
if (target) { |
|
|
e.preventDefault(); |
|
|
target.scrollIntoView({ behavior: 'smooth', block: 'start' }); |
|
|
|
|
|
if (!mobileNav.classList.contains('hidden')) { |
|
|
mobileNav.classList.add('hidden'); |
|
|
menuBtn.setAttribute('aria-expanded', 'false'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const form = $('#contactForm'); |
|
|
if (form) { |
|
|
form.addEventListener('submit', async (e) => { |
|
|
e.preventDefault(); |
|
|
const formData = new FormData(form); |
|
|
const data = Object.fromEntries(formData.entries()); |
|
|
|
|
|
|
|
|
if (!data.email || !/^\S+@\S+\.\S+$/.test(data.email)) { |
|
|
alert('Please enter a valid email.'); |
|
|
return; |
|
|
} |
|
|
if (!data.name || data.name.trim().length < 2) { |
|
|
alert('Please enter your name.'); |
|
|
return; |
|
|
} |
|
|
if (!data.message || data.message.trim().length < 10) { |
|
|
alert('Please enter a longer message (10+ characters).'); |
|
|
return; |
|
|
} |
|
|
|
|
|
|
|
|
console.log('Submitting contact form:', data); |
|
|
form.reset(); |
|
|
alert('Thanks! Your message has been sent.'); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
const yearEl = $('#year'); |
|
|
if (yearEl) yearEl.textContent = String(new Date().getFullYear()); |
|
|
|
|
|
|
|
|
console.log('Primary 500:', getComputedStyle(document.documentElement).getPropertyValue('--tw-color-primary-500') || 'N/A'); |
|
|
console.log('Secondary 500:', getComputedStyle(document.documentElement).getPropertyValue('--tw-color-secondary-500') || 'N/A'); |