diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-09 16:32:41 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-04-09 16:32:41 +0100 |
| commit | 5ab6c3304b4a2d055767b8195fac9c9eec776d16 (patch) | |
| tree | 19abe22d6fcf6f3279e9fc6494e3d4263091b805 /apps/web/components/theme-provider.tsx | |
| parent | cae543c627861d473a777bf4903d722ff3da5074 (diff) | |
| download | karakeep-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.tsx | 11 |
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"); + } +} |
