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

38 lines
785 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<div :style="{ backgroundImage: thumbnailUrl ? `url(${thumbnailUrl})` : 'none' }" data-testid="album-art-overlay"/>
</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)
2022-04-25 13:07:38 +00:00
} catch (e) {
thumbnailUrl.value = null
2022-04-15 14:24:30 +00:00
}
})
</script>
<style scoped>
div {
position: fixed;
opacity: .1;
z-index: 10000;
overflow: hidden;
background-size: cover;
background-position: center;
pointer-events: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>