@julseb-lib/react 0.1.35 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2665,19 +2665,18 @@ import { jsx as jsx18 } from "react/jsx-runtime";
2665
2665
  var ThemeContext = createContext(null);
2666
2666
  var ThemeProviderWrapper = ({ children }) => {
2667
2667
  const [theme, setTheme] = useState10("light");
2668
- const docEl = document.documentElement;
2669
2668
  const switchToLight = () => {
2670
2669
  if (typeof window !== "undefined") {
2671
- docEl.classList.add("light");
2672
- docEl.classList.remove("dark");
2670
+ document.documentElement.classList.add("light");
2671
+ document.documentElement.classList.remove("dark");
2673
2672
  setTheme("light");
2674
2673
  localStorage.setItem("theme", "light");
2675
2674
  }
2676
2675
  };
2677
2676
  const switchToDark = () => {
2678
2677
  if (typeof window !== "undefined") {
2679
- docEl.classList.remove("light");
2680
- docEl.classList.add("dark");
2678
+ document.documentElement.classList.remove("light");
2679
+ document.documentElement.classList.add("dark");
2681
2680
  setTheme("dark");
2682
2681
  localStorage.setItem("theme", "dark");
2683
2682
  }
@@ -2686,7 +2685,7 @@ var ThemeProviderWrapper = ({ children }) => {
2686
2685
  if (typeof window !== "undefined") {
2687
2686
  const storedTheme = localStorage.getItem("theme");
2688
2687
  if (storedTheme) {
2689
- if (theme === "light") switchToLight();
2688
+ if (storedTheme === "light") switchToLight();
2690
2689
  else switchToDark();
2691
2690
  } else {
2692
2691
  if (window.matchMedia("(prefers-color-scheme: dark)").matches)
@@ -2694,7 +2693,7 @@ var ThemeProviderWrapper = ({ children }) => {
2694
2693
  else switchToLight();
2695
2694
  }
2696
2695
  }
2697
- }, [theme, docEl]);
2696
+ }, [theme]);
2698
2697
  const switchTheme = () => {
2699
2698
  if (theme === "light") switchToDark();
2700
2699
  else switchToLight();