2021-09-23 03:40:35 +02:00
|
|
|
<template>
|
|
|
|
<div class="relative">
|
2022-08-23 23:07:53 +02:00
|
|
|
<div class="rounded-sm h-full relative" :style="{ width: width + 'px', height: height + 'px' }" @mouseover="mouseoverCard" @mouseleave="mouseleaveCard" @click="clickCard">
|
2021-10-17 18:29:52 +02:00
|
|
|
<nuxt-link :to="groupTo" class="cursor-pointer">
|
2022-08-23 23:07:53 +02:00
|
|
|
<div class="w-full h-full relative" :class="isHovering ? 'bg-black-400' : 'bg-primary'">
|
|
|
|
<covers-group-cover ref="groupcover" :id="groupEncode" :name="groupName" :type="groupType" :book-items="bookItems" :width="width" :height="height" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2021-09-24 14:32:38 +02:00
|
|
|
|
2021-12-02 22:49:03 +01:00
|
|
|
<div v-if="hasValidCovers" class="bg-black bg-opacity-60 absolute top-0 left-0 w-full h-full flex items-center justify-center text-center transition-opacity z-30" :class="isHovering ? '' : 'opacity-0'" :style="{ padding: `${sizeMultiplier}rem` }">
|
2022-08-23 23:07:53 +02:00
|
|
|
<p class="font-book" :style="{ fontSize: 1.2 * sizeMultiplier + 'rem' }">{{ groupName }}</p>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
|
|
|
|
2022-08-23 23:07:53 +02:00
|
|
|
<div class="absolute z-10 top-1.5 right-1.5 rounded-md leading-3 text-sm p-1 font-semibold text-white flex items-center justify-center" style="background-color: #cd9d49dd">{{ bookItems.length }}</div>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
2021-09-23 03:40:35 +02:00
|
|
|
</nuxt-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
2022-08-23 23:07:53 +02:00
|
|
|
width: Number,
|
|
|
|
height: Number,
|
2021-12-02 22:49:03 +01:00
|
|
|
bookCoverAspectRatio: Number
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHovering: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-10-05 05:11:42 +02:00
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
|
|
|
},
|
2021-09-23 03:40:35 +02:00
|
|
|
_group() {
|
|
|
|
return this.group || {}
|
|
|
|
},
|
2021-10-17 18:29:52 +02:00
|
|
|
groupType() {
|
|
|
|
return this._group.type
|
|
|
|
},
|
|
|
|
groupTo() {
|
2022-08-23 23:07:53 +02:00
|
|
|
return `/library/${this.currentLibraryId}/bookshelf?filter=${this.filter}`
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
|
|
|
sizeMultiplier() {
|
2022-08-23 23:07:53 +02:00
|
|
|
if (this.bookCoverAspectRatio === 1) return this.width / (120 * 1.6 * 2)
|
|
|
|
return this.width / 240
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
2021-09-24 14:32:38 +02:00
|
|
|
bookItems() {
|
2021-09-23 03:40:35 +02:00
|
|
|
return this._group.books || []
|
|
|
|
},
|
|
|
|
groupName() {
|
|
|
|
return this._group.name || 'No Name'
|
2021-09-24 14:32:38 +02:00
|
|
|
},
|
|
|
|
groupEncode() {
|
|
|
|
return this.$encode(this.groupName)
|
|
|
|
},
|
|
|
|
filter() {
|
|
|
|
return `${this.groupType}.${this.$encode(this.groupName)}`
|
|
|
|
},
|
|
|
|
hasValidCovers() {
|
2022-03-13 18:39:12 +01:00
|
|
|
var validCovers = this.bookItems.map((bookItem) => bookItem.media.coverPath)
|
2021-09-24 14:32:38 +02:00
|
|
|
return !!validCovers.length
|
2021-09-23 03:40:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-10-29 02:34:29 +02:00
|
|
|
mouseoverCard() {
|
|
|
|
this.isHovering = true
|
|
|
|
},
|
|
|
|
mouseleaveCard() {
|
|
|
|
this.isHovering = false
|
|
|
|
},
|
2021-09-24 14:32:38 +02:00
|
|
|
clickCard() {
|
|
|
|
this.$emit('click', this.group)
|
|
|
|
}
|
2021-09-26 22:34:08 +02:00
|
|
|
}
|
2021-09-23 03:40:35 +02:00
|
|
|
}
|
|
|
|
</script>
|