koel/resources/assets/js/components/ui/AlbumArtOverlay.vue

26 lines
691 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2024-02-24 15:37:01 +00:00
<div
:style="{ backgroundImage: thumbnailUrl ? `url(${thumbnailUrl})` : 'none' }"
2024-04-04 22:20:42 +00:00
class="pointer-events-none fixed z-[1000] overflow-hidden opacity-10 bg-cover bg-center top-0 left-0 h-full w-full"
2024-02-24 15:37:01 +00:00
data-testid="album-art-overlay"
/>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { ref, toRefs, watchEffect } from 'vue'
2022-04-15 14:24:30 +00:00
import { albumStore } from '@/stores'
2022-06-10 10:47:46 +00:00
const props = defineProps<{ album: number }>()
2022-04-25 13:07:38 +00:00
const { album } = toRefs(props)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const thumbnailUrl = ref<String | null>(null)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
watchEffect(async () => {
2022-04-25 13:07:38 +00:00
try {
2022-06-10 10:47:46 +00:00
thumbnailUrl.value = await albumStore.fetchThumbnail(album.value)
} catch (error: unknown) {
2022-04-25 13:07:38 +00:00
thumbnailUrl.value = null
2022-04-15 14:24:30 +00:00
}
})
</script>