From 8a1309536b76ba86872ca2e78aa695d9fd80c8cc Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 5 Oct 2024 20:08:50 +0000 Subject: feature: Allow attaching custom banners to notes. Fixes: #106 --- apps/web/components/dashboard/bookmarks/TextCard.tsx | 18 +++++++++++++++++- .../web/components/dashboard/preview/AttachmentBox.tsx | 12 +++++++++--- .../dashboard/preview/TextContentSection.tsx | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) (limited to 'apps/web/components/dashboard') diff --git a/apps/web/components/dashboard/bookmarks/TextCard.tsx b/apps/web/components/dashboard/bookmarks/TextCard.tsx index 9d6c1df1..14a4f905 100644 --- a/apps/web/components/dashboard/bookmarks/TextCard.tsx +++ b/apps/web/components/dashboard/bookmarks/TextCard.tsx @@ -1,10 +1,13 @@ "use client"; +import Image from "next/image"; +import Link from "next/link"; import { MarkdownComponent } from "@/components/ui/markdown-component"; import { bookmarkLayoutSwitch } from "@/lib/userLocalSettings/bookmarksLayout"; import { cn } from "@/lib/utils"; import type { ZBookmarkTypeText } from "@hoarder/shared/types/bookmarks"; +import { getAssetUrl } from "@hoarder/shared-react/utils/assetUtils"; import { getSourceUrl } from "@hoarder/shared-react/utils/bookmarkUtils"; import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard"; @@ -19,6 +22,8 @@ export default function TextCard({ }) { const bookmarkedText = bookmark.content; + const banner = bookmark.assets.find((a) => a.assetType == "bannerImage"); + return ( <> + + card banner + + + ) : (
a.assetType.localeCompare(b.assetType)); + + if (bookmark.content.type == BookmarkTypes.ASSET) { + // Currently, we don't allow attaching assets to assets types. return null; } - bookmark.assets.sort((a, b) => a.assetType.localeCompare(b.assetType)); return ( diff --git a/apps/web/components/dashboard/preview/TextContentSection.tsx b/apps/web/components/dashboard/preview/TextContentSection.tsx index 76cb23ea..327436c6 100644 --- a/apps/web/components/dashboard/preview/TextContentSection.tsx +++ b/apps/web/components/dashboard/preview/TextContentSection.tsx @@ -1,14 +1,32 @@ +import Image from "next/image"; import { MarkdownComponent } from "@/components/ui/markdown-component"; import { ScrollArea } from "@radix-ui/react-scroll-area"; +import { getAssetUrl } from "@hoarder/shared-react/utils/assetUtils"; import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; export function TextContentSection({ bookmark }: { bookmark: ZBookmark }) { if (bookmark.content.type != BookmarkTypes.TEXT) { throw new Error("Invalid content type"); } + const banner = bookmark.assets.find( + (asset) => asset.assetType == "bannerImage", + ); + return ( + {banner && ( +
+ banner +
+ )} {bookmark.content.text}
); -- cgit v1.2.3-70-g09d2