refactor(ui): replace SVG artwork placeholders with CSS (#292)

* chore(ui): replace SVG placeholders with CSS alternative

* fix(ui): Placeholder review followup
This commit is contained in:
Alex
2026-04-22 17:26:58 -04:00
committed by Zach Yale
parent 5ac7b5553e
commit 2fd7310e81
34 changed files with 392 additions and 511 deletions
@@ -6,13 +6,17 @@
(keydown.enter)="onCardClick($event)">
<div class="cover-container" [ngClass]="{ 'center-info-btn': _isSeriesViewActive || !hasDigitalFile(), 'audiobook-cover': _isAudiobook, 'square-library-cover': useSquareCovers }">
<img
[src]="coverImageUrl"
class="book-cover"
[class.square-cover]="_isAudiobook || useSquareCovers"
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
loading="lazy"
decoding="async"/>
@if (coverImageUrl) {
<img
[src]="coverImageUrl"
class="book-cover"
[class.square-cover]="_isAudiobook || useSquareCovers"
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
loading="lazy"
decoding="async"/>
} @else {
<app-cover-placeholder class="book-cover" [class.square-cover]="_isAudiobook || useSquareCovers" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" />
}
<div class="top-left-overlay-stack">
@if ((overlayPreferenceService?.showBookTypePill() ?? true) && getDisplayFormat(); as displayFormat) {
@@ -11,6 +11,7 @@ import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox';
import {FormsModule} from '@angular/forms';
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
import {NgClass} from '@angular/common';
import {User, UserService} from '../../../../settings/user-management/user.service';
import {EmailService} from '../../../../settings/email-v2/email.service';
@@ -33,7 +34,7 @@ import {QueryClient} from '@tanstack/angular-query-experimental';
selector: 'app-book-card',
templateUrl: './book-card.component.html',
styleUrls: ['./book-card.component.scss'],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar, TooltipModule, RouterLink, TranslocoPipe],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar, TooltipModule, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush
})
@@ -82,7 +83,7 @@ export class BookCardComponent implements OnInit, OnChanges {
protected _koboProgressPercentage: number | null = null;
protected _displayTitle: string | undefined = undefined;
protected _isSeriesViewActive: boolean = false;
protected _coverImageUrl: string = '';
protected _coverImageUrl: string | null = null;
protected _readStatusIcon: string = '';
protected _readStatusClass: string = '';
protected _readStatusTooltip: string = '';
@@ -214,7 +215,7 @@ export class BookCardComponent implements OnInit, OnChanges {
return this._displayTitle;
}
get coverImageUrl(): string {
get coverImageUrl(): string | null {
return this._coverImageUrl;
}
@@ -51,22 +51,30 @@
</td>
<td>
<a [routerLink]="urlHelper.getBookUrl(book)">
<img
[attr.src]="urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn)"
[alt]="t('bookCoverAlt')"
class="cover-thumbnail"
tooltipPosition="left"
[pTooltip]="tooltipContent"
tooltipStyleClass="cover-tooltip"
/>
@if (urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn); as coverUrl) {
<img
[attr.src]="coverUrl"
[alt]="t('bookCoverAlt')"
class="cover-thumbnail"
tooltipPosition="left"
[pTooltip]="tooltipContent"
tooltipStyleClass="cover-tooltip"
/>
} @else {
<app-cover-placeholder class="cover-thumbnail" [title]="metadata.title ?? ''" [author]="(metadata.authors ?? []).join(', ')" size="sm" />
}
</a>
<ng-template #tooltipContent>
<div class="tooltip-cover-container">
<img
[attr.src]="urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn)"
[alt]="t('bookCoverAlt')"
class="tooltip-cover-image"
/>
@if (urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn); as coverUrl) {
<img
[attr.src]="coverUrl"
[alt]="t('bookCoverAlt')"
class="tooltip-cover-image"
/>
} @else {
<app-cover-placeholder class="tooltip-cover-image" [title]="metadata.title ?? ''" [author]="(metadata.authors ?? []).join(', ')" />
}
<em class="tooltip-cover-title">{{ metadata.title }}</em>
</div>
</ng-template>
@@ -7,6 +7,7 @@ import {TooltipModule} from "primeng/tooltip";
import {Book, BookMetadata, ReadStatus} from '../../../model/book.model';
import {SortOption} from '../../../model/sort.model';
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
import {Button} from 'primeng/button';
import {BookService} from '../../../service/book.service';
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
@@ -29,7 +30,8 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
TooltipModule,
NgClass,
RouterLink,
TranslocoDirective
TranslocoDirective,
CoverPlaceholderComponent
],
styleUrls: ['./book-table.component.scss'],
providers: [DatePipe]