2021-08-21 16:15:44 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full border-b border-gray-700 pb-2">
|
|
|
|
<div class="flex py-1 hover:bg-gray-300 hover:bg-opacity-10 cursor-pointer" @click="selectMatch">
|
2021-12-03 02:40:42 +01:00
|
|
|
<img :src="selectedCover || '/book_placeholder.jpg'" class="h-24 object-cover" :style="{ width: 96 / bookCoverAspectRatio + 'px' }" />
|
2021-08-21 16:15:44 +02:00
|
|
|
<div class="px-4 flex-grow">
|
|
|
|
<div class="flex items-center">
|
|
|
|
<h1>{{ book.title }}</h1>
|
|
|
|
<div class="flex-grow" />
|
2022-03-14 01:34:31 +01:00
|
|
|
<p>{{ book.publishedYear }}</p>
|
2021-08-21 16:15:44 +02:00
|
|
|
</div>
|
|
|
|
<p class="text-gray-400">{{ book.author }}</p>
|
|
|
|
<div class="w-full max-h-12 overflow-hidden">
|
2021-10-28 21:41:42 +02:00
|
|
|
<p class="text-gray-500 text-xs">{{ book.description }}</p>
|
2021-08-21 16:15:44 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="bookCovers.length > 1" class="flex">
|
|
|
|
<template v-for="cover in bookCovers">
|
|
|
|
<div :key="cover" class="border-2 hover:border-yellow-300 border-transparent" :class="cover === selectedCover ? 'border-yellow-200' : ''" @mousedown.stop @mouseup.stop @click.stop="clickCover(cover)">
|
|
|
|
<img :src="cover" class="h-20 w-12 object-cover mr-1" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
book: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
2021-12-03 02:40:42 +01:00
|
|
|
},
|
|
|
|
bookCoverAspectRatio: Number
|
2021-08-21 16:15:44 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selectedCover: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
bookCovers() {
|
|
|
|
return this.book.covers ? this.book.covers || [] : []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectMatch() {
|
|
|
|
var book = { ...this.book }
|
|
|
|
book.cover = this.selectedCover
|
|
|
|
this.$emit('select', this.book)
|
|
|
|
},
|
|
|
|
clickCover(cover) {
|
|
|
|
this.selectedCover = cover
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-10-28 21:41:42 +02:00
|
|
|
this.selectedCover = this.bookCovers.length ? this.bookCovers[0] : this.book.cover || null
|
2021-08-21 16:15:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|