Move book card to own component
WIP: Edit Book's shelf functionality
This commit is contained in:
+3
-3
@@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
.last-read-title-container {
|
||||
|
||||
|
||||
}
|
||||
|
||||
.last-read-title {
|
||||
@@ -73,7 +73,7 @@ p {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.view-btn, .read-btn {
|
||||
.info-btn, .read-btn {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
@@ -82,7 +82,7 @@ p {
|
||||
margin: -60px 0;
|
||||
}
|
||||
|
||||
.book-item:hover .view-btn {
|
||||
.book-item:hover .info-btn {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,3 +11,10 @@
|
||||
<li *ngIf="item.separator" class="menu-separator"></li>
|
||||
</ng-container>
|
||||
</ul>
|
||||
|
||||
<ul class="layout-menu">
|
||||
<ng-container *ngFor="let item of shelfMenu(); let i = index;">
|
||||
<li app-menuitem *ngIf="!item.separator" [item]="item" [index]="i" [root]="true"></li>
|
||||
<li *ngIf="item.separator" class="menu-separator"></li>
|
||||
</ng-container>
|
||||
</ul>
|
||||
|
||||
@@ -27,6 +27,21 @@ export class AppMenuComponent implements OnInit {
|
||||
];
|
||||
});
|
||||
|
||||
shelfMenu = computed(() => {
|
||||
const shelves = this.libraryBookService.shelves();
|
||||
return [
|
||||
{
|
||||
label: 'Shelves',
|
||||
separator: false,
|
||||
items: shelves.map((shelf) => ({
|
||||
label: shelf.name,
|
||||
icon: 'pi pi-fw pi-heart',
|
||||
routerLink: [`/shelf/${shelf.id}/books`],
|
||||
})),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
constructor(private libraryBookService: LibraryAndBookService) {
|
||||
|
||||
}
|
||||
|
||||
@@ -26,15 +26,7 @@
|
||||
<virtual-scroller class="virtual-scroller" #scroll [items]="currentLibraryBooks()">
|
||||
<div class="grid" #container>
|
||||
<div class="virtual-scroller-item" *ngFor="let book of scroll.viewPortItems">
|
||||
<img [src]="coverImageSrc(book.id)" class="book-cover placeholder" alt="Cover of {{ book.metadata.title }}" loading="lazy"/>
|
||||
<div class="book-info">
|
||||
<div class="book-title-container">
|
||||
<h4 class="book-title">{{ book.metadata.title }}</h4>
|
||||
<p-button [text]="true" [rounded]="true" icon="pi pi-ellipsis-v" class="kebab-menu-btn"></p-button>
|
||||
</div>
|
||||
<p-button [rounded]="true" icon="pi pi-eye" class="view-btn" (click)="readBook(book)"></p-button>
|
||||
<p-button [rounded]="true" icon="pi pi-info" class="read-btn" (click)="openBookInfo(book.id, book.libraryId)"></p-button>
|
||||
</div>
|
||||
<app-book-card [book]="book"></app-book-card>
|
||||
</div>
|
||||
</div>
|
||||
</virtual-scroller>
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
.book-title-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.library-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -44,11 +37,8 @@
|
||||
}
|
||||
|
||||
.virtual-scroller-item {
|
||||
background-color: var(--surface-card);
|
||||
height: 243px;
|
||||
width: 150px;
|
||||
border-radius: 8px 8px 0 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.grid {
|
||||
@@ -60,60 +50,3 @@
|
||||
overflow: hidden;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.book-cover {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-color);
|
||||
margin-bottom: 6px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
padding: 6px 6px 3px;
|
||||
}
|
||||
|
||||
.book-authors {
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.4;
|
||||
margin: 0 auto;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.view-btn, .read-btn {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
display: none;
|
||||
margin-top: -40px;
|
||||
transition: opacity 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.virtual-scroller-item:hover .view-btn,
|
||||
.virtual-scroller-item:hover .read-btn {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.virtual-scroller-item:hover .read-btn {
|
||||
top: 70%;
|
||||
}
|
||||
|
||||
.virtual-scroller-item:hover .book-cover {
|
||||
filter: blur(2px);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {Component, computed, OnInit, signal} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {LibraryAndBookService} from '../../service/library-and-book.service';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
@@ -9,8 +8,9 @@ import {DropdownModule} from 'primeng/dropdown';
|
||||
import {LazyLoadImageModule} from 'ng-lazyload-image';
|
||||
import {VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
|
||||
import {SpeedDialModule} from 'primeng/speeddial';
|
||||
import {ConfirmationService, MenuItem, MenuItemCommandEvent, MessageService} from 'primeng/api';
|
||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||
import {ConfirmDialogModule} from 'primeng/confirmdialog';
|
||||
import {BookCardComponent} from '../../../book-card/book-card.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-browser-v2',
|
||||
@@ -24,7 +24,8 @@ import {ConfirmDialogModule} from 'primeng/confirmdialog';
|
||||
LazyLoadImageModule,
|
||||
VirtualScrollerModule,
|
||||
SpeedDialModule,
|
||||
ConfirmDialogModule
|
||||
ConfirmDialogModule,
|
||||
BookCardComponent
|
||||
]
|
||||
})
|
||||
export class LibraryBrowserComponent implements OnInit {
|
||||
@@ -113,20 +114,4 @@ export class LibraryBrowserComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number): string {
|
||||
return this.libraryBookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
|
||||
getAuthorNames(book: Book): string {
|
||||
return book.metadata.authors?.map((author) => author.name).join(', ') || 'No authors available';
|
||||
}
|
||||
|
||||
readBook(book: Book): void {
|
||||
this.libraryBookService.readBook(book);
|
||||
}
|
||||
|
||||
openBookInfo(bookId: number, libraryId: number) {
|
||||
this.router.navigate(['/library', libraryId, 'book', bookId, 'info']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user