From 47939a5409a0eb18b088c37b011ca6a3c4920746 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 15 Sep 2024 00:50:02 +0000 Subject: feature(web): Add a compact layout. Fixes #379 --- apps/web/components/dashboard/ChangeLayout.tsx | 9 +++- .../bookmarks/BookmarkLayoutAdaptingCard.tsx | 57 +++++++++++++++++++++- .../dashboard/bookmarks/BookmarksGrid.tsx | 1 + .../components/dashboard/bookmarks/EditorCard.tsx | 1 + .../components/dashboard/bookmarks/TextCard.tsx | 1 + apps/web/lib/userLocalSettings/types.ts | 2 +- 6 files changed, 68 insertions(+), 3 deletions(-) (limited to 'apps/web') diff --git a/apps/web/components/dashboard/ChangeLayout.tsx b/apps/web/components/dashboard/ChangeLayout.tsx index 7449bd2d..6ec38245 100644 --- a/apps/web/components/dashboard/ChangeLayout.tsx +++ b/apps/web/components/dashboard/ChangeLayout.tsx @@ -10,7 +10,13 @@ import { } 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"; +import { + Check, + LayoutDashboard, + LayoutGrid, + LayoutList, + List, +} from "lucide-react"; type LayoutType = "masonry" | "grid" | "list"; @@ -18,6 +24,7 @@ const iconMap = { masonry: LayoutDashboard, grid: LayoutGrid, list: LayoutList, + compact: List, }; export default function ChangeLayout() { diff --git a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx index f5891f40..e11e4295 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx @@ -1,5 +1,6 @@ import type { BookmarksLayoutTypes } from "@/lib/userLocalSettings/types"; import React, { useEffect, useState } from "react"; +import Image from "next/image"; import Link from "next/link"; import useBulkActionsStore from "@/lib/bulkActions"; import { @@ -8,11 +9,12 @@ import { } from "@/lib/userLocalSettings/bookmarksLayout"; import { cn } from "@/lib/utils"; import dayjs from "dayjs"; -import { Check } from "lucide-react"; +import { Check, Image as ImageIcon, NotebookPen } from "lucide-react"; import { useTheme } from "next-themes"; import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils"; +import { BookmarkTypes } from "@hoarder/shared/types/bookmarks"; import BookmarkActionBar from "./BookmarkActionBar"; import TagList from "./TagList"; @@ -187,6 +189,58 @@ function GridView({ ); } +function CompactView({ bookmark, title, footer, className }: Props) { + return ( +
+ +
+
+ {bookmark.content.type === BookmarkTypes.LINK && + bookmark.content.favicon && ( + favicon + )} + {bookmark.content.type === BookmarkTypes.TEXT && ( + + )} + {bookmark.content.type === BookmarkTypes.ASSET && ( + + )} + { +
+ {title ?? "Untitled"} +
+ } + {footer && ( +

•{footer}

+ )} +

+ + {dayjs(bookmark.createdAt).format("MMM DD")} + +
+ +
+
+ ); +} + export function BookmarkLayoutAdaptingCard(props: Props) { const layout = useBookmarkLayout(); @@ -194,5 +248,6 @@ export function BookmarkLayoutAdaptingCard(props: Props) { masonry: , grid: , list: , + compact: , }); } diff --git a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx index 540546fe..16c25850 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx @@ -80,6 +80,7 @@ export default function BookmarksGrid({ ), list:
{children}
, + compact:
{children}
, })} {hasNextPage && (
diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index 605fcf42..d1489b09 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -147,6 +147,7 @@ export default function EditorCard({ className }: { className?: string }) { grid: "h-96", masonry: "h-96", list: undefined, + compact: undefined, }); const handlePaste = async ( diff --git a/apps/web/components/dashboard/bookmarks/TextCard.tsx b/apps/web/components/dashboard/bookmarks/TextCard.tsx index 6fa2a1cf..9876d904 100644 --- a/apps/web/components/dashboard/bookmarks/TextCard.tsx +++ b/apps/web/components/dashboard/bookmarks/TextCard.tsx @@ -31,6 +31,7 @@ export default function TextCard({ bookmarkLayoutSwitch(layout, { grid: null, masonry: null, + compact: null, list: (
; export const zUserLocalSettings = z.object({ -- cgit v1.2.3-70-g09d2