aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/sidebar
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/dashboard/sidebar
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/dashboard/sidebar')
-rw-r--r--apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx b/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
index bf56b805..3fe4d52f 100644
--- a/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
+++ b/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
@@ -1,5 +1,6 @@
"use client";
+import { useToggleTheme } from "@/components/theme-provider";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
@@ -13,28 +14,29 @@ import { signOut } from "next-auth/react";
import { useTheme } from "next-themes";
function DarkModeToggle() {
- const { theme, setTheme } = useTheme();
+ const { theme } = useTheme();
let comp;
if (theme == "dark") {
comp = (
- <button onClick={() => setTheme("light")}>
+ <span>
<Sun className="size-4" />
<p>Light Mode</p>
- </button>
+ </span>
);
} else {
comp = (
- <button onClick={() => setTheme("dark")}>
+ <span>
<Moon className="size-4" />
<p>Dark Mode</p>
- </button>
+ </span>
);
}
return <Slot className="flex flex-row gap-2">{comp}</Slot>;
}
export default function SidebarProfileOptions() {
+ const toggleTheme = useToggleTheme();
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -43,7 +45,7 @@ export default function SidebarProfileOptions() {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-fit">
- <DropdownMenuItem>
+ <DropdownMenuItem onClick={toggleTheme}>
<DarkModeToggle />
</DropdownMenuItem>
<DropdownMenuItem