diff --git a/resources/js/alpine/components/theme-toggle.js b/resources/js/alpine/components/theme-toggle.js index a77296ad3..1e95705b0 100644 --- a/resources/js/alpine/components/theme-toggle.js +++ b/resources/js/alpine/components/theme-toggle.js @@ -49,4 +49,16 @@ Alpine.data('themeRadio', () => ({ Alpine.store('theme').set(this.value); }); }); + + // Dropdown and mobile theme switcher buttons + document.querySelectorAll('.dropdown-theme-btn, .mobile-theme-btn').forEach(function(btn) { + btn.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + var theme = this.dataset.theme; + if (theme) { + Alpine.store('theme').set(theme); + } + }); + }); })(); diff --git a/resources/js/alpine/stores/theme.js b/resources/js/alpine/stores/theme.js index a38017d6f..01e17ed7f 100644 --- a/resources/js/alpine/stores/theme.js +++ b/resources/js/alpine/stores/theme.js @@ -66,6 +66,23 @@ Alpine.store('theme', { if (toggle) { toggle.title = this.title(); } + + // Update dropdown & mobile theme switcher buttons + var self = this; + document.querySelectorAll('.dropdown-theme-btn, .mobile-theme-btn').forEach(function(btn) { + var isActive = btn.dataset.theme === self.current; + btn.classList.remove('bg-blue-600', 'text-white', 'text-gray-300', 'hover:bg-gray-800', 'hover:bg-gray-700', 'hover:text-white'); + if (isActive) { + btn.classList.add('bg-blue-600', 'text-white'); + } else { + btn.classList.add('text-gray-300', 'hover:text-white'); + if (btn.classList.contains('mobile-theme-btn')) { + btn.classList.add('hover:bg-gray-700'); + } else { + btn.classList.add('hover:bg-gray-800'); + } + } + }); }, icon() { diff --git a/resources/views/partials/header-menu.blade.php b/resources/views/partials/header-menu.blade.php index 21d248117..ab36fbb61 100644 --- a/resources/views/partials/header-menu.blade.php +++ b/resources/views/partials/header-menu.blade.php @@ -250,6 +250,32 @@ @endif
+ +