Add visual polish to book card component (#2788)

This commit is contained in:
ACX
2026-02-17 21:46:36 -07:00
committed by GitHub
parent 47f633c1b2
commit 78f60f0c60
5 changed files with 78 additions and 8 deletions
@@ -39,7 +39,10 @@
}
@if (!_isSeriesViewActive && hasDigitalFile()) {
<p-button [rounded]="true" [icon]="_isAudiobook ? 'pi pi-play' : 'pi pi-book'" class="read-btn" (click)="readBook(book)" [ariaLabel]="_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco)"></p-button>
<p-button [rounded]="true" [icon]="readButtonIcon" class="read-btn" (click)="readBook(book)"
[pTooltip]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : ''"
tooltipPosition="bottom"
[ariaLabel]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : (_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))"></p-button>
}
@if (isCheckboxEnabled) {
@@ -53,7 +56,7 @@
}
@if (hasProgress) {
<div class="cover-progress-bar-container">
<div class="cover-progress-bar-container" [pTooltip]="progressTooltip" tooltipPosition="top">
@if (_progressPercentage !== null) {
<p-progressBar
[value]="_progressPercentage"
@@ -1,17 +1,33 @@
.book-card {
background-color: var(--card-background);
border-radius: 8px 8px 8px 8px;
border-radius: 8px;
position: relative;
overflow: hidden;
height: 100%;
display: flex;
flex-direction: column;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
transition: box-shadow 0.25s ease, transform 0.25s ease;
&:hover {
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
transform: translateY(-2px);
}
&.selected {
border: 2px solid var(--primary-color);
}
}
@keyframes shimmer {
0% {
background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
}
.cover-container {
position: relative;
width: 100%;
@@ -24,9 +40,18 @@
justify-content: center;
}
.cover-container:not(.loaded) {
background: linear-gradient(
90deg,
var(--surface-ground) 25%,
var(--surface-hover, rgba(255, 255, 255, 0.08)) 50%,
var(--surface-ground) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
}
.cover-container.audiobook-cover {
// Use same aspect-ratio as ebooks for uniform virtual scroller row heights.
// The square audiobook cover image will be centered via object-fit: contain.
aspect-ratio: 5/7;
background-color: var(--surface-ground);
}
@@ -36,13 +61,17 @@
height: 100%;
border-radius: 8px 8px 0 0;
opacity: 0;
transition: opacity 0.2s ease-in;
transition: opacity 0.2s ease-in, transform 0.35s ease;
}
.book-cover.loaded {
opacity: 1;
}
.book-card:hover .book-cover.loaded {
transform: scale(1.04);
}
.book-cover.square-cover {
object-fit: contain;
}
@@ -91,6 +91,9 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
protected _titleTooltip: string = '';
protected _hasProgress: boolean = false;
protected _isAudiobook: boolean = false;
protected _progressTooltip: string = '';
protected _isContinueReading: boolean = false;
protected _readButtonIcon: string = 'pi pi-book';
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
private destroy$ = new Subject<void>();
@@ -177,6 +180,31 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
this._seriesCountTooltip = this.t.translate('book.card.alt.seriesCollapsed', { count: this.book.seriesCount });
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
const progressParts: string[] = [];
if (this._progressPercentage !== null) {
progressParts.push(`${this._progressPercentage}% (BookLore)`);
}
if (this._koProgressPercentage !== null) {
progressParts.push(`${this._koProgressPercentage}% (KOReader)`);
}
if (this._koboProgressPercentage !== null) {
progressParts.push(`${this._koboProgressPercentage}% (Kobo)`);
}
this._progressTooltip = progressParts.join(' | ');
const maxProgress = Math.max(
this._progressPercentage ?? 0,
this._koProgressPercentage ?? 0,
this._koboProgressPercentage ?? 0
);
this._isContinueReading = maxProgress > 0 && maxProgress < 100;
if (this._isAudiobook) {
this._readButtonIcon = this._isContinueReading ? 'pi pi-forward' : 'pi pi-play';
} else {
this._readButtonIcon = this._isContinueReading ? 'pi pi-forward' : 'pi pi-book';
}
}
get hasProgress(): boolean {
@@ -195,6 +223,14 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
return this._readStatusTooltip;
}
get progressTooltip(): string {
return this._progressTooltip;
}
get readButtonIcon(): string {
return this._readButtonIcon;
}
get displayTitle(): string | undefined {
return this._displayTitle;
}