Centralize book tag color definitions (#2314)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+2
-2
@@ -349,12 +349,12 @@
|
||||
<span class="metadata-key">File Type:</span>
|
||||
@if (getFileExtension(book?.filePath)) {
|
||||
<span (click)="goToFileType(book?.filePath)" style="cursor: pointer;">
|
||||
<app-tag size="3xs" variant="pill" [color]="getFileTypeColor(getFileExtension(book?.filePath))">
|
||||
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(getFileExtension(book?.filePath))" customTextColor="#fff">
|
||||
{{ (getFileExtension(book?.filePath) | uppercase) || '-' }}
|
||||
</app-tag>
|
||||
</span>
|
||||
} @else {
|
||||
<app-tag size="3xs" variant="pill" [color]="getFileTypeColor(getFileExtension(book?.filePath))">
|
||||
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(getFileExtension(book?.filePath))" customTextColor="#fff">
|
||||
-
|
||||
</app-tag>
|
||||
}
|
||||
|
||||
+4
-22
@@ -721,28 +721,10 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
getFileTypeColor(fileType: string | null | undefined): TagColor {
|
||||
if (!fileType) return 'gray';
|
||||
switch (fileType.toLowerCase()) {
|
||||
case 'pdf':
|
||||
return 'pink';
|
||||
case 'epub':
|
||||
return 'indigo';
|
||||
case 'cbz':
|
||||
return 'teal';
|
||||
case 'cbr':
|
||||
return 'purple';
|
||||
case 'cb7':
|
||||
return 'blue';
|
||||
case 'fb2':
|
||||
return 'orange';
|
||||
case 'mobi':
|
||||
return 'yellow';
|
||||
case 'azw3':
|
||||
return 'green';
|
||||
default:
|
||||
return 'gray';
|
||||
}
|
||||
getFileTypeBgColor(fileType: string | null | undefined): string {
|
||||
if (!fileType) return 'var(--p-gray-500)';
|
||||
const type = fileType.toLowerCase();
|
||||
return `var(--book-type-${type}-color, var(--p-gray-500))`;
|
||||
}
|
||||
|
||||
getStarColorScaled(rating?: number | null, maxScale: number = 5): string {
|
||||
|
||||
Reference in New Issue
Block a user