From 922d321e88667ac2003379cd013efb82b8561ae7 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 14 Jul 2026 10:05:08 +0300 Subject: [PATCH] feat: make link preview card slightly larger --- components/LinkPreviewCard.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/components/LinkPreviewCard.tsx b/components/LinkPreviewCard.tsx index 0c5599f..5a36788 100644 --- a/components/LinkPreviewCard.tsx +++ b/components/LinkPreviewCard.tsx @@ -7,7 +7,13 @@ export interface PreviewData { title: string | null; description: string | null; image?: string | null; - // url: string; +} + +function truncate(desc: string, maxLength = 300) { + if (desc.length <= maxLength) return desc; + const cut = desc.slice(0, maxLength); + const lastSpace = cut.lastIndexOf(" "); + return `${cut.slice(0, lastSpace > 0 ? lastSpace : maxLength)}…`; } export function LinkPreviewCard({ @@ -141,7 +147,7 @@ export function LinkPreviewCard({ animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: 4 }} transition={{ duration: 0.15 }} - className="fixed z-50 w-80 p-4 overflow-hidden" + className="fixed z-50 w-[22rem] p-4 overflow-hidden" style={{ top: pos.top, left: pos.left, @@ -187,11 +193,11 @@ export function LinkPreviewCard({ loading="lazy" referrerPolicy="no-referrer" onError={() => setImgError(true)} - className="absolute top-0 right-0 w-14 h-14 object-cover" + className="float-right ml-3 w-[4.5rem] h-[4.5rem] object-cover shrink-0" style={{ border: `1px solid ${indigo(0.12)}` }} /> )} -
+
- {data.description} + {truncate(data.description)}

)}