@tydavidson/design-system 1.1.3 → 1.1.4

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.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as React2 from 'react';
2
- import { createContext, useState, useEffect, useContext } from 'react';
3
2
  import { Slot } from '@radix-ui/react-slot';
4
3
  import { cva } from 'class-variance-authority';
5
4
  import { clsx } from 'clsx';
@@ -1536,30 +1535,20 @@ var isDarkTheme = (theme, systemTheme) => {
1536
1535
  }
1537
1536
  return theme === "dark";
1538
1537
  };
1539
- var ThemeContext = createContext(void 0);
1540
- function ThemeContextProvider({
1541
- children
1542
- }) {
1543
- const [isClient, setIsClient] = useState(false);
1538
+ function useTheme() {
1544
1539
  const { theme, setTheme, resolvedTheme, systemTheme } = useTheme$1();
1545
- useEffect(() => {
1546
- setIsClient(true);
1547
- }, []);
1548
1540
  const isDark = isDarkTheme(theme, systemTheme);
1549
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: {
1541
+ return {
1550
1542
  theme: theme || "system",
1551
1543
  setTheme,
1552
1544
  resolvedTheme: resolvedTheme || "light",
1553
- isClient,
1554
1545
  isDark
1555
- }, children });
1546
+ };
1556
1547
  }
1557
- function useTheme() {
1558
- const context = useContext(ThemeContext);
1559
- if (context === void 0) {
1560
- throw new Error("useTheme must be used within a ThemeContextProvider");
1561
- }
1562
- return context;
1548
+ function ThemeContextProvider({
1549
+ children
1550
+ }) {
1551
+ return /* @__PURE__ */ jsx(Fragment, { children });
1563
1552
  }
1564
1553
  function ThemeToggle({
1565
1554
  className,
@@ -1567,8 +1556,12 @@ function ThemeToggle({
1567
1556
  size = "md",
1568
1557
  ...props
1569
1558
  }) {
1570
- const { theme, setTheme, resolvedTheme, isClient } = useTheme();
1571
- if (!isClient) return null;
1559
+ const { theme, setTheme, resolvedTheme } = useTheme();
1560
+ const [mounted, setMounted] = React2.useState(false);
1561
+ React2.useEffect(() => {
1562
+ setMounted(true);
1563
+ }, []);
1564
+ if (!mounted) return null;
1572
1565
  const toggleTheme = () => {
1573
1566
  setTheme(resolvedTheme === "dark" ? "light" : "dark");
1574
1567
  };