2024-05-08 14:15:21 +02:00
|
|
|
<template>
|
2024-06-21 05:50:41 +02:00
|
|
|
<div v-bind="$attrs" class="bg-dark-700 overflow-hidden flex items-center justify-center">
|
|
|
|
|
<Skeleton :enabled="!imageLoaded" class="!h-full !w-full !rounded-none">
|
2024-06-21 06:53:34 +02:00
|
|
|
<img class="cursor-pointer ring-1 w-full h-full object-cover" :src="src" :alt="alt" />
|
2024-05-08 14:15:21 +02:00
|
|
|
</Skeleton>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-06-21 04:09:09 +02:00
|
|
|
import Skeleton from "../skeleton/Skeleton.vue";
|
2024-05-08 14:15:21 +02:00
|
|
|
|
2024-06-21 05:50:41 +02:00
|
|
|
defineOptions({
|
|
|
|
|
inheritAttrs: false,
|
|
|
|
|
});
|
|
|
|
|
const props = defineProps<{
|
2024-05-13 05:19:53 +02:00
|
|
|
src?: string;
|
2024-05-08 14:15:21 +02:00
|
|
|
alt?: string;
|
2024-06-21 05:50:41 +02:00
|
|
|
}>();
|
|
|
|
|
const imageLoaded = ref(false);
|
2024-05-08 14:15:21 +02:00
|
|
|
|
2024-06-21 05:50:41 +02:00
|
|
|
watch(
|
|
|
|
|
() => props.src,
|
|
|
|
|
(src) => {
|
|
|
|
|
if (!src) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load in background
|
|
|
|
|
const img = new Image();
|
|
|
|
|
img.src = src;
|
|
|
|
|
|
|
|
|
|
img.onload = () => {
|
|
|
|
|
imageLoaded.value = true;
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
);
|
2024-05-08 14:15:21 +02:00
|
|
|
</script>
|