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

40 lines
825 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-04-15 17:00:08 +00:00
const props = defineProps<{ song: Song | null }>()
const { song } = 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 () => {
if (song.value) {
try {
thumbnailUrl.value = await albumStore.getThumbnail(song.value.album)
} 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>