From 14bcc4454ccd4d596e78873fe2c2b2a88ec7a4ed Mon Sep 17 00:00:00 2001 From: wrigglebug <133191472+wrigglebug@users.noreply.github.com> Date: Sun, 8 Mar 2026 03:47:13 -0700 Subject: [PATCH] Adjust media sizing and URL preview layout --- src/app/components/media/media.css.ts | 2 +- .../components/message/MsgTypeRenderers.tsx | 13 ++- .../message/attachment/Attachment.css.ts | 2 +- .../components/url-preview/UrlPreview.css.tsx | 1 - .../components/url-preview/UrlPreviewCard.tsx | 109 ++++++++---------- 5 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/app/components/media/media.css.ts b/src/app/components/media/media.css.ts index b563ef3e..aad194fd 100644 --- a/src/app/components/media/media.css.ts +++ b/src/app/components/media/media.css.ts @@ -4,7 +4,7 @@ import { DefaultReset } from 'folds'; export const Image = style([ DefaultReset, { - objectFit: 'cover', + objectFit: 'contain', width: '100%', height: '100%', }, diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 275cfefe..66656f94 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -250,19 +250,26 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) { if (typeof mxcUrl !== 'string') { return ; } - const height = scaleYDimension(imgInfo?.w || 400, 400, imgInfo?.h || 400); + const MAX_SIZE = 400; + const imgW = imgInfo?.w ?? MAX_SIZE; + const imgH = imgInfo?.h ?? MAX_SIZE; + const aspectRatio = imgInfo?.w && imgInfo?.h ? `${imgW} / ${imgH}` : undefined; + // this garbage is for portrait images, we cap the width so the card doesn't exceed the bounds of the image + const displayWidth = imgH > imgW ? Math.round(MAX_SIZE * (imgW / imgH)) : MAX_SIZE; return ( {renderImageContent({ @@ -306,7 +313,7 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }: return ; } - const height = scaleYDimension(videoInfo.w || 400, 400, videoInfo.h || 400); + const height = Math.min(scaleYDimension(videoInfo.w || 400, 400, videoInfo.h || 400), 400); const filename = content.filename ?? content.body ?? 'Video'; diff --git a/src/app/components/message/attachment/Attachment.css.ts b/src/app/components/message/attachment/Attachment.css.ts index 4c417611..dad95f61 100644 --- a/src/app/components/message/attachment/Attachment.css.ts +++ b/src/app/components/message/attachment/Attachment.css.ts @@ -23,7 +23,7 @@ export const Attachment = recipe({ export type AttachmentVariants = RecipeVariants; export const AttachmentHeader = style({ - padding: config.space.S300, + padding: config.space.S100, }); export const AttachmentBox = style([ diff --git a/src/app/components/url-preview/UrlPreview.css.tsx b/src/app/components/url-preview/UrlPreview.css.tsx index 3192dc49..90adc127 100644 --- a/src/app/components/url-preview/UrlPreview.css.tsx +++ b/src/app/components/url-preview/UrlPreview.css.tsx @@ -5,7 +5,6 @@ export const UrlPreview = style([ DefaultReset, { width: toRem(400), - minHeight: toRem(102), backgroundColor: color.SurfaceVariant.Container, color: color.SurfaceVariant.OnContainer, border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`, diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx index 3855085d..2d59eed4 100644 --- a/src/app/components/url-preview/UrlPreviewCard.tsx +++ b/src/app/components/url-preview/UrlPreviewCard.tsx @@ -54,69 +54,14 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s return ( - {(prev['og:video'] && ( - ); }; @@ -197,9 +190,7 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s maxWidth: '100%', margin: 0, } - : { - width: '600px', - } + : undefined } > {previewContent}