2021-09-23 03:40:35 +02:00
|
|
|
<template>
|
|
|
|
<div class="relative">
|
2021-12-18 03:52:11 +01:00
|
|
|
<div class="rounded-sm h-full relative" :style="{ padding: `0px ${paddingX}px` }" @mouseover="mouseoverCard" @mouseleave="mouseleaveCard" @click="clickCard">
|
2021-10-17 18:29:52 +02:00
|
|
|
<nuxt-link :to="groupTo" class="cursor-pointer">
|
2021-11-26 22:46:07 +01:00
|
|
|
<div class="w-full h-full relative" :class="isHovering ? 'bg-black-400' : 'bg-primary'" :style="{ height: coverHeight + 'px', width: coverWidth + 'px' }">
|
2021-12-02 22:49:03 +01:00
|
|
|
<covers-group-cover ref="groupcover" :id="seriesId" :name="groupName" :is-categorized="isCategorized" :group-to="groupTo" :type="groupType" :book-items="bookItems" :width="coverWidth" :height="coverHeight" :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` }">
|
2021-09-26 22:34:08 +02:00
|
|
|
<p class="font-book" :style="{ fontSize: sizeMultiplier + 'rem' }">{{ groupName }}</p>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
|
|
|
|
2021-11-08 01:11:29 +01:00
|
|
|
<div class="absolute top-2 right-2 w-7 h-7 rounded-lg bg-black bg-opacity-90 text-gray-300 box-shadow-book flex items-center justify-center border border-white border-opacity-25 pointer-events-none z-40">
|
2021-09-24 14:32:38 +02:00
|
|
|
<p class="font-book text-xl">{{ bookItems.length }}</p>
|
|
|
|
</div>
|
2021-11-08 01:11:29 +01:00
|
|
|
<div class="absolute bottom-0 left-0 w-full h-1 flex flex-nowrap z-40">
|
2021-09-26 22:34:08 +02:00
|
|
|
<div v-for="userProgress in userProgressItems" :key="userProgress.audiobookId" class="h-full w-full" :class="userProgress.isRead ? 'bg-success' : userProgress.progress > 0 ? 'bg-yellow-400' : ''" />
|
|
|
|
</div>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
2021-09-23 03:40:35 +02:00
|
|
|
</nuxt-link>
|
|
|
|
</div>
|
2021-11-26 22:46:07 +01:00
|
|
|
|
2021-12-02 02:07:03 +01:00
|
|
|
<div v-if="!isCategorized" class="categoryPlacard absolute z-30 left-0 right-0 mx-auto bottom-0 h-6 rounded-md font-book text-center" :style="{ width: Math.min(160, coverWidth) + 'px' }">
|
2021-11-26 22:46:07 +01:00
|
|
|
<div class="w-full h-full shinyBlack flex items-center justify-center rounded-sm border" :style="{ padding: `0rem ${1 * sizeMultiplier}rem` }">
|
|
|
|
<p class="truncate" :style="{ fontSize: labelFontSize + 'rem' }">{{ groupName }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-23 03:40:35 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: Number,
|
|
|
|
default: 120
|
2021-11-26 22:46:07 +01:00
|
|
|
},
|
2021-12-02 22:49:03 +01:00
|
|
|
isCategorized: Boolean,
|
|
|
|
bookCoverAspectRatio: Number
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHovering: false
|
|
|
|
}
|
|
|
|
},
|
2021-09-24 14:32:38 +02:00
|
|
|
watch: {
|
|
|
|
width(newVal) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
if (this.$refs.groupcover) {
|
|
|
|
this.$refs.groupcover.init()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2021-09-23 03:40:35 +02:00
|
|
|
computed: {
|
2021-12-02 22:49:03 +01:00
|
|
|
seriesId() {
|
|
|
|
return this.groupEncode
|
|
|
|
},
|
2021-11-26 22:46:07 +01:00
|
|
|
labelFontSize() {
|
|
|
|
if (this.coverWidth < 160) return 0.75
|
|
|
|
return 0.875
|
|
|
|
},
|
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() {
|
|
|
|
if (this.groupType === 'series') {
|
2021-12-02 02:07:03 +01:00
|
|
|
return `/library/${this.currentLibraryId}/series/${this.groupEncode}`
|
2021-11-06 02:24:02 +01:00
|
|
|
} else if (this.groupType === 'collection') {
|
|
|
|
return `/collection/${this._group.id}`
|
2021-10-17 18:29:52 +02:00
|
|
|
} else {
|
|
|
|
return `/library/${this.currentLibraryId}/bookshelf?filter=tags.${this.groupEncode}`
|
|
|
|
}
|
|
|
|
},
|
2021-12-02 22:49:03 +01:00
|
|
|
squareAspectRatio() {
|
|
|
|
return this.bookCoverAspectRatio === 1
|
|
|
|
},
|
2021-11-07 02:31:46 +01:00
|
|
|
coverWidth() {
|
2021-12-02 22:49:03 +01:00
|
|
|
return this.width * 2
|
2021-11-07 02:31:46 +01:00
|
|
|
},
|
|
|
|
coverHeight() {
|
2021-12-02 22:49:03 +01:00
|
|
|
return this.width * this.bookCoverAspectRatio
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
|
|
|
sizeMultiplier() {
|
2021-12-02 22:49:03 +01:00
|
|
|
var baseSize = this.squareAspectRatio ? 192 : 120
|
|
|
|
return this.width / baseSize
|
2021-09-23 03:40:35 +02:00
|
|
|
},
|
|
|
|
paddingX() {
|
|
|
|
return 16 * this.sizeMultiplier
|
|
|
|
},
|
2021-09-24 14:32:38 +02:00
|
|
|
bookItems() {
|
2021-09-23 03:40:35 +02:00
|
|
|
return this._group.books || []
|
|
|
|
},
|
2021-09-26 22:34:08 +02:00
|
|
|
userAudiobooks() {
|
|
|
|
return Object.values(this.$store.state.user.user ? this.$store.state.user.user.audiobooks || {} : {})
|
|
|
|
},
|
|
|
|
userProgressItems() {
|
|
|
|
return this.bookItems.map((item) => {
|
|
|
|
var userAudiobook = this.userAudiobooks.find((ab) => ab.audiobookId === item.id)
|
|
|
|
return userAudiobook || {}
|
|
|
|
})
|
|
|
|
},
|
2021-09-23 03:40:35 +02:00
|
|
|
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() {
|
|
|
|
var validCovers = this.bookItems.map((bookItem) => bookItem.book.cover)
|
|
|
|
return !!validCovers.length
|
2021-10-30 03:42:28 +02:00
|
|
|
},
|
|
|
|
showExperimentalFeatures() {
|
|
|
|
return this.$store.state.showExperimentalFeatures
|
2021-09-23 03:40:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-10-29 02:34:29 +02:00
|
|
|
mouseoverCard() {
|
|
|
|
this.isHovering = true
|
|
|
|
// if (this.$refs.groupcover) this.$refs.groupcover.setHover(true)
|
|
|
|
},
|
|
|
|
mouseleaveCard() {
|
|
|
|
this.isHovering = false
|
|
|
|
// if (this.$refs.groupcover) this.$refs.groupcover.setHover(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>
|