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:
+16
-7
@@ -1,13 +1,22 @@
|
||||
<div class="series-card" role="button" tabindex="0" (click)="onCardClick($event)" (keydown.enter)="onCardClick($event)">
|
||||
<div class="stacked-covers" [ngClass]="'covers-' + series.coverBooks.length">
|
||||
@for (book of series.coverBooks; track book.id; let i = $index) {
|
||||
<img
|
||||
[src]="getCoverUrl(i)"
|
||||
class="cover-img"
|
||||
[ngClass]="'cover-' + i"
|
||||
[alt]="series.seriesName"
|
||||
loading="lazy"
|
||||
decoding="async"/>
|
||||
@if (getCoverUrl(i); as coverUrl) {
|
||||
<img
|
||||
[src]="coverUrl"
|
||||
class="cover-img"
|
||||
[ngClass]="'cover-' + i"
|
||||
[alt]="series.seriesName"
|
||||
loading="lazy"
|
||||
decoding="async"/>
|
||||
} @else {
|
||||
<app-cover-placeholder
|
||||
class="cover-img"
|
||||
[ngClass]="'cover-' + i"
|
||||
[title]="book.metadata?.title ?? ''"
|
||||
[author]="(book.metadata?.authors ?? []).join(', ')"
|
||||
size="sm" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ describe('SeriesCardComponent', () => {
|
||||
it('builds thumbnail URLs from ebook and audiobook covers', () => {
|
||||
expect(component.getCoverUrl(0)).toBe('thumb:1:2026-03-01');
|
||||
expect(component.getCoverUrl(1)).toBe('audio:2:2026-03-02');
|
||||
expect(component.getCoverUrl(99)).toBe('');
|
||||
expect(component.getCoverUrl(99)).toBeNull();
|
||||
});
|
||||
|
||||
it('emits a card click and stops propagation', () => {
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@ import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {SeriesSummary} from '../../model/series.model';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-series-card',
|
||||
@@ -14,7 +15,7 @@ import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './series-card.component.html',
|
||||
styleUrls: ['./series-card.component.scss'],
|
||||
imports: [NgClass, ProgressBar, Button, Tooltip, TranslocoPipe]
|
||||
imports: [NgClass, ProgressBar, Button, Tooltip, TranslocoPipe, CoverPlaceholderComponent]
|
||||
})
|
||||
export class SeriesCardComponent {
|
||||
|
||||
@@ -34,9 +35,9 @@ export class SeriesCardComponent {
|
||||
return this.series.authors.slice(0, 2).join(', ') + ' +' + (this.series.authors.length - 2);
|
||||
}
|
||||
|
||||
getCoverUrl(index: number): string {
|
||||
getCoverUrl(index: number): string | null {
|
||||
const book = this.series.coverBooks[index];
|
||||
if (!book) return '';
|
||||
if (!book) return null;
|
||||
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
|
||||
return isAudiobook
|
||||
? this.urlHelper.getAudiobookThumbnailUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)
|
||||
|
||||
Reference in New Issue
Block a user