From 5ab6c3304b4a2d055767b8195fac9c9eec776d16 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Tue, 9 Apr 2024 16:32:41 +0100
Subject: fix(web): Fix the toggle theme button allowing clicks from anywhere
 in the dropdown item

---
 apps/web/components/theme-provider.tsx | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'apps/web/components/theme-provider.tsx')

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");
+  }
+}
-- 
cgit v1.2.3-70-g09d2

