Make items keep aspect ratio

This commit is contained in:
Shea authored and niki committed 2026-07-01 15:15:52 +03:00
1 parent 2b0139fc80
commit c9d6cc543a
3 files changed
+26 -9

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import { DefaultReset } from 'folds';
export const Image = style([
DefaultReset,
{
objectFit: 'cover',
objectFit: 'contain',
width: '100%',
height: '100%',
},
+20 -6
View File
@@ -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({
+5 -2
View File
@@ -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)
)}
<Box alignItems="Inherit" gap="200">
{items.map((item, index) => (
<div key={item.url ?? item.file?.url ?? index} className={css.GalleryItem}>
<div
key={item.url ?? item.file?.url ?? index}
className={css.GalleryItem({ isImage: item.itemtype === MsgType.Image })}
>
{renderItem(galleryItemToContent(item), index)}
</div>
))}