aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/theme-provider.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-04-09 16:32:41 +0100
committerMohamedBassem <me@mbassem.com>2024-04-09 16:32:41 +0100
commit5ab6c3304b4a2d055767b8195fac9c9eec776d16 (patch)
tree19abe22d6fcf6f3279e9fc6494e3d4263091b805 /apps/web/components/theme-provider.tsx
parentcae543c627861d473a777bf4903d722ff3da5074 (diff)
downloadkarakeep-5ab6c3304b4a2d055767b8195fac9c9eec776d16.tar.zst
fix(web): Fix the toggle theme button allowing clicks from anywhere in the dropdown item
Diffstat (limited to 'apps/web/components/theme-provider.tsx')
-rw-r--r--apps/web/components/theme-provider.tsx11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/web/components/theme-provider.tsx b/apps/web/components/theme-provider.tsx
index 8efcd93b..737e1356 100644
--- a/apps/web/components/theme-provider.tsx
+++ b/apps/web/components/theme-provider.tsx
@@ -2,8 +2,17 @@
import type { ThemeProviderProps } from "next-themes/dist/types";
import * as React from "react";
-import { ThemeProvider as NextThemesProvider } from "next-themes";
+import { ThemeProvider as NextThemesProvider, useTheme } from "next-themes";
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
}
+
+export function useToggleTheme() {
+ const { theme, setTheme } = useTheme();
+ if (theme == "dark") {
+ return () => setTheme("light");
+ } else {
+ return () => setTheme("dark");
+ }
+}