Add visual polish to book card component (#2788)
This commit is contained in:
+5
-2
@@ -39,7 +39,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if (!_isSeriesViewActive && hasDigitalFile()) {
|
@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) {
|
@if (isCheckboxEnabled) {
|
||||||
@@ -53,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if (hasProgress) {
|
@if (hasProgress) {
|
||||||
<div class="cover-progress-bar-container">
|
<div class="cover-progress-bar-container" [pTooltip]="progressTooltip" tooltipPosition="top">
|
||||||
@if (_progressPercentage !== null) {
|
@if (_progressPercentage !== null) {
|
||||||
<p-progressBar
|
<p-progressBar
|
||||||
[value]="_progressPercentage"
|
[value]="_progressPercentage"
|
||||||
|
|||||||
+33
-4
@@ -1,17 +1,33 @@
|
|||||||
.book-card {
|
.book-card {
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
border-radius: 8px 8px 8px 8px;
|
border-radius: 8px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
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 {
|
&.selected {
|
||||||
border: 2px solid var(--primary-color);
|
border: 2px solid var(--primary-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes shimmer {
|
||||||
|
0% {
|
||||||
|
background-position: -200% 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background-position: 200% 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.cover-container {
|
.cover-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -24,9 +40,18 @@
|
|||||||
justify-content: center;
|
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 {
|
.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;
|
aspect-ratio: 5/7;
|
||||||
background-color: var(--surface-ground);
|
background-color: var(--surface-ground);
|
||||||
}
|
}
|
||||||
@@ -36,13 +61,17 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 8px 8px 0 0;
|
border-radius: 8px 8px 0 0;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.2s ease-in;
|
transition: opacity 0.2s ease-in, transform 0.35s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.book-cover.loaded {
|
.book-cover.loaded {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.book-card:hover .book-cover.loaded {
|
||||||
|
transform: scale(1.04);
|
||||||
|
}
|
||||||
|
|
||||||
.book-cover.square-cover {
|
.book-cover.square-cover {
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|||||||
+36
@@ -91,6 +91,9 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
protected _titleTooltip: string = '';
|
protected _titleTooltip: string = '';
|
||||||
protected _hasProgress: boolean = false;
|
protected _hasProgress: boolean = false;
|
||||||
protected _isAudiobook: 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 metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||||
private destroy$ = new Subject<void>();
|
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._seriesCountTooltip = this.t.translate('book.card.alt.seriesCollapsed', { count: this.book.seriesCount });
|
||||||
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
|
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 {
|
get hasProgress(): boolean {
|
||||||
@@ -195,6 +223,14 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return this._readStatusTooltip;
|
return this._readStatusTooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get progressTooltip(): string {
|
||||||
|
return this._progressTooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
get readButtonIcon(): string {
|
||||||
|
return this._readButtonIcon;
|
||||||
|
}
|
||||||
|
|
||||||
get displayTitle(): string | undefined {
|
get displayTitle(): string | undefined {
|
||||||
return this._displayTitle;
|
return this._displayTitle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,8 @@
|
|||||||
"viewDetails": "View book details",
|
"viewDetails": "View book details",
|
||||||
"readBook": "Read book",
|
"readBook": "Read book",
|
||||||
"playAudiobook": "Play audiobook",
|
"playAudiobook": "Play audiobook",
|
||||||
"bookMenu": "Book actions menu"
|
"bookMenu": "Book actions menu",
|
||||||
|
"continueReading": "Continue reading"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notes": {
|
"notes": {
|
||||||
|
|||||||
@@ -133,7 +133,8 @@
|
|||||||
"viewDetails": "Ver detalles del libro",
|
"viewDetails": "Ver detalles del libro",
|
||||||
"readBook": "Leer libro",
|
"readBook": "Leer libro",
|
||||||
"playAudiobook": "Reproducir audiolibro",
|
"playAudiobook": "Reproducir audiolibro",
|
||||||
"bookMenu": "Menú de acciones del libro"
|
"bookMenu": "Menú de acciones del libro",
|
||||||
|
"continueReading": "Continuar leyendo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notes": {
|
"notes": {
|
||||||
|
|||||||
Reference in New Issue
Block a user