MediaAttachmentGrid: improve layout as length % 2

This commit is contained in:
thislight 2024-10-08 17:43:33 +08:00
parent eefe2812df
commit dbb93fd76c
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E

View file

@ -51,9 +51,19 @@ const MediaAttachmentGrid: Component<{
setViewerIndex(index); setViewerIndex(index);
}; };
const columnCount = () => {
if (props.attachments.length === 1) {
return 1;
} else if (props.attachments.length % 2 === 0) {
return 2;
} else {
return 3;
}
};
css` css`
.attachments { .attachments {
column-count: ${(props.attachments.length === 1 ? 1 : 3).toString()}; column-count: ${columnCount.toString()};
} }
`; `;
return ( return (