fix(dashboard): honor sidebar theme preference on all routes (#738)

* fix(dashboard): honor sidebar theme preference on all routes

Stop forcing light mode on public org-site pages. Use one ModeWatcher
everywhere so light/dark/system follows the sidebar footer toggle.

- Remove isPublicOrgSitePage forced-light routing (#716 behavior)
- Fix theme toggle active state (light/dark/system mutually exclusive)

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(dashboard): apply sidebar color mode instead of browser default

ModeWatcher defaulted to system, so prefers-color-scheme won unless
localStorage happened to match. AppModeWatcher now:

- Defaults new visitors to light (not system)
- Injects FOUC script with the same default
- Only tracks OS appearance when the user picks System in the sidebar
- Re-syncs explicit light/dark from mode-watcher localStorage on load

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
This commit is contained in:
Rotimi Best
2026-07-12 17:52:23 +01:00
committed by GitHub
co-authored by Rotimi Best Cursor Agent
parent 46feccd0fd
commit 877b45b1a3
8 changed files with 112 additions and 80 deletions
@@ -0,0 +1,37 @@
<script lang="ts">
import { browser } from '$app/environment';
import {
ModeWatcher,
createInitialModeExpression,
setMode,
systemPrefersMode,
userPrefersMode
} from '@cio/ui/base/dark-mode';
import { MODE_STORAGE_KEY, readStoredColorMode } from '$lib/utils/functions/color-mode';
const initialModeScript = createInitialModeExpression({
defaultMode: 'light',
modeStorageKey: MODE_STORAGE_KEY
});
$effect(() => {
if (!browser) {
return;
}
const storedPreference = readStoredColorMode();
systemPrefersMode.tracking(storedPreference === 'system');
if (storedPreference !== 'system' && userPrefersMode.current !== storedPreference) {
setMode(storedPreference);
}
});
</script>
<svelte:head>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html initialModeScript}
</svelte:head>
<ModeWatcher defaultMode="light" disableHeadScriptInjection />