diff --git a/resources/js/themeToggle.js b/resources/js/themeToggle.js index 3a0ca5f..a3288cf 100644 --- a/resources/js/themeToggle.js +++ b/resources/js/themeToggle.js @@ -1,11 +1,11 @@ document.addEventListener("DOMContentLoaded", function() { - const themeToggleIcon = { - dark: document.getElementById("theme-toggle-dark-icon"), - light: document.getElementById("theme-toggle-light-icon") + const themeToggleIcons = { + dark: Array.from(document.querySelectorAll(".theme-toggle-dark-icon")), + light: Array.from(document.querySelectorAll(".theme-toggle-light-icon")) }; // Make sure the theme toggle icons are available. - if (themeToggleIcon.dark === null || themeToggleIcon.light === null) { + if (themeToggleIcons.dark.length === 0 || themeToggleIcons.light.length === 0) { console.log("Theme toggle icons not found."); return; } @@ -13,11 +13,11 @@ document.addEventListener("DOMContentLoaded", function() { // Function to update the visibility of the theme icons based on the theme function updateIconVisibility(theme) { if (theme === "dark") { - themeToggleIcon.dark.classList.add("hidden"); - themeToggleIcon.light.classList.remove("hidden"); + themeToggleIcons.dark.forEach(icon => icon.classList.add("hidden")); + themeToggleIcons.light.forEach(icon => icon.classList.remove("hidden")); } else { - themeToggleIcon.dark.classList.remove("hidden"); - themeToggleIcon.light.classList.add("hidden"); + themeToggleIcons.dark.forEach(icon => icon.classList.remove("hidden")); + themeToggleIcons.light.forEach(icon => icon.classList.add("hidden")); } } @@ -41,13 +41,15 @@ document.addEventListener("DOMContentLoaded", function() { document.documentElement.classList.add(initialTheme); // Ensure the class is set updateIconVisibility(initialTheme); - // Set up the theme toggle button - const themeToggleBtn = document.getElementById("theme-toggle"); - themeToggleBtn.addEventListener("click", function() { - // Determine the current theme by checking the classList of documentElement - const currentTheme = document.documentElement.classList.contains("dark") ? "dark" : "light"; - const newTheme = currentTheme === "light" ? "dark" : "light"; + // Set up the theme toggle buttons + const themeToggleButtons = Array.from(document.querySelectorAll(".theme-toggle")); + themeToggleButtons.forEach(button => { + button.addEventListener("click", function() { + // Determine the current theme by checking the classList of documentElement + const currentTheme = document.documentElement.classList.contains("dark") ? "dark" : "light"; + const newTheme = currentTheme === "light" ? "dark" : "light"; - updateTheme(newTheme); + updateTheme(newTheme); + }); }); }); diff --git a/resources/views/components/responsive-nav-link.blade.php b/resources/views/components/responsive-nav-link.blade.php index 19e13eb..9ecb3fa 100644 --- a/resources/views/components/responsive-nav-link.blade.php +++ b/resources/views/components/responsive-nav-link.blade.php @@ -2,8 +2,8 @@ @php $classes = ($active ?? false) - ? 'block w-full ps-3 pe-4 py-2 border-l-4 border-grey-400 text-start text-base font-medium text-gray-700 bg-gray-50 dark:bg-gray-800 focus:outline-none focus:text-gray-800 dark:focus:text-gray-300 focus:bg-gray-100 dark:focus:bg-gray-700 focus:border-gray-700 dark:focus:border-gray-700 transition duration-150 ease-in-out' - : 'block w-full ps-3 pe-4 py-2 border-l-4 border-transparent text-start text-base font-medium text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-gray-500 hover:bg-gray-50 dark:hover:bg-gray-800 hover:border-gray-300 dark:hover:border-gray-700 focus:outline-none focus:text-gray-800 dark:focus:text-gray-300 focus:bg-gray-50 dark:focus:bg-gray-700 focus:border-gray-300 dark:focus:border-gray-700 transition duration-150 ease-in-out'; + ? 'block rounded-md px-3 py-2 text-base font-medium text-gray-700 dark:text-gray-100 bg-gray-100 dark:bg-gray-900 transition duration-150 ease-in-out' + : 'block rounded-md px-3 py-2 text-base font-medium text-gray-700 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-gray-800 dark:hover:text-white transition duration-150 ease-in-out'; @endphp merge(['class' => $classes]) }}> diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php index 792ddd3..be74666 100644 --- a/resources/views/navigation-menu.blade.php +++ b/resources/views/navigation-menu.blade.php @@ -1,4 +1,4 @@ -