ctrl+click will select the book cover (#1133)

This commit is contained in:
Ionuț Staicu
2025-09-13 22:02:27 -06:00
committed by GitHub
parent 49bcb5ab65
commit 3db92c236c
2 changed files with 25 additions and 7 deletions
@@ -1,7 +1,8 @@
<div class="book-card" <div class="book-card"
[class.selected]="isSelected" [class.selected]="isSelected"
(mouseover)="isHovered = true" (mouseover)="isHovered = true"
(mouseout)="isHovered = false"> (mouseout)="isHovered = false"
(click)="onCardClick($event)">
<div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }"> <div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }">
<div <div
@@ -698,21 +698,38 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
this.lastMouseEvent = event; this.lastMouseEvent = event;
} }
toggleSelection(event: CheckboxChangeEvent): void { onCardClick(event: MouseEvent): void {
if (this.isCheckboxEnabled) { if (!event.ctrlKey) {
this.isSelected = event.checked; return;
}
this.toggleCardSelection(!this.isSelected)
}
toggleCardSelection(selected: boolean):void {
if (!this.isCheckboxEnabled) {
return;
}
this.isSelected = selected;
const shiftKey = this.lastMouseEvent?.shiftKey ?? false; const shiftKey = this.lastMouseEvent?.shiftKey ?? false;
this.checkboxClick.emit({ this.checkboxClick.emit({
index: this.index, index: this.index,
bookId: this.book.id, bookId: this.book.id,
selected: event.checked, selected: selected,
shiftKey: shiftKey, shiftKey: shiftKey,
}); });
if (this.onBookSelect) { if (this.onBookSelect) {
this.onBookSelect(this.book.id, event.checked); this.onBookSelect(this.book.id, selected);
} }
this.lastMouseEvent = null; this.lastMouseEvent = null;
} }
toggleSelection(event: CheckboxChangeEvent): void {
this.toggleCardSelection(event.checked);
} }
ngOnDestroy(): void { ngOnDestroy(): void {