elk/components/status/StatusMedia.vue

47 lines
1.0 KiB
Vue
Raw Normal View History

2022-11-14 02:56:48 +00:00
<script setup lang="ts">
2023-01-08 06:21:09 +00:00
import type { mastodon } from 'masto'
2022-11-14 02:56:48 +00:00
2023-02-15 10:34:23 +00:00
const { status, isPreview = false } = defineProps<{
2023-01-08 06:21:09 +00:00
status: mastodon.v1.Status | mastodon.v1.StatusEdit
2022-12-13 19:26:53 +00:00
fullSize?: boolean
2023-02-15 10:34:23 +00:00
isPreview?: boolean
2022-11-14 02:56:48 +00:00
}>()
const gridColumnNumber = computed(() => {
const num = status.mediaAttachments.length
if (num <= 1)
return 1
else if (num <= 4)
return 2
else
return 3
})
2022-11-14 02:56:48 +00:00
</script>
<template>
<div class="status-media-container">
2022-11-14 03:33:09 +00:00
<template v-for="attachment of status.mediaAttachments" :key="attachment.id">
2022-11-30 03:27:19 +00:00
<StatusAttachment
:attachment="attachment"
:attachments="status.mediaAttachments"
2022-12-13 19:26:53 +00:00
:full-size="fullSize"
w-full
h-full
2023-02-15 10:34:23 +00:00
:is-preview="isPreview"
2022-11-30 03:27:19 +00:00
/>
2022-11-14 03:33:09 +00:00
</template>
</div>
2022-11-14 02:56:48 +00:00
</template>
2022-11-14 03:33:09 +00:00
<style lang="postcss">
.status-media-container {
--grid-cols: v-bind(gridColumnNumber);
display: grid;
grid-template-columns: repeat(var(--grid-cols, 1), 1fr);
2023-01-10 09:05:59 +00:00
--at-apply: gap-2;
2022-11-21 13:38:10 +00:00
position: relative;
2022-11-14 03:33:09 +00:00
width: 100%;
overflow: hidden;
}
</style>