Centralize book tag color definitions (#2314)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-17 22:43:54 -07:00
committed by GitHub
co-authored by acx10
parent e5b1d33bf7
commit cb85604863
6 changed files with 55 additions and 66 deletions
@@ -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>
}
@@ -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 {