Handle > 4 medias

- Mastodon now doesn't allow >4, so this is for the future or maybe the forks.
- Using grid for better control on how images lay out
This commit is contained in:
Lim Chee Aun 2022-12-28 10:51:57 +08:00
parent 8b6cae5611
commit fa0ccece32
2 changed files with 41 additions and 27 deletions

View file

@ -280,37 +280,48 @@
.status .media-container {
margin-top: 8px;
display: flex;
flex-wrap: wrap;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: 1fr;
gap: 2px;
flex-direction: row;
height: 160px;
}
.status:not(.large) .media-container.media-gt4 {
flex-wrap: nowrap;
overflow: auto;
.status .media-container.media-gt2 {
height: 200px;
}
.status.large :is(.media-container, .media-container.media-gt2) {
height: auto;
max-height: 80vh;
}
.status .media {
flex-grow: 1;
flex-basis: calc(50% - 8px);
border-radius: 8px;
overflow: hidden;
max-height: 160px;
min-height: 80px;
border: 1px solid var(--outline-color);
}
.status .media-container.media-gt2 .media {
aspect-ratio: 1 / 1;
.status .media:only-child {
grid-area: span 2 / span 2;
}
.status:not(.large) .media-container.media-gt4 .media {
min-width: 80px;
.status .media:first-child:nth-last-child(3) {
grid-area: span 2;
}
.status:not(.large) .media-container.media-gt4 .media:last-child {
position: relative;
}
.status:not(.large) .media-container.media-gt4 .media:last-child:after {
content: '4+';
position: absolute;
inset: 0;
display: flex;
place-content: center;
place-items: center;
background-color: var(--bg-faded-blur-color);
}
.status .media:hover {
border-color: var(--outline-hover-color);
}
.status .media.block {
flex-basis: 100%;
max-height: auto;
}
.status .media :is(img, video) {
width: 100%;
height: 100%;

View file

@ -417,16 +417,19 @@ function Status({
mediaAttachments.length > 2 ? 'media-gt2' : ''
} ${mediaAttachments.length > 4 ? 'media-gt4' : ''}`}
>
{mediaAttachments.map((media, i) => (
<Media
media={media}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setShowMediaModal(i);
}}
/>
))}
{mediaAttachments
.slice(0, size === 'l' ? undefined : 4)
.map((media, i) => (
<Media
key={media.id}
media={media}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setShowMediaModal(i);
}}
/>
))}
</div>
)}
{!!card &&