frontend/src/views/CollectionView/CollectionMerchCard.vue

98 lines
1.8 KiB
Vue
Raw Normal View History

2025-09-18 21:05:19 +03:00
<script setup>
2025-09-16 21:26:36 +03:00
import BoxIcon from '@/components/icons/BoxIcon.vue'
2025-10-18 14:10:21 +03:00
import { useMerchImagesApi } from '@/api/merchImages.js'
import { onMounted, ref } from 'vue'
const { getImageUrl } = useMerchImagesApi()
2025-09-18 21:05:19 +03:00
2025-10-18 14:10:21 +03:00
const props = defineProps({
2025-09-18 21:05:19 +03:00
merch: {
type: Object,
required: true,
}
})
2025-10-18 14:10:21 +03:00
const fileList = ref([])
onMounted(async () => {
try {
const imgUrl = await getImageUrl(props.merch.merch_uuid, 'thumbnail')
2025-10-18 14:10:21 +03:00
fileList.value = [
{
name: 'full.jpg',
url: imgUrl,
status: 'finished',
},
]
} catch (error) {
fileList.value = []
if (!error.message?.includes('404')) {
console.error('Error getting image: ', error)
}
}
})
2025-09-16 21:26:36 +03:00
</script>
<template>
2025-09-25 20:04:48 +03:00
<n-card class="responsive-card">
<template #header>
<h3 class="card-title">{{ merch.name }}</h3>
</template>
2025-09-16 21:26:36 +03:00
<template #cover>
<div class="cover-wrapper">
2025-10-18 14:10:21 +03:00
<img
v-if="fileList.length > 0 && fileList[0].url"
:src="fileList[0].url"
alt="Thumbnail"
class="thumbnail"
/>
<BoxIcon v-else />
2025-09-16 21:26:36 +03:00
</div>
</template>
</n-card>
</template>
<style scoped>
.responsive-card {
2025-09-25 20:04:48 +03:00
width: 180px;
height: 240px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-title {
margin: 0;
font-size: 14px;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
white-space: normal;
2025-09-16 21:26:36 +03:00
}
.cover-wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
padding: 12px 0;
overflow: hidden;
}
2025-10-18 14:10:21 +03:00
.thumbnail {
width: 100%;
height: auto;
max-width: 80%;
object-fit: contain;
}
2025-09-16 21:26:36 +03:00
.cover-wrapper :deep(svg) {
width: 100%;
height: auto;
max-width: 80%;
}
</style>