-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (63 loc) · 2.01 KB
/
Copy pathscript.js
File metadata and controls
71 lines (63 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Theme Toggle Functionality
const themeToggle = document.getElementById('theme-toggle');
const body = document.body;
// Check for saved theme preference or default to light
const currentTheme = localStorage.getItem('theme') || 'light-theme';
body.classList.add(currentTheme);
// Update button text based on current theme
updateThemeButtonText();
// Theme toggle event listener
themeToggle.addEventListener('click', () => {
if (body.classList.contains('dark-theme')) {
body.classList.remove('dark-theme');
body.classList.add('light-theme');
localStorage.setItem('theme', 'light-theme');
} else {
body.classList.remove('light-theme');
body.classList.add('dark-theme');
localStorage.setItem('theme', 'dark-theme');
}
updateThemeButtonText();
});
// Update button text based on theme
function updateThemeButtonText() {
if (body.classList.contains('dark-theme')) {
themeToggle.textContent = 'Light Theme';
} else {
themeToggle.textContent = 'Dark Theme';
}
}
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Optional: Add animation to skill cards on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all skill cards
document.querySelectorAll('.skill-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.3s, transform 0.3s';
observer.observe(card);
});