From 053d1a905ed6cef71151d168351f22b35ddca986 Mon Sep 17 00:00:00 2001 From: Olicorne <26625900+thiswillbeyourgithub@users.noreply.github.com> Date: Sun, 18 May 2025 20:45:32 +0200 Subject: fix(web): Switch to a tab view in small screens for bookmark previews * feat: Implement tabbed layout for bookmark preview content and details * feat: Enable swipe gesture to switch between content and details tabs * feat: add scroll-based tab bar hide/show functionality * fix: adjust tab bar layout to maintain content space when hidden * fix: bg-muted was stopping midway in the background * fix: disable mouse tracking for swipe detection in BookmarkPreview * fix: improve scroll behavior to prevent glitchy tab bar animation * Update apps/web/components/dashboard/preview/BookmarkPreview.tsx Co-authored-by: xuatz * Update apps/web/components/dashboard/preview/BookmarkPreview.tsx Co-authored-by: xuatz * feat: add responsive layout with tabs and swipe for BookmarkPreview * Remove react swipe, scroll handlers and do screen detection using media queries * Revert the grey background for the main content * remove react-swip from the package.json * more fixes * Fix the black area under the tab bar --------- Co-authored-by: xuatz Co-authored-by: Mohamed Bassem --- .../dashboard/preview/BookmarkPreview.tsx | 116 ++++++++++++++------- 1 file changed, 80 insertions(+), 36 deletions(-) (limited to 'apps/web/components/dashboard/preview') diff --git a/apps/web/components/dashboard/preview/BookmarkPreview.tsx b/apps/web/components/dashboard/preview/BookmarkPreview.tsx index df09f687..c09bc949 100644 --- a/apps/web/components/dashboard/preview/BookmarkPreview.tsx +++ b/apps/web/components/dashboard/preview/BookmarkPreview.tsx @@ -1,11 +1,12 @@ "use client"; -import React from "react"; +import { useState } from "react"; import Link from "next/link"; import { BookmarkTagsEditor } from "@/components/dashboard/bookmarks/BookmarkTagsEditor"; import { FullPageSpinner } from "@/components/ui/full-page-spinner"; import { Separator } from "@/components/ui/separator"; import { Skeleton } from "@/components/ui/skeleton"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Tooltip, TooltipContent, @@ -68,6 +69,8 @@ export default function BookmarkPreview({ initialData?: ZBookmark; }) { const { t } = useTranslation(); + const [activeTab, setActiveTab] = useState("content"); + const { data: bookmark } = api.bookmarks.getBookmark.useQuery( { bookmarkId, @@ -111,45 +114,86 @@ export default function BookmarkPreview({ const sourceUrl = getSourceUrl(bookmark); const title = getBookmarkTitle(bookmark); - return ( -
-
- {isBookmarkStillCrawling(bookmark) ? : content} -
-
-
-
-

- {title === undefined || title === "" ? "Untitled" : title} -

-
- {sourceUrl && ( - - {t("preview.view_original")} - - - )} - + // Common content for both layouts + const contentSection = isBookmarkStillCrawling(bookmark) ? ( + + ) : ( + content + ); + + const detailsSection = ( +
+
+
+

+ {title === undefined || title === "" ? "Untitled" : title} +

+ {sourceUrl && ( + + {t("preview.view_original")} + + + )} + +
+ + +
+

{t("common.tags")}

+ +
+
+

{t("common.note")}

+ +
+ + + +
+ ); - - -
-

{t("common.tags")}

- + return ( + <> + {/* Render original layout for wide screens */} +
+
+ {contentSection}
-
-

{t("common.note")}

- +
+ {detailsSection}
- - -
-
+ + {/* Render tabbed layout for narrow/vertical screens */} + + + {t("preview.tabs.content")} + {t("preview.tabs.details")} + + + {contentSection} + + + {detailsSection} + + + ); } -- cgit v1.2.3-70-g09d2