diff --git a/app.js b/app.js index 97c1b943..a4a70642 100644 --- a/app.js +++ b/app.js @@ -1,4 +1,23 @@ $(document).ready(function() { + + + const themeToggle = document.getElementById("theme-toggle"); +const body = document.body; + +function toggleTheme() { + body.classList.toggle("dark-mode"); + const isDarkMode = body.classList.contains("dark-mode"); + localStorage.setItem("theme", isDarkMode ? "dark" : "light"); +} + +themeToggle.addEventListener("click", toggleTheme); + +const savedTheme = localStorage.getItem("theme"); +if (savedTheme === "dark") { + body.classList.add("dark-mode"); +} + + // Create a variable for the container to hold the emoji cards. const emojiCardContainer = document.getElementById("emojis"); diff --git a/index.html b/index.html index cd27842d..906c5f50 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,9 @@
Want to add to EmojiScreen? Head to Github! ✨
Contribute + + +