From 877b45b1a3ee5f3f77c50c1345d76efedaa9bfbe Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sun, 12 Jul 2026 17:52:23 +0100 Subject: [PATCH] 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 * 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 --------- Co-authored-by: Cursor Agent Co-authored-by: Rotimi Best --- .../lib/features/app/app-mode-watcher.svelte | 37 +++++++++++++++++ .../ui/sidebar/footer/theme-toggle.svelte | 34 +++++++++------- .../src/lib/utils/constants/routes.ts | 7 ---- .../lib/utils/functions/color-mode.test.ts | 40 +++++++++++++++++++ .../src/lib/utils/functions/color-mode.ts | 14 +++++++ .../lib/utils/functions/color-scheme.test.ts | 25 ------------ .../src/lib/utils/functions/color-scheme.ts | 23 ----------- apps/dashboard/src/routes/+layout.svelte | 12 +----- 8 files changed, 112 insertions(+), 80 deletions(-) create mode 100644 apps/dashboard/src/lib/features/app/app-mode-watcher.svelte create mode 100644 apps/dashboard/src/lib/utils/functions/color-mode.test.ts create mode 100644 apps/dashboard/src/lib/utils/functions/color-mode.ts delete mode 100644 apps/dashboard/src/lib/utils/functions/color-scheme.test.ts delete mode 100644 apps/dashboard/src/lib/utils/functions/color-scheme.ts diff --git a/apps/dashboard/src/lib/features/app/app-mode-watcher.svelte b/apps/dashboard/src/lib/features/app/app-mode-watcher.svelte new file mode 100644 index 00000000..8e4fdcfb --- /dev/null +++ b/apps/dashboard/src/lib/features/app/app-mode-watcher.svelte @@ -0,0 +1,37 @@ + + + + + {@html initialModeScript} + + + diff --git a/apps/dashboard/src/lib/features/ui/sidebar/footer/theme-toggle.svelte b/apps/dashboard/src/lib/features/ui/sidebar/footer/theme-toggle.svelte index 30b8301b..070b6448 100644 --- a/apps/dashboard/src/lib/features/ui/sidebar/footer/theme-toggle.svelte +++ b/apps/dashboard/src/lib/features/ui/sidebar/footer/theme-toggle.svelte @@ -1,29 +1,31 @@
@@ -31,11 +33,13 @@
{#each themes as theme (theme.mode)} - {@const isActive = userPrefersMode.current === theme.mode || userPrefersMode.current === undefined}