Skip to content

Commit

Permalink
feat(webui): read button on item card
Browse files Browse the repository at this point in the history
closes #133
  • Loading branch information
gotson committed Jun 4, 2020
1 parent 63da7ec commit a59f263
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 51 deletions.
44 changes: 40 additions & 4 deletions komga-webui/src/components/ItemCard.vue
Expand Up @@ -32,6 +32,7 @@
:opacity="hover ? 0.3 : 0"
:class="`${hover ? 'item-border-darken' : selected ? 'item-border' : 'item-border-transparent'} overlay-full`"
>
<!-- Circle icon for selection (top left) -->
<v-icon v-if="onSelected"
:color="selected ? 'secondary' : ''"
style="position: absolute; top: 5px; left: 10px"
Expand All @@ -41,6 +42,19 @@
}}
</v-icon>

<!-- FAB reading (center) -->
<v-btn
v-if="bookReady && !selected && !preselect"
fab
x-large
color="accent"
style="position: absolute; top: 50%; left: 50%; margin-left: -36px; margin-top: -36px"
:to="{name: 'read-book', params: { bookId: item.id}}"
>
<v-icon>mdi-book-open-page-variant</v-icon>
</v-btn>

<!-- Pen icon for edition (bottom left) -->
<v-icon v-if="!selected && !preselect && onEdit"
style="position: absolute; bottom: 10px; left: 10px"
@click.stop="editItem"
Expand Down Expand Up @@ -87,10 +101,12 @@ export default Vue.extend({
type: Object as () => BookDto | SeriesDto,
required: true,
},
// hide the bottom part of the card
thumbnailOnly: {
type: Boolean,
default: false,
},
// disables the default link on clicking the card
noLink: {
type: Boolean,
default: false,
Expand All @@ -100,19 +116,23 @@ export default Vue.extend({
required: false,
default: 150,
},
// when true, card will show the active border and circle icon full
selected: {
type: Boolean,
default: false,
},
// when true, will display the border like if the card was hovered, and click anywhere will trigger onSelected
preselect: {
type: Boolean,
required: false,
},
// callback function to call when selecting the card
onSelected: {
type: Function,
default: undefined,
required: false,
},
// callback function for the edit button
onEdit: {
type: Function,
default: undefined,
Expand All @@ -124,7 +144,7 @@ export default Vue.extend({
},
computed: {
overlay (): boolean {
return this.onEdit !== undefined || this.onSelected !== undefined
return this.onEdit !== undefined || this.onSelected !== undefined || this.bookReady
},
computedItem (): Item<BookDto | SeriesDto> {
return createItem(this.item)
Expand Down Expand Up @@ -160,6 +180,12 @@ export default Vue.extend({
if ('seriesId' in this.item) return getReadProgressPercentage(this.item)
return 0
},
bookReady (): boolean {
if ('seriesId' in this.item) {
return this.item.media.status === 'READY'
}
return false
},
},
methods: {
onClick () {
Expand Down Expand Up @@ -187,9 +213,7 @@ export default Vue.extend({
</script>

<style>
@import "../styles/unread-triangle.css";
.no-link * {
.no-link {
cursor: default;
}
Expand All @@ -209,4 +233,16 @@ export default Vue.extend({
width: 100%;
height: 100%;
}
.unread {
border-left: 25px solid transparent;
border-right: 25px solid orange;
border-bottom: 25px solid transparent;
height: 0;
width: 0;
position: absolute;
right: 0;
z-index: 2;
}
</style>
10 changes: 0 additions & 10 deletions komga-webui/src/styles/unread-triangle.css

This file was deleted.

47 changes: 10 additions & 37 deletions komga-webui/src/views/BrowseBook.vue
Expand Up @@ -46,40 +46,13 @@
<v-container fluid class="pa-6">
<v-row>
<v-col cols="4" sm="4" md="auto" lg="auto" xl="auto">
<v-hover>
<template v-slot:default="{ hover }">
<v-img :src="thumbnailUrl"
lazy-src="../assets/cover.svg"
max-height="300"
max-width="212"
>
<div class="unread" v-if="isUnread"/>
<v-fade-transition>
<v-overlay
v-if="hover && book.media.status === 'READY'"
absolute
color="grey darken-4"
>
<v-btn fab
x-large
color="accent"
:to="{name: 'read-book', params: { bookId: bookId}}"
>
<v-icon>mdi-book-open-page-variant</v-icon>
</v-btn>
</v-overlay>
</v-fade-transition>
<v-progress-linear
v-if="isInProgress"
:value="readProgressPercentage"
color="orange"
height="6"
style="position: absolute; bottom: 0"
/>
</v-img>
</template>
</v-hover>

<item-card
v-if="book.hasOwnProperty('id')"
width="212"
:item="book"
thumbnail-only
no-link
></item-card>
</v-col>

<v-col cols="8">
Expand Down Expand Up @@ -140,7 +113,7 @@
</v-col>
<v-col cols="auto">
<v-btn icon
color="primary"
color="accent"
title="Read book"
class="pb-1"
:to="{name: 'read-book', params: { bookId: bookId}}"
Expand Down Expand Up @@ -195,6 +168,7 @@
<script lang="ts">
import Badge from '@/components/Badge.vue'
import EditBooksDialog from '@/components/EditBooksDialog.vue'
import ItemCard from '@/components/ItemCard.vue'
import ToolbarSticky from '@/components/ToolbarSticky.vue'
import { groupAuthorsByRolePlural } from '@/functions/authors'
import { getBookFormatFromMediaType } from '@/functions/book-format'
Expand All @@ -206,7 +180,7 @@ import Vue from 'vue'
export default Vue.extend({
name: 'BrowseBook',
components: { ToolbarSticky, Badge, EditBooksDialog },
components: { ToolbarSticky, Badge, EditBooksDialog, ItemCard },
data: () => {
return {
book: {} as BookDto,
Expand Down Expand Up @@ -288,5 +262,4 @@ export default Vue.extend({
</script>

<style scoped>
@import "../styles/unread-triangle.css";
</style>

0 comments on commit a59f263

Please sign in to comment.