@tydavidson/design-system 1.1.20 → 1.2.0
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -30
- package/dist/index.mjs.map +1 -1
- package/dist/themes/index.d.mts +3 -13
- package/dist/themes/index.d.ts +3 -13
- package/dist/themes/index.js +4 -31
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/index.mjs +5 -31
- package/dist/themes/index.mjs.map +1 -1
- package/docs/theme-usage.md +69 -236
- package/package.json +1 -1
package/dist/themes/index.d.mts
CHANGED
@@ -2,20 +2,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ThemeProviderProps } from 'next-themes/dist/types';
|
3
3
|
|
4
4
|
/**
|
5
|
-
* ThemeProvider
|
6
|
-
*
|
7
|
-
* This wraps the next-themes provider with sensible defaults
|
8
|
-
* for handling light/dark themes and system preferences
|
9
|
-
*
|
10
|
-
* IMPORTANT: This component must be used in a Client Component context.
|
11
|
-
* For Server Components, use the NoSSR wrapper or dynamic imports.
|
5
|
+
* Re-exports the `ThemeProvider` from `next-themes` with sensible defaults.
|
6
|
+
* This component must be used in a Client Component context.
|
12
7
|
*/
|
13
8
|
declare function ThemeProvider({ children, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
14
|
-
/**
|
15
|
-
* NoSSR wrapper for theme provider to prevent SSR issues
|
16
|
-
* Use this when you need to ensure the theme provider only renders on the client
|
17
|
-
*/
|
18
|
-
declare function ThemeProviderNoSSR({ children, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
19
9
|
|
20
10
|
/**
|
21
11
|
* Client-only theme provider wrapper
|
@@ -41,4 +31,4 @@ declare function useThemeServer(): {
|
|
41
31
|
isDark: boolean;
|
42
32
|
};
|
43
33
|
|
44
|
-
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider,
|
34
|
+
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider, useThemeServer };
|
package/dist/themes/index.d.ts
CHANGED
@@ -2,20 +2,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ThemeProviderProps } from 'next-themes/dist/types';
|
3
3
|
|
4
4
|
/**
|
5
|
-
* ThemeProvider
|
6
|
-
*
|
7
|
-
* This wraps the next-themes provider with sensible defaults
|
8
|
-
* for handling light/dark themes and system preferences
|
9
|
-
*
|
10
|
-
* IMPORTANT: This component must be used in a Client Component context.
|
11
|
-
* For Server Components, use the NoSSR wrapper or dynamic imports.
|
5
|
+
* Re-exports the `ThemeProvider` from `next-themes` with sensible defaults.
|
6
|
+
* This component must be used in a Client Component context.
|
12
7
|
*/
|
13
8
|
declare function ThemeProvider({ children, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
14
|
-
/**
|
15
|
-
* NoSSR wrapper for theme provider to prevent SSR issues
|
16
|
-
* Use this when you need to ensure the theme provider only renders on the client
|
17
|
-
*/
|
18
|
-
declare function ThemeProviderNoSSR({ children, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
19
9
|
|
20
10
|
/**
|
21
11
|
* Client-only theme provider wrapper
|
@@ -41,4 +31,4 @@ declare function useThemeServer(): {
|
|
41
31
|
isDark: boolean;
|
42
32
|
};
|
43
33
|
|
44
|
-
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider,
|
34
|
+
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider, useThemeServer };
|
package/dist/themes/index.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var
|
3
|
+
var nextThemes = require('next-themes');
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
5
|
+
var React = require('react');
|
5
6
|
|
6
7
|
function _interopNamespace(e) {
|
7
8
|
if (e && e.__esModule) return e;
|
@@ -24,23 +25,9 @@ function _interopNamespace(e) {
|
|
24
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
25
26
|
|
26
27
|
// src/themes/theme-provider.tsx
|
27
|
-
function ThemeProvider({
|
28
|
-
children,
|
29
|
-
...props
|
30
|
-
}) {
|
31
|
-
const [NextThemesProvider, setNextThemesProvider] = React__namespace.useState(void 0);
|
32
|
-
const [mounted, setMounted] = React__namespace.useState(false);
|
33
|
-
React__namespace.useEffect(() => {
|
34
|
-
import('next-themes').then(({ ThemeProvider: Provider }) => {
|
35
|
-
setNextThemesProvider(() => Provider);
|
36
|
-
setMounted(true);
|
37
|
-
});
|
38
|
-
}, []);
|
39
|
-
if (!mounted || !NextThemesProvider) {
|
40
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
41
|
-
}
|
28
|
+
function ThemeProvider({ children, ...props }) {
|
42
29
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
43
|
-
|
30
|
+
nextThemes.ThemeProvider,
|
44
31
|
{
|
45
32
|
attribute: "class",
|
46
33
|
defaultTheme: "system",
|
@@ -51,19 +38,6 @@ function ThemeProvider({
|
|
51
38
|
}
|
52
39
|
);
|
53
40
|
}
|
54
|
-
function ThemeProviderNoSSR({
|
55
|
-
children,
|
56
|
-
...props
|
57
|
-
}) {
|
58
|
-
const [mounted, setMounted] = React__namespace.useState(false);
|
59
|
-
React__namespace.useEffect(() => {
|
60
|
-
setMounted(true);
|
61
|
-
}, []);
|
62
|
-
if (!mounted) {
|
63
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
64
|
-
}
|
65
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { ...props, children });
|
66
|
-
}
|
67
41
|
function ClientThemeProvider({
|
68
42
|
children,
|
69
43
|
...props
|
@@ -193,7 +167,6 @@ function useThemeServer() {
|
|
193
167
|
exports.ClientThemeProvider = ClientThemeProvider;
|
194
168
|
exports.ClientThemeToggle = ClientThemeToggle;
|
195
169
|
exports.ThemeProvider = ThemeProvider;
|
196
|
-
exports.ThemeProviderNoSSR = ThemeProviderNoSSR;
|
197
170
|
exports.useThemeServer = useThemeServer;
|
198
171
|
//# sourceMappingURL=index.js.map
|
199
172
|
//# sourceMappingURL=index.js.map
|
package/dist/themes/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/themes/theme-provider.tsx","../../src/themes/client-wrapper.tsx","../../src/themes/theme-context.tsx"],"names":["React","jsx","React2","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,CAAA,GAAUA,0BAAc,MAAS,CAAA;AACjF,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAUA,0BAAS,KAAK,CAAA;AAElD,EAAMA,2BAAU,MAAM;AAEpB,IAAA,OAAO,aAAa,CAAA,CAAE,IAAA,CAAK,CAAC,EAAE,aAAA,EAAe,UAAS,KAAM;AAC1D,MAAA,qBAAA,CAAsB,MAAM,QAAQ,CAAA;AACpC,MAAA,UAAA,CAAW,IAAI,CAAA;AAAA,IACjB,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,EAAE,CAAA;AAGL,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,kBAAA,EAAoB;AACnC,IAAA,6DAAU,QAAA,EAAS,CAAA;AAAA,EACrB;AAEA,EAAA,uBACEC,cAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,OAAA;AAAA,MACV,YAAA,EAAa,QAAA;AAAA,MACb,YAAA,EAAY,IAAA;AAAA,MACZ,yBAAA,EAAyB,IAAA;AAAA,MACxB,GAAG,KAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ;AAMO,SAAS,kBAAA,CAAmB;AAAA,EACjC,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e,OAAA;AAAA,IACf,MAAA,EAAQ;AAAA,GACV;AACF","file":"index.js","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * ThemeProvider component for handling theme state\n * \n * This wraps the next-themes provider with sensible defaults\n * for handling light/dark themes and system preferences\n * \n * IMPORTANT: This component must be used in a Client Component context.\n * For Server Components, use the NoSSR wrapper or dynamic imports.\n */\nexport function ThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [NextThemesProvider, setNextThemesProvider] = React.useState<any>(undefined);\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only import next-themes on the client side\n import('next-themes').then(({ ThemeProvider: Provider }) => {\n setNextThemesProvider(() => Provider);\n setMounted(true);\n });\n }, []);\n\n // Return children without theme provider during SSR or before mounting\n if (!mounted || !NextThemesProvider) {\n return <>{children}</>;\n }\n\n return (\n <NextThemesProvider\n attribute=\"class\"\n defaultTheme=\"system\"\n enableSystem\n disableTransitionOnChange\n {...props}\n >\n {children}\n </NextThemesProvider>\n )\n}\n\n/**\n * NoSSR wrapper for theme provider to prevent SSR issues\n * Use this when you need to ensure the theme provider only renders on the client\n */\nexport function ThemeProviderNoSSR({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n if (!mounted) {\n return <>{children}</>;\n }\n\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}","\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider } from \"./theme-provider\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Client-only theme provider wrapper\n * This component ensures theme functionality only runs on the client side\n * without using next/dynamic which causes Server Component issues\n */\nexport function ClientThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n // During SSR or before mounting, render children without theme provider\n if (!mounted) {\n return <>{children}</>;\n }\n\n // Once mounted, render with theme provider\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}\n\n/**\n * Client-only theme toggle wrapper\n * This component ensures theme toggle only renders on the client side\n * and provides a safe fallback for Server Components\n */\nexport function ClientThemeToggle(props: any) {\n const [mounted, setMounted] = React.useState(false);\n const [isDark, setIsDark] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n // Check current theme\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const currentTheme = savedTheme || (systemPrefersDark ? 'dark' : 'light');\n setIsDark(currentTheme === 'dark');\n }\n }, []);\n\n const toggleTheme = () => {\n if (typeof window !== 'undefined') {\n const newTheme = isDark ? 'light' : 'dark';\n localStorage.setItem('theme', newTheme);\n document.documentElement.classList.toggle('dark', newTheme === 'dark');\n setIsDark(newTheme === 'dark');\n }\n };\n\n // During SSR or before mounting, render a placeholder\n if (!mounted) {\n return (\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n onClick={toggleTheme}\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n {isDark ? (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n ) : (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\" />\n </svg>\n )}\n </button>\n );\n} ","\"use client\"\n\nimport * as React from \"react\"\n\n/**\n * Server-safe theme hook that can be used in Server Components\n * Returns default theme values without accessing client-side APIs\n */\nexport function useThemeServer() {\n return {\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n };\n}\n\n/**\n * @deprecated Use ThemeProvider from './theme-provider' instead\n * This component is kept for backward compatibility but is no longer needed\n */\nexport function ThemeContextProvider({ \n children \n}: { \n children: React.ReactNode \n}) {\n // This is now a no-op wrapper for backward compatibility\n return <>{children}</>;\n}\n\n/**\n * @deprecated Use useTheme from next-themes directly or use the ThemeProvider\n * This hook is kept for backward compatibility but is no longer needed\n */\nexport function useTheme() {\n // Import next-themes dynamically to avoid SSR issues\n const [themeData, setThemeData] = React.useState({\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n });\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only run on client side\n if (typeof window === 'undefined') return;\n\n // Import next-themes and use it properly\n import('next-themes').then((nextThemes) => {\n // Create a simple theme manager that doesn't violate hook rules\n const themeManager = {\n getTheme: () => {\n // Get theme from localStorage or system preference\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n if (savedTheme) return savedTheme;\n \n // Check system preference\n if (window.matchMedia('(prefers-color-scheme: dark)').matches) {\n return 'dark';\n }\n }\n return 'light';\n },\n setTheme: (theme: string) => {\n if (typeof window !== 'undefined') {\n localStorage.setItem('theme', theme);\n document.documentElement.classList.toggle('dark', theme === 'dark');\n // Trigger a re-render\n setThemeData(prev => ({\n ...prev,\n theme,\n resolvedTheme: theme,\n isDark: theme === 'dark'\n }));\n }\n }\n };\n\n const currentTheme = themeManager.getTheme();\n const isDark = currentTheme === 'dark';\n \n setThemeData({\n theme: currentTheme,\n setTheme: themeManager.setTheme,\n resolvedTheme: currentTheme,\n isDark,\n });\n setMounted(true);\n });\n }, []);\n\n return themeData;\n}"]}
|
1
|
+
{"version":3,"sources":["../../src/themes/theme-provider.tsx","../../src/themes/client-wrapper.tsx","../../src/themes/theme-context.tsx"],"names":["jsx","NextThemesProvider","React","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,GAAG,OAAM,EAAuB;AACxE,EAAA,uBACEA,cAAA;AAAA,IAACC,wBAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,OAAA;AAAA,MACV,YAAA,EAAa,QAAA;AAAA,MACb,YAAA,EAAY,IAAA;AAAA,MACZ,yBAAA,EAAyB,IAAA;AAAA,MACxB,GAAG,KAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ;ACXO,SAAS,mBAAA,CAAoB;AAAA,EAClC,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAuB;AACrB,EAAA,MAAM,C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,EAAW,CAAA;AAAA,4BACnBA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,uBAAA,EAAwB,CAAA;AAAA,4BAChCA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,uBAAA,EAAwB;AAAA;AAAA;AAAA,0BAGlCA,cAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,IAAA;AAAA,UACN,MAAA,EAAO,IAAA;AAAA,UACP,OAAA,EAAQ,WAAA;AAAA,UACR,IAAA,EAAK,MAAA;AAAA,UACL,MAAA,EAAO,cAAA;AAAA,UACP,WAAA,EAAY,GAAA;AAAA,UACZ,aAAA,EAAc,OAAA;AAAA,UACd,cAAA,EAAe,OAAA;AAAA,UAEf,QAAA,kBAAAA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,oCAAA,EAAqC;AAAA;AAAA;AAC/C;AAAA,GAEJ;AAEJ;ACrIO,SAAS,cAAA,GAAiB;AAC/B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,QAAA;AAAA,IACP,QAAA,EAAU,CAAC,KAAA,KAAkB;AAAA,IAAC,CAAA;AAAA,IAC9B,aAAA,EAAe,OAAA;AAAA,IACf,MAAA,EAAQ;AAAA,GACV;AACF","file":"index.js","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider as NextThemesProvider } from \"next-themes\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Re-exports the `ThemeProvider` from `next-themes` with sensible defaults.\n * This component must be used in a Client Component context.\n */\nexport function ThemeProvider({ children, ...props }: ThemeProviderProps) {\n return (\n <NextThemesProvider\n attribute=\"class\"\n defaultTheme=\"system\"\n enableSystem\n disableTransitionOnChange\n {...props}\n >\n {children}\n </NextThemesProvider>\n )\n}","\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider } from \"./theme-provider\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Client-only theme provider wrapper\n * This component ensures theme functionality only runs on the client side\n * without using next/dynamic which causes Server Component issues\n */\nexport function ClientThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n // During SSR or before mounting, render children without theme provider\n if (!mounted) {\n return <>{children}</>;\n }\n\n // Once mounted, render with theme provider\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}\n\n/**\n * Client-only theme toggle wrapper\n * This component ensures theme toggle only renders on the client side\n * and provides a safe fallback for Server Components\n */\nexport function ClientThemeToggle(props: any) {\n const [mounted, setMounted] = React.useState(false);\n const [isDark, setIsDark] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n // Check current theme\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const currentTheme = savedTheme || (systemPrefersDark ? 'dark' : 'light');\n setIsDark(currentTheme === 'dark');\n }\n }, []);\n\n const toggleTheme = () => {\n if (typeof window !== 'undefined') {\n const newTheme = isDark ? 'light' : 'dark';\n localStorage.setItem('theme', newTheme);\n document.documentElement.classList.toggle('dark', newTheme === 'dark');\n setIsDark(newTheme === 'dark');\n }\n };\n\n // During SSR or before mounting, render a placeholder\n if (!mounted) {\n return (\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n onClick={toggleTheme}\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n {isDark ? (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n ) : (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\" />\n </svg>\n )}\n </button>\n );\n} ","\"use client\"\n\nimport * as React from \"react\"\n\n/**\n * Server-safe theme hook that can be used in Server Components\n * Returns default theme values without accessing client-side APIs\n */\nexport function useThemeServer() {\n return {\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n };\n}\n\n/**\n * @deprecated Use ThemeProvider from './theme-provider' instead\n * This component is kept for backward compatibility but is no longer needed\n */\nexport function ThemeContextProvider({ \n children \n}: { \n children: React.ReactNode \n}) {\n // This is now a no-op wrapper for backward compatibility\n return <>{children}</>;\n}\n\n/**\n * @deprecated Use useTheme from next-themes directly or use the ThemeProvider\n * This hook is kept for backward compatibility but is no longer needed\n */\nexport function useTheme() {\n // Import next-themes dynamically to avoid SSR issues\n const [themeData, setThemeData] = React.useState({\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n });\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only run on client side\n if (typeof window === 'undefined') return;\n\n // Import next-themes and use it properly\n import('next-themes').then((nextThemes) => {\n // Create a simple theme manager that doesn't violate hook rules\n const themeManager = {\n getTheme: () => {\n // Get theme from localStorage or system preference\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n if (savedTheme) return savedTheme;\n \n // Check system preference\n if (window.matchMedia('(prefers-color-scheme: dark)').matches) {\n return 'dark';\n }\n }\n return 'light';\n },\n setTheme: (theme: string) => {\n if (typeof window !== 'undefined') {\n localStorage.setItem('theme', theme);\n document.documentElement.classList.toggle('dark', theme === 'dark');\n // Trigger a re-render\n setThemeData(prev => ({\n ...prev,\n theme,\n resolvedTheme: theme,\n isDark: theme === 'dark'\n }));\n }\n }\n };\n\n const currentTheme = themeManager.getTheme();\n const isDark = currentTheme === 'dark';\n \n setThemeData({\n theme: currentTheme,\n setTheme: themeManager.setTheme,\n resolvedTheme: currentTheme,\n isDark,\n });\n setMounted(true);\n });\n }, []);\n\n return themeData;\n}"]}
|
package/dist/themes/index.mjs
CHANGED
@@ -1,24 +1,11 @@
|
|
1
|
-
import
|
1
|
+
import { ThemeProvider as ThemeProvider$1 } from 'next-themes';
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
3
|
+
import * as React from 'react';
|
3
4
|
|
4
5
|
// src/themes/theme-provider.tsx
|
5
|
-
function ThemeProvider({
|
6
|
-
children,
|
7
|
-
...props
|
8
|
-
}) {
|
9
|
-
const [NextThemesProvider, setNextThemesProvider] = React.useState(void 0);
|
10
|
-
const [mounted, setMounted] = React.useState(false);
|
11
|
-
React.useEffect(() => {
|
12
|
-
import('next-themes').then(({ ThemeProvider: Provider }) => {
|
13
|
-
setNextThemesProvider(() => Provider);
|
14
|
-
setMounted(true);
|
15
|
-
});
|
16
|
-
}, []);
|
17
|
-
if (!mounted || !NextThemesProvider) {
|
18
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
19
|
-
}
|
6
|
+
function ThemeProvider({ children, ...props }) {
|
20
7
|
return /* @__PURE__ */ jsx(
|
21
|
-
|
8
|
+
ThemeProvider$1,
|
22
9
|
{
|
23
10
|
attribute: "class",
|
24
11
|
defaultTheme: "system",
|
@@ -29,19 +16,6 @@ function ThemeProvider({
|
|
29
16
|
}
|
30
17
|
);
|
31
18
|
}
|
32
|
-
function ThemeProviderNoSSR({
|
33
|
-
children,
|
34
|
-
...props
|
35
|
-
}) {
|
36
|
-
const [mounted, setMounted] = React.useState(false);
|
37
|
-
React.useEffect(() => {
|
38
|
-
setMounted(true);
|
39
|
-
}, []);
|
40
|
-
if (!mounted) {
|
41
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
42
|
-
}
|
43
|
-
return /* @__PURE__ */ jsx(ThemeProvider, { ...props, children });
|
44
|
-
}
|
45
19
|
function ClientThemeProvider({
|
46
20
|
children,
|
47
21
|
...props
|
@@ -168,6 +142,6 @@ function useThemeServer() {
|
|
168
142
|
};
|
169
143
|
}
|
170
144
|
|
171
|
-
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider,
|
145
|
+
export { ClientThemeProvider, ClientThemeToggle, ThemeProvider, useThemeServer };
|
172
146
|
//# sourceMappingURL=index.mjs.map
|
173
147
|
//# sourceMappingURL=index.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/themes/theme-provider.tsx","../../src/themes/client-wrapper.tsx","../../src/themes/theme-context.tsx"],"names":["React2","jsx","Fragment"],"mappings":";;;;AAcO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAuB;AACrB,EA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CAAA,EAAE,UAAA,EAAW,CAAA;AAAA,4BACnBA,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,uBAAA,EAAwB,CAAA;AAAA,4BAChCA,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,uBAAA,EAAwB;AAAA;AAAA;AAAA,0BAGlCA,GAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,IAAA;AAAA,UACN,MAAA,EAAO,IAAA;AAAA,UACP,OAAA,EAAQ,WAAA;AAAA,UACR,IAAA,EAAK,MAAA;AAAA,UACL,MAAA,EAAO,cAAA;AAAA,UACP,WAAA,EAAY,GAAA;AAAA,UACZ,aAAA,EAAc,OAAA;AAAA,UACd,cAAA,EAAe,OAAA;AAAA,UAEf,QAAA,kBAAAA,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,oCAAA,EAAqC;AAAA;AAAA;AAC/C;AAAA,GAEJ;AAEJ;ACrIO,SAAS,cAAA,GAAiB;AAC/B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,QAAA;AAAA,IACP,QAAA,EAAU,CAAC,KAAA,KAAkB;AAAA,IAAC,CAAA;AAAA,IAC9B,aAAA,EAAe,OAAA;AAAA,IACf,MAAA,EAAQ;AAAA,GACV;AACF","file":"index.mjs","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * ThemeProvider component for handling theme state\n * \n * This wraps the next-themes provider with sensible defaults\n * for handling light/dark themes and system preferences\n * \n * IMPORTANT: This component must be used in a Client Component context.\n * For Server Components, use the NoSSR wrapper or dynamic imports.\n */\nexport function ThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [NextThemesProvider, setNextThemesProvider] = React.useState<any>(undefined);\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only import next-themes on the client side\n import('next-themes').then(({ ThemeProvider: Provider }) => {\n setNextThemesProvider(() => Provider);\n setMounted(true);\n });\n }, []);\n\n // Return children without theme provider during SSR or before mounting\n if (!mounted || !NextThemesProvider) {\n return <>{children}</>;\n }\n\n return (\n <NextThemesProvider\n attribute=\"class\"\n defaultTheme=\"system\"\n enableSystem\n disableTransitionOnChange\n {...props}\n >\n {children}\n </NextThemesProvider>\n )\n}\n\n/**\n * NoSSR wrapper for theme provider to prevent SSR issues\n * Use this when you need to ensure the theme provider only renders on the client\n */\nexport function ThemeProviderNoSSR({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n if (!mounted) {\n return <>{children}</>;\n }\n\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}","\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider } from \"./theme-provider\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Client-only theme provider wrapper\n * This component ensures theme functionality only runs on the client side\n * without using next/dynamic which causes Server Component issues\n */\nexport function ClientThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n // During SSR or before mounting, render children without theme provider\n if (!mounted) {\n return <>{children}</>;\n }\n\n // Once mounted, render with theme provider\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}\n\n/**\n * Client-only theme toggle wrapper\n * This component ensures theme toggle only renders on the client side\n * and provides a safe fallback for Server Components\n */\nexport function ClientThemeToggle(props: any) {\n const [mounted, setMounted] = React.useState(false);\n const [isDark, setIsDark] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n // Check current theme\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const currentTheme = savedTheme || (systemPrefersDark ? 'dark' : 'light');\n setIsDark(currentTheme === 'dark');\n }\n }, []);\n\n const toggleTheme = () => {\n if (typeof window !== 'undefined') {\n const newTheme = isDark ? 'light' : 'dark';\n localStorage.setItem('theme', newTheme);\n document.documentElement.classList.toggle('dark', newTheme === 'dark');\n setIsDark(newTheme === 'dark');\n }\n };\n\n // During SSR or before mounting, render a placeholder\n if (!mounted) {\n return (\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n onClick={toggleTheme}\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n {isDark ? (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n ) : (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\" />\n </svg>\n )}\n </button>\n );\n} ","\"use client\"\n\nimport * as React from \"react\"\n\n/**\n * Server-safe theme hook that can be used in Server Components\n * Returns default theme values without accessing client-side APIs\n */\nexport function useThemeServer() {\n return {\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n };\n}\n\n/**\n * @deprecated Use ThemeProvider from './theme-provider' instead\n * This component is kept for backward compatibility but is no longer needed\n */\nexport function ThemeContextProvider({ \n children \n}: { \n children: React.ReactNode \n}) {\n // This is now a no-op wrapper for backward compatibility\n return <>{children}</>;\n}\n\n/**\n * @deprecated Use useTheme from next-themes directly or use the ThemeProvider\n * This hook is kept for backward compatibility but is no longer needed\n */\nexport function useTheme() {\n // Import next-themes dynamically to avoid SSR issues\n const [themeData, setThemeData] = React.useState({\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n });\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only run on client side\n if (typeof window === 'undefined') return;\n\n // Import next-themes and use it properly\n import('next-themes').then((nextThemes) => {\n // Create a simple theme manager that doesn't violate hook rules\n const themeManager = {\n getTheme: () => {\n // Get theme from localStorage or system preference\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n if (savedTheme) return savedTheme;\n \n // Check system preference\n if (window.matchMedia('(prefers-color-scheme: dark)').matches) {\n return 'dark';\n }\n }\n return 'light';\n },\n setTheme: (theme: string) => {\n if (typeof window !== 'undefined') {\n localStorage.setItem('theme', theme);\n document.documentElement.classList.toggle('dark', theme === 'dark');\n // Trigger a re-render\n setThemeData(prev => ({\n ...prev,\n theme,\n resolvedTheme: theme,\n isDark: theme === 'dark'\n }));\n }\n }\n };\n\n const currentTheme = themeManager.getTheme();\n const isDark = currentTheme === 'dark';\n \n setThemeData({\n theme: currentTheme,\n setTheme: themeManager.setTheme,\n resolvedTheme: currentTheme,\n isDark,\n });\n setMounted(true);\n });\n }, []);\n\n return themeData;\n}"]}
|
1
|
+
{"version":3,"sources":["../../src/themes/theme-provider.tsx","../../src/themes/client-wrapper.tsx","../../src/themes/theme-context.tsx"],"names":["NextThemesProvider","jsx"],"mappings":";;;;;AAUO,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,GAAG,OAAM,EAAuB;AACxE,EAAA,uBACE,GAAA;AAAA,IAACA,eAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,OAAA;AAAA,MACV,YAAA,EAAa,QAAA;AAAA,MACb,YAAA,EAAY,IAAA;AAAA,MACZ,yBAAA,EAAyB,IAAA;AAAA,MACxB,GAAG,KAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ;ACXO,SAAS,mBAAA,CAAoB;AAAA,EAClC,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAU,eAAS,KAAK,CAAA;AAElD,EAAM,gBAAU,MAAM;AACpB,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,EAAE,CAAA;AAGL,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,uBAAOC,GAAAA,CAAA,QAAA,EAAA,EAAG,QAAA,EAAS,CAAA;AAAA,EACrB;AAGA,EAAA,uBACEA,GAAAA,CAAC,aAAA,EAAA,EAAe,GAAG,OAChB,QAAA,EACH,CAAA;AAEJ;AAOO,SAAS,kBAAkB,KAAA,EAAY;AAC5C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAU,eAAS,KAAK,CAAA;AAClD,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GA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E,oCAAA,EAAqC;AAAA;AAAA;AAC/C;AAAA,GAEJ;AAEJ;ACrIO,SAAS,cAAA,GAAiB;AAC/B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,QAAA;AAAA,IACP,QAAA,EAAU,CAAC,KAAA,KAAkB;AAAA,IAAC,CAAA;AAAA,IAC9B,aAAA,EAAe,OAAA;AAAA,IACf,MAAA,EAAQ;AAAA,GACV;AACF","file":"index.mjs","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider as NextThemesProvider } from \"next-themes\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Re-exports the `ThemeProvider` from `next-themes` with sensible defaults.\n * This component must be used in a Client Component context.\n */\nexport function ThemeProvider({ children, ...props }: ThemeProviderProps) {\n return (\n <NextThemesProvider\n attribute=\"class\"\n defaultTheme=\"system\"\n enableSystem\n disableTransitionOnChange\n {...props}\n >\n {children}\n </NextThemesProvider>\n )\n}","\"use client\"\n\nimport * as React from \"react\"\nimport { ThemeProvider } from \"./theme-provider\"\nimport type { ThemeProviderProps } from \"next-themes/dist/types\"\n\n/**\n * Client-only theme provider wrapper\n * This component ensures theme functionality only runs on the client side\n * without using next/dynamic which causes Server Component issues\n */\nexport function ClientThemeProvider({ \n children, \n ...props \n}: ThemeProviderProps) {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n }, []);\n\n // During SSR or before mounting, render children without theme provider\n if (!mounted) {\n return <>{children}</>;\n }\n\n // Once mounted, render with theme provider\n return (\n <ThemeProvider {...props}>\n {children}\n </ThemeProvider>\n );\n}\n\n/**\n * Client-only theme toggle wrapper\n * This component ensures theme toggle only renders on the client side\n * and provides a safe fallback for Server Components\n */\nexport function ClientThemeToggle(props: any) {\n const [mounted, setMounted] = React.useState(false);\n const [isDark, setIsDark] = React.useState(false);\n\n React.useEffect(() => {\n setMounted(true);\n // Check current theme\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;\n const currentTheme = savedTheme || (systemPrefersDark ? 'dark' : 'light');\n setIsDark(currentTheme === 'dark');\n }\n }, []);\n\n const toggleTheme = () => {\n if (typeof window !== 'undefined') {\n const newTheme = isDark ? 'light' : 'dark';\n localStorage.setItem('theme', newTheme);\n document.documentElement.classList.toggle('dark', newTheme === 'dark');\n setIsDark(newTheme === 'dark');\n }\n };\n\n // During SSR or before mounting, render a placeholder\n if (!mounted) {\n return (\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n onClick={toggleTheme}\n className=\"inline-flex items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 w-10\"\n aria-label=\"Toggle theme\"\n {...props}\n >\n {isDark ? (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2\" />\n <path d=\"M12 20v2\" />\n <path d=\"m4.93 4.93 1.41 1.41\" />\n <path d=\"m17.66 17.66 1.41 1.41\" />\n <path d=\"M2 12h2\" />\n <path d=\"M20 12h2\" />\n <path d=\"m6.34 17.66-1.41 1.41\" />\n <path d=\"m19.07 4.93-1.41 1.41\" />\n </svg>\n ) : (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\" />\n </svg>\n )}\n </button>\n );\n} ","\"use client\"\n\nimport * as React from \"react\"\n\n/**\n * Server-safe theme hook that can be used in Server Components\n * Returns default theme values without accessing client-side APIs\n */\nexport function useThemeServer() {\n return {\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n };\n}\n\n/**\n * @deprecated Use ThemeProvider from './theme-provider' instead\n * This component is kept for backward compatibility but is no longer needed\n */\nexport function ThemeContextProvider({ \n children \n}: { \n children: React.ReactNode \n}) {\n // This is now a no-op wrapper for backward compatibility\n return <>{children}</>;\n}\n\n/**\n * @deprecated Use useTheme from next-themes directly or use the ThemeProvider\n * This hook is kept for backward compatibility but is no longer needed\n */\nexport function useTheme() {\n // Import next-themes dynamically to avoid SSR issues\n const [themeData, setThemeData] = React.useState({\n theme: \"system\",\n setTheme: (theme: string) => {},\n resolvedTheme: \"light\",\n isDark: false,\n });\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // Only run on client side\n if (typeof window === 'undefined') return;\n\n // Import next-themes and use it properly\n import('next-themes').then((nextThemes) => {\n // Create a simple theme manager that doesn't violate hook rules\n const themeManager = {\n getTheme: () => {\n // Get theme from localStorage or system preference\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem('theme');\n if (savedTheme) return savedTheme;\n \n // Check system preference\n if (window.matchMedia('(prefers-color-scheme: dark)').matches) {\n return 'dark';\n }\n }\n return 'light';\n },\n setTheme: (theme: string) => {\n if (typeof window !== 'undefined') {\n localStorage.setItem('theme', theme);\n document.documentElement.classList.toggle('dark', theme === 'dark');\n // Trigger a re-render\n setThemeData(prev => ({\n ...prev,\n theme,\n resolvedTheme: theme,\n isDark: theme === 'dark'\n }));\n }\n }\n };\n\n const currentTheme = themeManager.getTheme();\n const isDark = currentTheme === 'dark';\n \n setThemeData({\n theme: currentTheme,\n setTheme: themeManager.setTheme,\n resolvedTheme: currentTheme,\n isDark,\n });\n setMounted(true);\n });\n }, []);\n\n return themeData;\n}"]}
|