2022-11-26 23:45:54 +01:00
|
|
|
<template>
|
|
|
|
<div class="relative rounded-sm overflow-hidden" :style="{ width: width + 'px', height: height + 'px' }">
|
2022-11-27 21:13:31 +01:00
|
|
|
<div v-if="items.length" class="flex flex-wrap justify-center h-full relative bg-primary bg-opacity-95 rounded-sm">
|
2022-11-26 23:45:54 +01:00
|
|
|
<div class="absolute top-0 left-0 w-full h-full bg-gray-400 bg-opacity-5" />
|
2022-11-27 22:12:55 +01:00
|
|
|
<covers-book-cover v-for="(li, index) in libraryItemCovers" :key="index" :library-item="li" :width="itemCoverWidth" :book-cover-aspect-ratio="1" />
|
2022-11-26 23:45:54 +01:00
|
|
|
</div>
|
|
|
|
<div v-else class="relative w-full h-full flex items-center justify-center p-2 bg-primary rounded-sm">
|
|
|
|
<div class="absolute top-0 left-0 w-full h-full bg-gray-400 bg-opacity-5" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
items: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
|
|
|
},
|
|
|
|
width: Number,
|
2022-11-27 22:12:55 +01:00
|
|
|
height: Number
|
2022-11-26 23:45:54 +01:00
|
|
|
},
|
|
|
|
data() {
|
2022-11-27 21:13:31 +01:00
|
|
|
return {}
|
2022-11-26 23:45:54 +01:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
sizeMultiplier() {
|
2022-11-27 21:13:31 +01:00
|
|
|
return this.width / (120 * 1.6 * 2)
|
2022-11-27 21:11:17 +01:00
|
|
|
},
|
2022-11-27 21:35:55 +01:00
|
|
|
itemCoverWidth() {
|
|
|
|
if (this.libraryItemCovers.length === 1) return this.width
|
|
|
|
return this.width / 2
|
|
|
|
},
|
2022-11-27 21:11:17 +01:00
|
|
|
libraryItemCovers() {
|
|
|
|
if (!this.items.length) return []
|
|
|
|
if (this.items.length === 1) return [this.items[0].libraryItem]
|
|
|
|
|
|
|
|
const covers = []
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
|
|
let index = i % this.items.length
|
|
|
|
if (this.items.length === 2 && i >= 2) index = (i + 1) % 2 // for playlists with 2 items show covers in checker pattern
|
|
|
|
|
|
|
|
covers.push(this.items[index].libraryItem)
|
|
|
|
}
|
|
|
|
return covers
|
2022-11-26 23:45:54 +01:00
|
|
|
}
|
|
|
|
},
|
2022-11-27 21:13:31 +01:00
|
|
|
methods: {},
|
2022-11-26 23:45:54 +01:00
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|