From 27e115d61c225ae904ae933369694424381f5855 Mon Sep 17 00:00:00 2001 From: Nicholas <31909304+lauslim12@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:15:12 +0000 Subject: [PATCH] Stabilize dark mode + transitions --- app/app.tsx | 2 +- app/use-dark-mode.ts | 5 +---- index.html | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/app.tsx b/app/app.tsx index 2f3994d..984c051 100644 --- a/app/app.tsx +++ b/app/app.tsx @@ -16,7 +16,7 @@ import { Header } from "~/header"; * bypassing the optimization glitch. */ export const App = () => ( -
+
diff --git a/app/use-dark-mode.ts b/app/use-dark-mode.ts index af98831..d17eb43 100644 --- a/app/use-dark-mode.ts +++ b/app/use-dark-mode.ts @@ -14,10 +14,7 @@ const DarkThemeStore = createStore( * Subscribe to changes in the dark theme store to ensure only one * listener updates the DOM, regardless of how many components use the hook. */ -DarkThemeStore.subscribe(() => { - // Read state directly from the store. - const isDark = DarkThemeStore.state; - +DarkThemeStore.subscribe((isDark) => { if (isDark) { document.documentElement.classList.add("dark"); return; diff --git a/index.html b/index.html index 5eb6d72..62e7a57 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,8 @@ const isDark = window.matchMedia("(prefers-color-scheme: dark)").matches; if (isDark) { document.documentElement.classList.add("dark"); + } else { + document.documentElement.classList.remove("dark"); }