diff --git a/script.js b/script.js index 7ada10d..ddeeb04 100644 --- a/script.js +++ b/script.js @@ -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(); } - }; \ No newline at end of file +};