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/app/dashboard/archive/page.tsx | 26 ++++++--- apps/web/app/dashboard/bookmarks/page.tsx | 16 +++-- apps/web/app/dashboard/favourites/page.tsx | 8 ++- apps/web/app/dashboard/search/page.tsx | 8 ++- 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 +--------------------- 9 files changed, 99 insertions(+), 100 deletions(-) create mode 100644 apps/web/components/dashboard/ChangeLayout.tsx delete mode 100644 apps/web/components/dashboard/bookmarks/TopNav.tsx diff --git a/apps/web/app/dashboard/archive/page.tsx b/apps/web/app/dashboard/archive/page.tsx index 26ec45e9..a5326205 100644 --- a/apps/web/app/dashboard/archive/page.tsx +++ b/apps/web/app/dashboard/archive/page.tsx @@ -1,17 +1,27 @@ import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; +import ChangeLayout from "@/components/dashboard/ChangeLayout"; import InfoTooltip from "@/components/ui/info-tooltip"; +function header() { + return ( +
+
+

🗄️ Archive

+ +

Archived bookmarks won't appear in the homepage

+
+
+
+ +
+
+ ); +} + export default async function ArchivedBookmarkPage() { return ( -

🗄️ Archive

- -

Archived bookmarks won't appear in the homepage

-
- - } + header={header()} query={{ archived: true }} showDivider={true} showEditorCard={true} diff --git a/apps/web/app/dashboard/bookmarks/page.tsx b/apps/web/app/dashboard/bookmarks/page.tsx index 90f4f2cb..47392ad5 100644 --- a/apps/web/app/dashboard/bookmarks/page.tsx +++ b/apps/web/app/dashboard/bookmarks/page.tsx @@ -1,19 +1,17 @@ import React from "react"; import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; -import TopNav from "@/components/dashboard/bookmarks/TopNav"; -import { Separator } from "@/components/ui/separator"; +import ChangeLayout from "@/components/dashboard/ChangeLayout"; +import { SearchInput } from "@/components/dashboard/search/SearchInput"; export default async function BookmarksPage() { return (
- - +
+ + +
- Bookmarks

} - query={{ archived: false }} - showEditorCard={true} - /> +
); diff --git a/apps/web/app/dashboard/favourites/page.tsx b/apps/web/app/dashboard/favourites/page.tsx index 423a8e69..fd39b90a 100644 --- a/apps/web/app/dashboard/favourites/page.tsx +++ b/apps/web/app/dashboard/favourites/page.tsx @@ -1,9 +1,15 @@ import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; +import ChangeLayout from "@/components/dashboard/ChangeLayout"; export default async function FavouritesBookmarkPage() { return ( ⭐️ Favourites

} + header={ +
+

⭐️ Favourites

+ +
+ } query={{ favourited: true }} showDivider={true} showEditorCard={true} diff --git a/apps/web/app/dashboard/search/page.tsx b/apps/web/app/dashboard/search/page.tsx index 8454acc5..11febca6 100644 --- a/apps/web/app/dashboard/search/page.tsx +++ b/apps/web/app/dashboard/search/page.tsx @@ -2,9 +2,9 @@ import { Suspense, useRef } from "react"; import BookmarksGrid from "@/components/dashboard/bookmarks/BookmarksGrid"; +import ChangeLayout from "@/components/dashboard/ChangeLayout"; import { SearchInput } from "@/components/dashboard/search/SearchInput"; import { FullPageSpinner } from "@/components/ui/full-page-spinner"; -import { Separator } from "@/components/ui/separator"; import { useBookmarkSearch } from "@/lib/hooks/bookmark-search"; function SearchComp() { @@ -15,8 +15,10 @@ function SearchComp() { return (
- - +
+ + +
{data ? ( ) : ( 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