From 8f0e9b182e971dff98b18c707d3eb6238abf286e Mon Sep 17 00:00:00 2001
From: Md Saban <45597394+mdsaban@users.noreply.github.com>
Date: Sun, 23 Jun 2024 17:08:34 +0530
Subject: ui(web): move layout selector to main screen (#252)
---
apps/web/components/dashboard/ChangeLayout.tsx | 50 ++++++++++++++++
.../components/dashboard/bookmarks/Bookmarks.tsx | 2 +-
apps/web/components/dashboard/bookmarks/TopNav.tsx | 5 --
apps/web/components/dashboard/lists/ListHeader.tsx | 16 +++--
.../dashboard/sidebar/SidebarProfileOptions.tsx | 68 +---------------------
5 files changed, 62 insertions(+), 79 deletions(-)
create mode 100644 apps/web/components/dashboard/ChangeLayout.tsx
delete mode 100644 apps/web/components/dashboard/bookmarks/TopNav.tsx
(limited to 'apps/web/components/dashboard')
diff --git a/apps/web/components/dashboard/ChangeLayout.tsx b/apps/web/components/dashboard/ChangeLayout.tsx
new file mode 100644
index 00000000..59acb6bd
--- /dev/null
+++ b/apps/web/components/dashboard/ChangeLayout.tsx
@@ -0,0 +1,50 @@
+"use client";
+
+import React from "react";
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { useBookmarkLayout } from "@/lib/userLocalSettings/bookmarksLayout";
+import { updateBookmarksLayout } from "@/lib/userLocalSettings/userLocalSettings";
+import { Check, LayoutDashboard, LayoutGrid, LayoutList } from "lucide-react";
+
+type LayoutType = "masonry" | "grid" | "list";
+
+const iconMap = {
+ masonry: LayoutDashboard,
+ grid: LayoutGrid,
+ list: LayoutList,
+};
+
+export default function SidebarProfileOptions() {
+ const layout = useBookmarkLayout();
+
+ return (
+
+
+
+
+
+ {Object.keys(iconMap).map((key) => (
+ await updateBookmarksLayout(key as LayoutType)}
+ >
+
+ {React.createElement(iconMap[key as LayoutType], { size: 18 })}
+ {key}
+
+ {layout == key && }
+
+ ))}
+
+
+ );
+}
diff --git a/apps/web/components/dashboard/bookmarks/Bookmarks.tsx b/apps/web/components/dashboard/bookmarks/Bookmarks.tsx
index 6a9266b9..5729e846 100644
--- a/apps/web/components/dashboard/bookmarks/Bookmarks.tsx
+++ b/apps/web/components/dashboard/bookmarks/Bookmarks.tsx
@@ -14,7 +14,7 @@ export default async function Bookmarks({
showEditorCard = false,
}: {
query: ZGetBookmarksRequest;
- header: React.ReactNode;
+ header?: React.ReactNode;
showDivider?: boolean;
showEditorCard?: boolean;
}) {
diff --git a/apps/web/components/dashboard/bookmarks/TopNav.tsx b/apps/web/components/dashboard/bookmarks/TopNav.tsx
deleted file mode 100644
index 189c9d5c..00000000
--- a/apps/web/components/dashboard/bookmarks/TopNav.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { SearchInput } from "../search/SearchInput";
-
-export default function TopNav() {
- return ;
-}
diff --git a/apps/web/components/dashboard/lists/ListHeader.tsx b/apps/web/components/dashboard/lists/ListHeader.tsx
index 6796d484..2f69203e 100644
--- a/apps/web/components/dashboard/lists/ListHeader.tsx
+++ b/apps/web/components/dashboard/lists/ListHeader.tsx
@@ -1,6 +1,7 @@
"use client";
import { useRouter } from "next/navigation";
+import ChangeLayout from "@/components/dashboard/ChangeLayout";
import { Button } from "@/components/ui/button";
import { MoreHorizontal } from "lucide-react";
@@ -32,15 +33,18 @@ export default function ListHeader({
}
return (
-
+
{list.icon} {list.name}
-
-
-
+
+
+
+
+
+
);
}
diff --git a/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx b/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
index c2ae493a..af3f1548 100644
--- a/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
+++ b/apps/web/components/dashboard/sidebar/SidebarProfileOptions.tsx
@@ -7,69 +7,12 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuSub,
- DropdownMenuSubContent,
- DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import { useBookmarkLayout } from "@/lib/userLocalSettings/bookmarksLayout";
-import { updateBookmarksLayout } from "@/lib/userLocalSettings/userLocalSettings";
-import {
- Check,
- LayoutDashboard,
- LayoutGrid,
- LayoutList,
- LayoutPanelLeft,
- LogOut,
- Moon,
- MoreHorizontal,
- Paintbrush,
- Sun,
-} from "lucide-react";
+import { LogOut, Moon, MoreHorizontal, Paintbrush, Sun } from "lucide-react";
import { signOut } from "next-auth/react";
import { useTheme } from "next-themes";
-function BookmarkLayoutSelector() {
- const layout = useBookmarkLayout();
-
- const checkedComp =
;
-
- return (
- <>
-
await updateBookmarksLayout("masonry")}
- >
-
-
- Masonry
-
- {layout == "masonry" && checkedComp}
-
-
await updateBookmarksLayout("grid")}
- >
-
-
- Grid
-
- {layout == "grid" && checkedComp}
-
-
await updateBookmarksLayout("list")}
- >
-
-
- List
-
- {layout == "list" && checkedComp}
-
- >
- );
-}
-
function DarkModeToggle() {
const { theme } = useTheme();
@@ -109,15 +52,6 @@ export default function SidebarProfileOptions() {
-
-
-
- Layout
-
-
-
-
-
signOut({
--
cgit v1.2.3-70-g09d2