From 8cdcd7b28410be6b0b081ef1f21f656a5f3112f8 Mon Sep 17 00:00:00 2001 From: boojack Date: Fri, 10 Apr 2026 08:55:20 +0800 Subject: [PATCH] refactor(attachments): extract visual gallery layout and tile style tokens --- .../Attachment/AttachmentListView.tsx | 77 +++++++------------ .../Attachment/attachmentVisualClasses.ts | 33 ++++++++ .../Attachment/visualGalleryLayout.ts | 72 +++++++++++++++++ 3 files changed, 134 insertions(+), 48 deletions(-) create mode 100644 web/src/components/MemoMetadata/Attachment/attachmentVisualClasses.ts create mode 100644 web/src/components/MemoMetadata/Attachment/visualGalleryLayout.ts diff --git a/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx b/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx index 735d4b0e0..cfb75638d 100644 --- a/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx +++ b/web/src/components/MemoMetadata/Attachment/AttachmentListView.tsx @@ -10,6 +10,18 @@ import type { AttachmentVisualItem, PreviewMediaItem } from "@/utils/media-item" import { buildAttachmentVisualItems } from "@/utils/media-item"; import AudioAttachmentItem from "./AudioAttachmentItem"; import { getAttachmentMetadata, isAudioAttachment, separateAttachments } from "./attachmentHelpers"; +import { + COLLAGE_VIDEO_PLAY_BADGE_CLASS, + COVER_MEDIA_CLASS, + MEDIA_HOVER_GRADIENT_CLASS, + MEDIA_HOVER_SURFACE_CLASS, + NATURAL_MEDIA_CLASS, + OVERFLOW_TILE_OVERLAY_CLASS, + SINGLE_MOTION_VIDEO_CLASS, + SINGLE_VIDEO_CARD_WIDTH_CLASS, + VISUAL_TILE_BUTTON_CLASS, +} from "./attachmentVisualClasses"; +import { resolveVisualGalleryLayout } from "./visualGalleryLayout"; interface AttachmentListViewProps { attachments: Attachment[]; @@ -18,15 +30,6 @@ interface AttachmentListViewProps { type VisualItem = AttachmentVisualItem; -const VISUAL_TILE_CLASS = - "group relative overflow-hidden rounded-xl border border-border/70 bg-muted/30 text-left transition-colors hover:border-accent/40"; -const COVER_MEDIA_CLASS = "h-full w-full rounded-none object-cover transition-transform duration-300 group-hover:scale-[1.02]"; -const NATURAL_MEDIA_CLASS = - "block h-auto max-h-[20rem] w-auto max-w-full rounded-none transition-transform duration-300 group-hover:scale-[1.02]"; -const SINGLE_VIDEO_CARD_WIDTH_CLASS = "w-full max-w-[30rem]"; -const TWO_ITEM_GRID_HEIGHT_CLASS = "h-[11rem] sm:h-[13rem] md:h-[15rem]"; -const MOSAIC_GRID_HEIGHT_CLASS = "h-[13rem] sm:h-[16rem] md:h-[18rem]"; - const AttachmentMeta = ({ attachment }: { attachment: Attachment }) => { const { fileTypeLabel, fileSizeLabel } = getAttachmentMetadata(attachment); @@ -74,14 +77,12 @@ const VisualTile = ({ children, }: PropsWithChildren<{ className?: string; onPreview?: () => void; overlayLabel?: string }>) => { return ( - ); }; @@ -116,7 +117,7 @@ const CollageVisualItem = ({ <>