refactor(covers): consolidate cover images into app-cover (#1928)
This commit is contained in:
+8
-14
@@ -6,20 +6,14 @@
|
||||
(keydown.enter)="onCardClick($event)">
|
||||
|
||||
<div class="cover-container" [ngClass]="{ 'center-info-btn': isSeriesViewActive() || !hasDigitalFile(), 'audiobook-cover': isAudiobook(), 'square-library-cover': useSquareCovers() }">
|
||||
@if (coverImageUrl(); as url) {
|
||||
<img
|
||||
[src]="url"
|
||||
class="book-cover"
|
||||
[class.square-cover]="isAudiobook() || useSquareCovers()"
|
||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle() })"
|
||||
width="250"
|
||||
[height]="(isAudiobook() || useSquareCovers()) ? 250 : 350"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [class.square-cover]="isAudiobook() || useSquareCovers()" [title]="book().metadata?.title ?? ''" [author]="(book().metadata?.authors ?? []).join(', ')" />
|
||||
}
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
[class.square-cover]="isAudiobook() || useSquareCovers()"
|
||||
[src]="coverImageUrl()"
|
||||
[title]="displayTitle()"
|
||||
[authors]="book().metadata?.authors ?? []"
|
||||
[fit]="(isAudiobook() || useSquareCovers()) ? 'contain' : 'cover'"
|
||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle() })"/>
|
||||
|
||||
<div class="top-left-overlay-stack">
|
||||
@if (showBookTypePill() && displayFormat(); as fmt) {
|
||||
|
||||
-4
@@ -47,10 +47,6 @@
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.book-cover.square-cover {
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.cover-container::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import {CheckboxChangeEvent, Checkbox} 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 {CoverComponent} from '../../../../../shared/components/cover/cover.component';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {EmailService} from '../../../../settings/email-v2/email.service';
|
||||
@@ -31,7 +31,7 @@ import {ButtonDirective} from 'primeng/button';
|
||||
selector: 'app-book-card',
|
||||
templateUrl: './book-card.component.html',
|
||||
styleUrls: ['./book-card.component.scss'],
|
||||
imports: [ButtonDirective, Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
|
||||
imports: [ButtonDirective, Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverComponent],
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
|
||||
+8
-15
@@ -48,21 +48,14 @@
|
||||
(mouseleave)="coverPreviewHide.emit(currentBook.id)"
|
||||
(focusin)="showCoverPreview(coverOrigin)"
|
||||
(focusout)="coverPreviewHide.emit(currentBook.id)">
|
||||
@if (imageUrl) {
|
||||
<img
|
||||
[attr.src]="imageUrl"
|
||||
alt=""
|
||||
class="cover-thumbnail"
|
||||
[class.square-cover]="squareCover" />
|
||||
} @else {
|
||||
<app-cover-placeholder
|
||||
class="cover-thumbnail"
|
||||
aria-hidden="true"
|
||||
[class.square-cover]="squareCover"
|
||||
[title]="currentMetadata.title ?? ''"
|
||||
[author]="(currentMetadata.authors ?? []).join(', ')"
|
||||
size="sm" />
|
||||
}
|
||||
<app-cover
|
||||
class="cover-thumbnail"
|
||||
aria-hidden="true"
|
||||
[class.square-cover]="squareCover"
|
||||
[src]="imageUrl"
|
||||
[title]="currentMetadata.title || currentBook.fileName"
|
||||
[authors]="currentMetadata.authors ?? []"
|
||||
size="sm" />
|
||||
</a>
|
||||
}
|
||||
@case ('readStatus') {
|
||||
|
||||
+2
-1
@@ -79,12 +79,13 @@
|
||||
}
|
||||
|
||||
.cover-thumbnail {
|
||||
width: calc(1.75rem * 5 / 7);
|
||||
height: 1.75rem;
|
||||
aspect-ratio: 5 / 7;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
|
||||
&.square-cover {
|
||||
width: 1.75rem;
|
||||
aspect-ratio: 1 / 1;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -98,12 +98,12 @@ describe('BookTableRowComponent', () => {
|
||||
const host = fixture.nativeElement as HTMLElement;
|
||||
const lockButton = host.querySelector<HTMLButtonElement>('.metadata-lock-button');
|
||||
const coverLink = host.querySelector<HTMLAnchorElement>('.cover-link');
|
||||
const placeholder = host.querySelector<HTMLElement>('app-cover-placeholder');
|
||||
const cover = host.querySelector<HTMLElement>('app-cover');
|
||||
|
||||
expect(lockButton?.getAttribute('aria-label')).toBe('Unlocked');
|
||||
expect(lockButton?.getAttribute('aria-pressed')).toBe('false');
|
||||
expect(coverLink?.getAttribute('aria-label')).toBe('Alpha');
|
||||
expect(placeholder?.getAttribute('aria-hidden')).toBe('true');
|
||||
expect(cover?.getAttribute('aria-hidden')).toBe('true');
|
||||
});
|
||||
|
||||
it('formats file sizes with the matching unit', () => {
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../../shared/components/cover/cover.component';
|
||||
import {AppRatingComponent} from '../../../../../shared/ui/rating/app-rating.component';
|
||||
import {RATING_FIELDS, isMetadataFullyLocked} from './book-table.helpers';
|
||||
|
||||
@@ -86,7 +86,7 @@ const CLICKABLE_FILTER_KEYS: Record<string, string> = {
|
||||
imports: [
|
||||
CdkOverlayOrigin,
|
||||
Checkbox,
|
||||
CoverPlaceholderComponent,
|
||||
CoverComponent,
|
||||
FormsModule,
|
||||
NgClass,
|
||||
AppRatingComponent,
|
||||
|
||||
+7
-13
@@ -94,19 +94,13 @@
|
||||
[cdkConnectedOverlayPush]="true"
|
||||
[cdkConnectedOverlayFlexibleDimensions]="true">
|
||||
<div class="cover-preview">
|
||||
@if (preview.coverUrl; as coverUrl) {
|
||||
<img
|
||||
[attr.src]="coverUrl"
|
||||
[alt]="t('book.table.bookCoverAlt')"
|
||||
class="cover-preview-image"
|
||||
[class.square-cover]="preview.useSquareCover" />
|
||||
} @else {
|
||||
<app-cover-placeholder
|
||||
class="cover-preview-image"
|
||||
[class.square-cover]="preview.useSquareCover"
|
||||
[title]="preview.metadata.title ?? ''"
|
||||
[author]="(preview.metadata.authors ?? []).join(', ')" />
|
||||
}
|
||||
<app-cover
|
||||
class="cover-preview-image"
|
||||
[class.square-cover]="preview.useSquareCover"
|
||||
[src]="preview.coverUrl"
|
||||
[title]="preview.metadata.title"
|
||||
[authors]="preview.metadata.authors ?? []"
|
||||
[alt]="preview.metadata.title || t('book.table.bookCoverAlt')" />
|
||||
</div>
|
||||
</ng-template>
|
||||
}
|
||||
|
||||
-1
@@ -144,7 +144,6 @@
|
||||
width: 100%;
|
||||
max-height: calc(100dvh - 5.25rem);
|
||||
aspect-ratio: 5 / 7;
|
||||
object-fit: cover;
|
||||
border-radius: inherit;
|
||||
|
||||
&.square-cover {
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import {injectVirtualizer} from '@tanstack/angular-virtual';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {RouteScrollPositionService} from '../../../../../shared/service/route-scroll-position.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../../shared/components/cover/cover.component';
|
||||
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
||||
import {patchAppBooksMetadataLockInCache} from '../../../service/book-query-cache';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -70,7 +70,7 @@ const COVER_OVERLAY_POSITIONS: ConnectedPosition[] = [
|
||||
Checkbox,
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
CoverPlaceholderComponent
|
||||
CoverComponent
|
||||
],
|
||||
styleUrls: ['./book-table.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
|
||||
+7
-13
@@ -1,17 +1,11 @@
|
||||
<div class="book-cover-wrapper" [class.audiobook-only]="isAudiobookOnly()" (mouseenter)="isHovered = true" (mouseleave)="isHovered = false">
|
||||
@if (getThumbnailUrl(); as coverUrl) {
|
||||
<img
|
||||
[src]="coverUrl"
|
||||
class="book-cover"
|
||||
alt="Cover of {{ book.metadata?.title }}"
|
||||
width="250"
|
||||
height="350"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" size="sm" />
|
||||
}
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
[src]="getThumbnailUrl()"
|
||||
[title]="book.metadata?.title || book.fileName"
|
||||
[authors]="book.metadata?.authors ?? []"
|
||||
[alt]="book.metadata?.title || book.fileName || ''"
|
||||
size="sm" />
|
||||
|
||||
@if (showSeriesNumber && !book.seriesCount && book.metadata?.seriesNumber !== null && book.metadata?.seriesNumber !== undefined) {
|
||||
<div class="series-number-overlay">
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
.book-cover {
|
||||
width: 100%;
|
||||
aspect-ratio: 5 / 7;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
border-radius: 0.4375rem;
|
||||
}
|
||||
@@ -15,7 +14,6 @@
|
||||
&.audiobook-only {
|
||||
.book-cover {
|
||||
aspect-ratio: 1 / 1;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import {ChangeDetectionStrategy, Component, computed, inject, Input} from '@angular/core';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../shared/components/cover/cover.component';
|
||||
import {Button} from 'primeng/button';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {Router} from '@angular/router';
|
||||
@@ -16,7 +16,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
Button,
|
||||
NgClass,
|
||||
Tooltip,
|
||||
CoverPlaceholderComponent
|
||||
CoverComponent
|
||||
],
|
||||
templateUrl: './book-card-lite-component.html',
|
||||
styleUrl: './book-card-lite-component.scss'
|
||||
|
||||
+7
-8
@@ -186,14 +186,13 @@
|
||||
class="delete-checkbox">
|
||||
</p-checkbox>
|
||||
}
|
||||
@if (urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn); as coverUrl) {
|
||||
<img class="book-cover"
|
||||
[src]="coverUrl"
|
||||
[alt]="book.metadata?.title || ''"
|
||||
loading="lazy"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" size="sm" />
|
||||
}
|
||||
<app-cover class="book-cover"
|
||||
aria-hidden="true"
|
||||
[src]="urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
[title]="book.metadata?.title"
|
||||
[authors]="book.metadata?.authors ?? []"
|
||||
size="sm"
|
||||
loading="lazy" />
|
||||
<div class="book-info">
|
||||
<div class="book-title">{{ book.metadata?.title || ('book.fileAttacher.unknownTitle' | transloco) }}</div>
|
||||
@if (book.metadata?.authors?.length) {
|
||||
|
||||
-1
@@ -204,7 +204,6 @@
|
||||
height: 52px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 3px;
|
||||
object-fit: cover;
|
||||
background: var(--color-card);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ import {BookService} from '../../service/book.service';
|
||||
import {Book, DuplicateDetectionRequest, DuplicateGroup} from '../../model/book.model';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {CoverComponent} from '../../../../shared/components/cover/cover.component';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
|
||||
type PresetMode = 'strict' | 'balanced' | 'aggressive' | 'custom';
|
||||
@@ -40,7 +40,7 @@ interface DisplayGroup extends DuplicateGroup {
|
||||
Paginator,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe,
|
||||
CoverPlaceholderComponent,
|
||||
CoverComponent,
|
||||
],
|
||||
templateUrl: './duplicate-merger.component.html',
|
||||
styleUrls: ['./duplicate-merger.component.scss']
|
||||
|
||||
@@ -32,16 +32,14 @@
|
||||
<div class="series-hero">
|
||||
@if (coverBook(); as coverBook) {
|
||||
<div class="hero-cover-section">
|
||||
@if (getBookCoverUrl(coverBook); as coverUrl) {
|
||||
<img
|
||||
[src]="coverUrl"
|
||||
class="hero-cover-img"
|
||||
[alt]="coverBook.metadata?.title || ''"
|
||||
loading="lazy"
|
||||
decoding="async"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="hero-cover-img" [title]="coverBook.metadata?.title ?? ''" [author]="(coverBook.metadata?.authors ?? []).join(', ')" size="lg" />
|
||||
}
|
||||
<app-cover
|
||||
class="hero-cover-img"
|
||||
[src]="getBookCoverUrl(coverBook)"
|
||||
[title]="coverBook.metadata?.title"
|
||||
[authors]="coverBook.metadata?.authors ?? []"
|
||||
size="lg"
|
||||
[alt]="coverBook.metadata?.title ?? ''"
|
||||
loading="lazy" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -190,14 +188,14 @@
|
||||
tabindex="0"
|
||||
(click)="readBook(nextUp.book.id)"
|
||||
(keydown.enter)="readBook(nextUp.book.id)">
|
||||
@if (nextUp.thumbnailUrl) {
|
||||
<img [src]="nextUp.thumbnailUrl"
|
||||
[alt]="nextUp.book.metadata?.title || ''"
|
||||
class="next-up-thumb"
|
||||
loading="lazy"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="next-up-thumb" [title]="nextUp.book.metadata?.title ?? ''" [author]="(nextUp.book.metadata?.authors ?? []).join(', ')" size="sm" />
|
||||
}
|
||||
<app-cover
|
||||
class="next-up-thumb"
|
||||
aria-hidden="true"
|
||||
[src]="nextUp.thumbnailUrl"
|
||||
[title]="nextUp.book.metadata?.title"
|
||||
[authors]="nextUp.book.metadata?.authors ?? []"
|
||||
size="sm"
|
||||
loading="lazy" />
|
||||
<div class="next-up-info">
|
||||
<span class="next-up-label">
|
||||
<i class="pi pi-bookmark-fill"></i>
|
||||
@@ -321,14 +319,14 @@
|
||||
{{ book.metadata?.seriesNumber !== null && book.metadata?.seriesNumber !== undefined ? '#' + book.metadata?.seriesNumber : '-' }}
|
||||
</span>
|
||||
</div>
|
||||
@if (getBookThumbnailUrl(book); as coverUrl) {
|
||||
<img [src]="coverUrl"
|
||||
[alt]="book.metadata?.title || ''"
|
||||
class="list-thumb"
|
||||
loading="lazy"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="list-thumb" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" size="sm" />
|
||||
}
|
||||
<app-cover
|
||||
class="list-thumb"
|
||||
aria-hidden="true"
|
||||
[src]="getBookThumbnailUrl(book)"
|
||||
[title]="book.metadata?.title"
|
||||
[authors]="book.metadata?.authors ?? []"
|
||||
size="sm"
|
||||
loading="lazy" />
|
||||
<div class="list-book-info">
|
||||
<span class="list-book-title">{{ book.metadata?.title || '' }}</span>
|
||||
<div class="list-book-meta">
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
.hero-cover-img {
|
||||
width: 240px;
|
||||
height: 360px;
|
||||
object-fit: cover;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 6px 24px rgb(0 0 0 / 40%);
|
||||
|
||||
@@ -460,7 +459,6 @@ $meta-card-colors: (
|
||||
.next-up-thumb {
|
||||
width: 2.4063rem;
|
||||
height: 3.5rem;
|
||||
object-fit: cover;
|
||||
border-radius: 0.2188rem;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 6px rgb(0 0 0 / 25%);
|
||||
@@ -618,7 +616,6 @@ $meta-card-colors: (
|
||||
.list-thumb {
|
||||
width: 2.4063rem;
|
||||
height: 3.5rem;
|
||||
object-fit: cover;
|
||||
border-radius: 0.3281rem;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
||||
|
||||
@@ -28,7 +28,7 @@ import {TagComponent} from "../../../../shared/components/tag/tag.component";
|
||||
import {AfterViewChecked, ChangeDetectionStrategy, Component, computed, effect, ElementRef, inject, signal, viewChild} from '@angular/core';
|
||||
import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overlay-preference.service';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../shared/components/cover/cover.component';
|
||||
import {injectQuery} from '@tanstack/angular-query-experimental';
|
||||
import {AuthorService} from '../../../author-browser/service/author.service';
|
||||
import {LayoutService} from '../../../../shared/layout/layout.service';
|
||||
@@ -89,7 +89,7 @@ interface SeriesStats {
|
||||
Divider,
|
||||
TranslocoDirective,
|
||||
TagComponent,
|
||||
CoverPlaceholderComponent,
|
||||
CoverComponent,
|
||||
],
|
||||
})
|
||||
export class SeriesPageComponent implements AfterViewChecked {
|
||||
|
||||
Reference in New Issue
Block a user