-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4fcca2
commit da80d77
Showing
7 changed files
with
86 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@if(imageSrc()) { | ||
<img [src]="imageSrc()" /> | ||
} @else { | ||
<mat-progress-spinner mode="indeterminate" /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:host { | ||
display: grid; | ||
} | ||
|
||
mat-progress-spinner { | ||
margin: 2rem; | ||
} | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: contain; | ||
pointer-events: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
Component, | ||
ChangeDetectionStrategy, | ||
inject, | ||
Input, | ||
computed, | ||
signal, | ||
} from '@angular/core'; | ||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; | ||
|
||
import { PreviewService } from '@app/services/preview.service'; | ||
|
||
@Component({ | ||
selector: 'app-thumb', | ||
templateUrl: './thumb.component.html', | ||
styleUrls: ['./thumb.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [MatProgressSpinnerModule], | ||
}) | ||
export class ThumbnailComponent { | ||
private readonly pagesPreviews = inject(PreviewService).pagesPreviews; | ||
|
||
@Input() | ||
set pageIndex(value: number) { | ||
this.currentPageIndex.set(value); | ||
} | ||
|
||
readonly currentPageIndex = signal<number | undefined>(undefined); | ||
|
||
readonly imageSrc = computed(() => { | ||
const index = this.currentPageIndex(); | ||
const found = this.pagesPreviews()?.find( | ||
(preview) => preview.pageIndex === index | ||
); | ||
|
||
return found?.base64 || undefined; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters