From bf7e694e00849399b078e4de9b95f0d0d9027b39 Mon Sep 17 00:00:00 2001 From: thislight Date: Sat, 14 Sep 2024 20:09:54 +0800 Subject: [PATCH] MediaAttachmentGrid: optimize preview layout (#11) --- src/timelines/MediaAttachmentGrid.tsx | 6 +++--- src/timelines/toot.module.css | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/timelines/MediaAttachmentGrid.tsx b/src/timelines/MediaAttachmentGrid.tsx index 5db3cbe..2d07752 100644 --- a/src/timelines/MediaAttachmentGrid.tsx +++ b/src/timelines/MediaAttachmentGrid.tsx @@ -13,12 +13,12 @@ const MediaAttachmentGrid: Component<{ const gridTemplateColumns = () => { const l = props.attachments.length; if (l < 2) { - return "1fr"; + return "minmax(40px, auto)"; } if (l < 4) { - return "repeat(2, 1fr)"; + return "repeat(2, minmax(40px, auto))"; } - return "repeat(3, 1fr)"; + return "repeat(3, minmax(40px, auto))"; }; const openViewerFor = (index: number) => { diff --git a/src/timelines/toot.module.css b/src/timelines/toot.module.css index 3a65937..ba8477b 100644 --- a/src/timelines/toot.module.css +++ b/src/timelines/toot.module.css @@ -140,7 +140,7 @@ max-height: calc(4 * var(--title-line-height) * var(--title-size)); } - > p { + >p { max-height: calc(8 * var(--body-line-height) * var(--body-size)); } @@ -228,10 +228,19 @@ > :where(img) { max-height: 35vh; min-height: 40px; - object-fit: none; - width: 100%; + object-fit: contain; + max-width: 100%; background-color: var(--tutu-color-surface-d); border-radius: 2px; + border: 1px solid transparent; + transition: border-color 220ms var(--tutu-anim-curve-std), + box-shadow 220ms var(--tutu-anim-curve-std); + + &:hover, + &:focus-visible { + border: 1px solid var(--tutu-color-surface-dd); + box-shadow: var(--tutu-shadow-e1); + } } }