-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from KaranSingh36752/patch-1
Update script.js
- Loading branch information
Showing
1 changed file
with
26 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
const toggleIcon = document.querySelector(".toggle-theme"); | ||
const toggleIcon = document.querySelector(".toggle-theme"); | ||
|
||
function toggleDarkMode() { | ||
document.body.classList.toggle("dark-mode"); | ||
const applyTheme = (isDarkMode) => { | ||
const footer = document.querySelector(".footer"); | ||
|
||
if (document.body.classList.contains("dark-mode")) { | ||
if (isDarkMode) { | ||
document.body.classList.add("dark-mode"); | ||
document.body.style.backgroundColor = "#1b1f38"; | ||
document.body.style.color = "white"; | ||
footer.style.color = "white"; | ||
toggleIcon.classList.remove('fa-moon'); | ||
toggleIcon.classList.add('fa-sun'); | ||
} else { | ||
document.body.classList.remove("dark-mode"); | ||
document.body.style.backgroundColor = "white"; | ||
document.body.style.color = "#1b1f38"; | ||
footer.style.color = "#1b1f38"; | ||
toggleIcon.classList.remove('fa-sun'); | ||
toggleIcon.classList.add('fa-moon'); | ||
} | ||
} | ||
}; | ||
|
||
function openModal() { | ||
const toggleDarkMode = () => { | ||
const isDarkMode = !document.body.classList.contains("dark-mode"); | ||
applyTheme(isDarkMode); | ||
}; | ||
|
||
window.onload = () => { | ||
const isDarkMode = false; | ||
applyTheme(isDarkMode); | ||
}; | ||
|
||
const openModal = () => { | ||
document.getElementById("myModal").style.display = "flex"; | ||
} | ||
}; | ||
|
||
function closeModal() { | ||
const closeModal = () => { | ||
document.getElementById("myModal").style.display = "none"; | ||
} | ||
}; | ||
|
||
// Close the modal when clicking outside of the content | ||
window.onclick = function (event) { | ||
window.onclick = (event) => { | ||
const modal = document.getElementById("myModal"); | ||
if (event.target == modal) { | ||
closeModal(); | ||
closeModal(); | ||
} | ||
}; | ||
}; |