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

zio/stable
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
1 changed files with 14 additions and 17 deletions

View File

@ -6,10 +6,20 @@ const { status, isPreview = false } = defineProps<{
fullSize?: boolean fullSize?: boolean
isPreview?: 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> </script>
<template> <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"> <template v-for="attachment of status.mediaAttachments" :key="attachment.id">
<StatusAttachment <StatusAttachment
:attachment="attachment" :attachment="attachment"
@ -25,25 +35,12 @@ const { status, isPreview = false } = defineProps<{
<style lang="postcss"> <style lang="postcss">
.status-media-container { .status-media-container {
--grid-cols: v-bind(gridColumnNumber);
display: grid;
grid-template-columns: repeat(var(--grid-cols, 1), 1fr);
--at-apply: gap-2; --at-apply: gap-2;
position: relative; position: relative;
width: 100%; width: 100%;
overflow: hidden; 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> </style>