refactor(covers): consolidate cover images into app-cover (#1928)
This commit is contained in:
+7
-9
@@ -2,15 +2,13 @@
|
||||
<div class="sidebar-overlay" role="button" tabindex="0" (click)="onOverlayClick()" (keydown.enter)="onOverlayClick()" [class.closing]="closing()">
|
||||
<aside class="sidebar" role="button" tabindex="0" (click)="$event.stopPropagation()" (keydown.enter)="$event.stopPropagation()" [class.closing]="closing()">
|
||||
<header class="sidebar-header">
|
||||
@if (bookInfo().coverUrl) {
|
||||
<img
|
||||
[src]="bookInfo().coverUrl"
|
||||
alt="Book cover"
|
||||
class="book-cover"
|
||||
/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [title]="bookInfo().title" [author]="bookInfo().authors" size="sm" />
|
||||
}
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
aria-hidden="true"
|
||||
[src]="bookInfo().coverUrl"
|
||||
[title]="bookInfo().title"
|
||||
[authors]="bookInfo().authors"
|
||||
size="sm" />
|
||||
<div class="book-meta">
|
||||
<h2 class="book-title">{{ bookInfo().title }}</h2>
|
||||
@if (bookInfo().authors) {
|
||||
|
||||
@@ -48,7 +48,6 @@ $sidebar-width: 300px;
|
||||
.book-cover {
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
|
||||
flex-shrink: 0;
|
||||
|
||||
+2
-2
@@ -5,14 +5,14 @@ import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {CbxSidebarService, CbxSidebarTab} from './cbx-sidebar.service';
|
||||
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader';
|
||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../../shared/components/cover/cover.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-sidebar',
|
||||
standalone: true,
|
||||
templateUrl: './cbx-sidebar.component.html',
|
||||
styleUrls: ['./cbx-sidebar.component.scss'],
|
||||
imports: [FormsModule, TranslocoPipe, ReaderIconComponent, DatePipe, CoverPlaceholderComponent]
|
||||
imports: [FormsModule, TranslocoPipe, ReaderIconComponent, DatePipe, CoverComponent]
|
||||
})
|
||||
export class CbxSidebarComponent {
|
||||
private readonly sidebarService = inject(CbxSidebarService);
|
||||
|
||||
+6
-5
@@ -9,11 +9,12 @@
|
||||
<div class="dialog-body">
|
||||
<div class="metadata-container">
|
||||
<div class="cover-section">
|
||||
@if (bookCoverUrl) {
|
||||
<img [src]="bookCoverUrl" [alt]="metadata?.title || t('unknown')" class="book-cover">
|
||||
} @else {
|
||||
<app-cover-placeholder class="cover-placeholder" [title]="metadata?.title ?? ''" [author]="(metadata?.authors ?? []).join(', ')" />
|
||||
}
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
[src]="bookCoverUrl"
|
||||
[title]="metadata?.title"
|
||||
[authors]="metadata?.authors ?? []"
|
||||
[alt]="metadata?.title || t('unknown')" />
|
||||
</div>
|
||||
|
||||
<div class="metadata-section">
|
||||
|
||||
@@ -131,29 +131,12 @@
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
|
||||
max-height: 300px;
|
||||
object-fit: cover;
|
||||
|
||||
@media (width <= 768px) {
|
||||
max-height: 240px;
|
||||
}
|
||||
}
|
||||
|
||||
.cover-placeholder {
|
||||
width: 100%;
|
||||
aspect-ratio: 2/3;
|
||||
background: linear-gradient(135deg, color-mix(in srgb, var(--color-white) 4%, transparent) 0%, color-mix(in srgb, var(--color-white) 1%, transparent) 100%);
|
||||
border: 2px dashed color-mix(in srgb, var(--color-white) 12%, transparent);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@media (width <= 768px) {
|
||||
max-height: 240px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.metadata-section {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
@@ -2,12 +2,12 @@ import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Book} from '../../../book/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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reader-book-metadata-dialog',
|
||||
standalone: true,
|
||||
imports: [TranslocoDirective, CoverPlaceholderComponent],
|
||||
imports: [TranslocoDirective, CoverComponent],
|
||||
templateUrl: './metadata-dialog.component.html',
|
||||
styleUrls: ['./metadata-dialog.component.scss']
|
||||
})
|
||||
|
||||
+11
-21
@@ -4,27 +4,17 @@
|
||||
<aside class="sidebar" role="button" tabindex="0" (click)="$event.stopPropagation()" (keydown.enter)="$event.stopPropagation()" [class.closing]="closing()">
|
||||
<!-- Header with book info -->
|
||||
<header class="sidebar-header">
|
||||
@if (bookInfo().coverUrl) {
|
||||
<img
|
||||
[src]="bookInfo().coverUrl"
|
||||
[alt]="t('bookCoverAlt')"
|
||||
class="book-cover"
|
||||
(click)="onCoverClick()"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(keydown.enter)="onCoverClick()"
|
||||
/>
|
||||
} @else {
|
||||
<app-cover-placeholder
|
||||
class="book-cover"
|
||||
[title]="bookInfo().title"
|
||||
[author]="bookInfo().authors"
|
||||
size="sm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(click)="onCoverClick()"
|
||||
(keydown.enter)="onCoverClick()" />
|
||||
}
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
[src]="bookInfo().coverUrl"
|
||||
[title]="bookInfo().title"
|
||||
[authors]="bookInfo().authors"
|
||||
size="sm"
|
||||
[alt]="bookInfo().title || t('bookCoverAlt')"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(click)="onCoverClick()"
|
||||
(keydown.enter)="onCoverClick()" />
|
||||
<div class="book-meta">
|
||||
<h2 class="book-title">{{ bookInfo().title }}</h2>
|
||||
@if (bookInfo().authors) {
|
||||
|
||||
@@ -48,7 +48,6 @@ $sidebar-width: 300px;
|
||||
.book-cover {
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {TocItem} from 'epubjs';
|
||||
import {ReaderSidebarService, SidebarTab} from './sidebar.service';
|
||||
import {ReaderIconComponent} from '../../shared/icon.component';
|
||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {CoverComponent} from '../../../../../shared/components/cover/cover.component';
|
||||
import {DatePipe, NgTemplateOutlet} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
@@ -13,7 +13,7 @@ import {DatePipe, NgTemplateOutlet} from '@angular/common';
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrls: ['./sidebar.component.scss'],
|
||||
imports: [
|
||||
DatePipe, NgTemplateOutlet, FormsModule, TranslocoDirective, ReaderIconComponent, CoverPlaceholderComponent]
|
||||
DatePipe, NgTemplateOutlet, FormsModule, TranslocoDirective, ReaderIconComponent, CoverComponent]
|
||||
})
|
||||
export class ReaderSidebarComponent {
|
||||
private readonly sidebarService = inject(ReaderSidebarService);
|
||||
|
||||
Reference in New Issue
Block a user