1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-14 04:49:59 +00:00

feat: support more than 4 media attachments with 3 columns grid (#2802)

This commit is contained in:
TAKAHASHI Shuuji 2024-04-14 20:04:28 +09:00 committed by GitHub
parent e4c7124d28
commit c1f8e3efb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,10 +6,20 @@ const { status, isPreview = false } = defineProps<{
fullSize?: boolean
isPreview?: boolean
}>()
const gridColumnNumber = computed(() => {
const num = status.mediaAttachments.length
if (num <= 1)
return 1
else if (num <= 4)
return 2
else
return 3
})
</script>
<template>
<div class="status-media-container" :class="`status-media-container-${status.mediaAttachments.length}`">
<div class="status-media-container">
<template v-for="attachment of status.mediaAttachments" :key="attachment.id">
<StatusAttachment
:attachment="attachment"
@ -25,25 +35,12 @@ const { status, isPreview = false } = defineProps<{
<style lang="postcss">
.status-media-container {
--grid-cols: v-bind(gridColumnNumber);
display: grid;
grid-template-columns: repeat(var(--grid-cols, 1), 1fr);
--at-apply: gap-2;
position: relative;
width: 100%;
overflow: hidden;
}
.status-media-container-1 {
display: grid;
grid-template-columns: 1fr;
}
.status-media-container-2 {
display: grid;
grid-template-columns: 1fr 1fr;
}
.status-media-container-3 {
display: grid;
grid-template-columns: 1fr 1fr;
}
.status-media-container-4 {
display: grid;
grid-template-columns: 1fr 1fr;
}
</style>