From c9d6cc543abff86262468e736c2cf9938b0f802f Mon Sep 17 00:00:00 2001 From: Shea Date: Wed, 1 Jul 2026 12:15:52 +0000 Subject: [PATCH] Make items keep aspect ratio --- src/app/components/media/media.css.ts | 2 +- src/app/components/message/MGallery.css.ts | 26 +++++++++++++++++----- src/app/components/message/MGallery.tsx | 7 ++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/app/components/media/media.css.ts b/src/app/components/media/media.css.ts index a176fef02..4253b52d2 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/MGallery.css.ts b/src/app/components/message/MGallery.css.ts index f673754e0..74061538a 100644 --- a/src/app/components/message/MGallery.css.ts +++ b/src/app/components/message/MGallery.css.ts @@ -7,12 +7,26 @@ export const GalleryHolder = style({ marginTop: config.space.S200, }); -export const GalleryItem = style({ - width: toRem(300), - height: toRem(200), - flexShrink: 0, - overflow: 'hidden', - borderRadius: config.radii.R300, +export const GalleryItem = recipe({ + base: [ + DefaultReset, + { + maxWidth: toRem(450), + flexShrink: 0, + overflow: 'hidden', + borderRadius: config.radii.R300, + }, + ], + variants: { + isImage: { + true: { + height: toRem(300), + }, + false: { + maxHeight: toRem(300), + }, + }, + }, }); export const GalleryHolderGradient = recipe({ diff --git a/src/app/components/message/MGallery.tsx b/src/app/components/message/MGallery.tsx index 381bd77d3..2a917a108 100644 --- a/src/app/components/message/MGallery.tsx +++ b/src/app/components/message/MGallery.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Box, Icon, IconButton, Icons, Scroll } from 'folds'; -import type { IContent } from 'matrix-js-sdk'; +import { MsgType, type IContent } from 'matrix-js-sdk'; import type { IGalleryContent, IGalleryItem } from '$types/matrix/common'; import { getIntersectionObserverEntry, @@ -104,7 +104,10 @@ export function MGallery({ content, renderItem, renderCaption }: MGalleryProps) )} {items.map((item, index) => ( -
+
{renderItem(galleryItemToContent(item), index)}
))}