From db36a2a6f0dadcbcd4c51edb73970699e9ad1d2e Mon Sep 17 00:00:00 2001 From: Cody A Price Date: Thu, 30 Nov 2023 02:19:53 -0600 Subject: [PATCH] theme-provider: announce/set (current) theme and applied theme --- components/theme-provider/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/theme-provider/index.tsx b/components/theme-provider/index.tsx index 60e57c91..b57b283e 100644 --- a/components/theme-provider/index.tsx +++ b/components/theme-provider/index.tsx @@ -163,7 +163,8 @@ function applyTheme(theme: Theme) { const prefersHighContrast = window.matchMedia(prefersHighContrastMediaQuery).matches; const newTheme = theme === "system" ? determineThemeFromMediaQuery({ prefersDarkMode, prefersHighContrast }) : theme; htmlElement.classList.add(newTheme); - htmlElement.dataset.theme = newTheme; + htmlElement.dataset.appliedTheme = newTheme; + htmlElement.dataset.theme = theme; } /** @@ -221,7 +222,8 @@ const PreventWrongThemeFlash = ({ const htmlElement = document.documentElement; htmlElement.classList.remove(...themes); htmlElement.classList.add(initialTheme); - htmlElement.dataset.theme = initialTheme; + htmlElement.dataset.appliedTheme = initialTheme; + htmlElement.dataset.theme = themePreference; })(); `.trim(), }}