feat(ui): add dark mode toggle to navbar
Uses Bootstrap 5.3 native data-bs-theme with localStorage persistence. Inline script in <head> prevents flash on page load. Moon/sun icon in top-right navbar switches between light and dark. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -66,10 +66,35 @@ async function api(method, path, body = null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dark mode
|
||||
// ---------------------------------------------------------------------------
|
||||
function toggleDarkMode() {
|
||||
const isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';
|
||||
if (isDark) {
|
||||
document.documentElement.removeAttribute('data-bs-theme');
|
||||
localStorage.setItem('darkMode', 'light');
|
||||
document.getElementById('darkmode-icon').className = 'bi bi-moon-fill';
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
||||
localStorage.setItem('darkMode', 'dark');
|
||||
document.getElementById('darkmode-icon').className = 'bi bi-sun-fill';
|
||||
}
|
||||
}
|
||||
|
||||
function syncDarkmodeIcon() {
|
||||
const icon = document.getElementById('darkmode-icon');
|
||||
if (!icon) return;
|
||||
icon.className = document.documentElement.getAttribute('data-bs-theme') === 'dark'
|
||||
? 'bi bi-sun-fill'
|
||||
: 'bi bi-moon-fill';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Auth
|
||||
// ---------------------------------------------------------------------------
|
||||
async function initApp() {
|
||||
syncDarkmodeIcon();
|
||||
await initI18n();
|
||||
await loadBranding();
|
||||
await loadAzureLoginConfig();
|
||||
|
||||
Reference in New Issue
Block a user