Skip to content

Commit

Permalink
theme-provider: announce/set (current) theme and applied theme
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-dot-js committed Nov 30, 2023
1 parent 04e87b5 commit db36a2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/theme-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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(),
}}
Expand Down

0 comments on commit db36a2a

Please sign in to comment.