From 724bfb8f2422da18e6ce30acb56f76f5166cd753 Mon Sep 17 00:00:00 2001 From: TerryM Date: Wed, 3 Jun 2026 08:33:29 +0800 Subject: [PATCH] fix(home): match Figma media pills for latest cards - Align latest-update media size pills to the Figma spec: 72x24 pill, black background, 24px gray icon cell, 10px label, and the exact small Figma cloud-download SVG. - For non-document latest cards, remove the duplicate footer download action so media cards only show per-media size/download pills plus the bookmark action, matching the Figma non-document card design. - Keep card heights flexible so content determines the final card height instead of locking to design mock heights. --- src/components/LatestUpdateCard.tsx | 141 ++++++++++++++++++---------- 1 file changed, 94 insertions(+), 47 deletions(-) diff --git a/src/components/LatestUpdateCard.tsx b/src/components/LatestUpdateCard.tsx index 7043f89..e901272 100644 --- a/src/components/LatestUpdateCard.tsx +++ b/src/components/LatestUpdateCard.tsx @@ -147,57 +147,112 @@ function FileCard({ post, att }: { post: Post; att: Attachment }) { ); } +function PillDownloadIcon() { + return ( + + ); +} + +function MediaSizeChip({ att }: { att: Attachment }) { + return ( +
+ + + + + {formatBytes(att.sizeBytes)} + +
+ ); +} + +function MediaTile({ + att, + showExtra, +}: { + att: Attachment; + showExtra?: number; +}) { + const src = attachmentPreview(att); + const isVideo = att.kind === "video" || att.mime.startsWith("video/"); + return ( +
+ {src ? ( + + ) : null} + + {isVideo ? ( +
+ + + +
+ ) : null} + {showExtra ? ( +
+ +{showExtra} +
+ ) : null} +
+ ); +} + function MediaGrid({ attachments }: { attachments: Attachment[] }) { const visible = attachments.slice(0, 4); const extra = Math.max(0, attachments.length - visible.length); - if (visible.length <= 1) { - const src = attachmentPreview(visible[0]); - return src ? ( - - ) : ( -
+ if (visible.length === 0) return
; + if (visible.length === 1) return ; + if (visible.length === 2) { + return ( +
+ {visible.map((att) => ( + + ))} +
+ ); + } + if (visible.length === 3) { + return ( +
+ +
+ + +
+
); } return (
{visible.map((att, index) => ( -
- - {extra > 0 && index === visible.length - 1 ? ( -
- +{extra} -
- ) : null} -
+ 0 && index === visible.length - 1 ? extra : 0} + /> ))}
); } -function MediaBadge({ att }: { att?: Attachment }) { - if (!att) return null; - return ( -
- - - - {formatBytes(att.sizeBytes)} -
- ); -} - function VisualCard({ post }: { post: Post }) { const { lang } = useI18n(); const att = post.attachments[0]; @@ -213,21 +268,13 @@ function VisualCard({ post }: { post: Post }) { }`} > - - {isVideo ? ( -
- - - -
- ) : null}
{text || post.title ? (
{autolink(text || post.title || "")}
) : null} -