kingdelexx's picture
i want a multi page portfolio website for myself i am a fullstack developer profficient in python and django, html, css, react and javascript. i have many project to showoff with, the site should have a nice navber and potensial client can message or reach out to me on all socials, and the ui design should be dark and light morphism
098a0cb verified
Raw History Blame Contribute Delete
2.64 kB
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Form submission handler
const contactForm = document.querySelector('form');
if (contactForm) {
contactForm.addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(contactForm);
const submitBtn = contactForm.querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
try {
submitBtn.disabled = true;
submitBtn.innerHTML = 'Sending... <i data-feather="loader" class="w-4 h-4 animate-spin"></i>';
feather.replace();
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 1500));
// Show success message
alert('Thank you for your message! I will get back to you soon.');
contactForm.reset();
} catch (error) {
alert('There was an error sending your message. Please try again later.');
} finally {
submitBtn.disabled = false;
submitBtn.innerHTML = originalText;
feather.replace();
}
});
}
// Animate elements on scroll
const animateOnScroll = () => {
const elements = document.querySelectorAll('.animate-fade-in');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (elementPosition < windowHeight - 100) {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
};
// Initialize animation and set up scroll listener
document.addEventListener('DOMContentLoaded', () => {
animateOnScroll();
window.addEventListener('scroll', animateOnScroll);
});
// Theme switcher with localStorage
const toggleTheme = () => {
const html = document.documentElement;
html.classList.toggle('light-mode');
const isLight = html.classList.contains('light-mode');
localStorage.setItem('theme', isLight ? 'light' : 'dark');
// Update theme toggle icon
const themeIcons = document.querySelectorAll('[data-theme-icon]');
themeIcons.forEach(icon => {
if (isLight) {
icon.setAttribute('data-feather', 'moon');
} else {
icon.setAttribute('data-feather', 'sun');
}
feather.replace(icon);
});
};
// Initialize theme from localStorage
const savedTheme = localStorage.getItem('theme') || 'dark';
if (savedTheme === 'light') {
document.documentElement.classList.add('light-mode');
}