Add theme switcher to user dropdown too

This commit is contained in:
DariusIII
2026-03-03 13:31:23 +01:00
parent ca489cb904
commit 3c04c580d2
3 changed files with 80 additions and 0 deletions
+17
View File
@@ -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() {