- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
53 lines (47 loc) · 1.79 KB
/
Copy pathscript.js
File metadata and controls
53 lines (47 loc) · 1.79 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
// Toggle Mobile Navigation Menu
document.querySelector('.menu-toggle').addEventListener('click',()=>{
document.querySelector('.nav-links').classList.toggle('show');
});
// Dark Mode Toggle
document.querySelector('#dark-mode-toggle').addEventListener('click',()=>{
if(document.body.getAttribute('data-theme')==='dark'){
document.body.removeAttribute('data-theme');
localStorage.setItem('theme','light');
}else{
document.body.setAttribute('data-theme','dark');
localStorage.setItem('theme','dark');
}
});
// Load Dark Mode Preference on Page Load
if(localStorage.getItem('theme')==='dark'){
document.body.setAttribute('data-theme','dark');
}
// Handle Modal Popups for Projects
document.querySelectorAll('.modal-btn').forEach(button=>{
button.addEventListener('click',event=>{
constmodalId=event.target.getAttribute('data-modal');
document.getElementById(modalId).style.display='flex';
});
});
document.querySelectorAll('.close-btn').forEach(button=>{
button.addEventListener('click',event=>{
constmodalId=event.target.getAttribute('data-modal');
document.getElementById(modalId).style.display='none';
});
});
window.addEventListener('click',event=>{
if(event.target.classList.contains('modal')){
event.target.style.display='none';
}
});
constprojectsContainer=document.querySelector(".projects");
projects.forEach(project=>{
constprojectCard=document.createElement("div");
projectCard.classList.add("project-card");
projectCard.innerHTML=`
<h3>${project.title}</h3>
<p>${project.description}</p>
<a href="${project.link}" class="btn btn-primary">View More</a>
`;
projectsContainer.appendChild(projectCard);
});