feat(icons): Made icons for libraries and shelves optional with no default icons. (#2599)
* feat(icons): Made icons for libraries and shelves optional with no default icon displayed. * Added tests for making sure the API handles nullable icons for Shelves and Libraries. * Fixed some issues identified during PR review. * Rebased on develop.
This commit is contained in:
+7
-6
@@ -45,17 +45,18 @@
|
||||
/>
|
||||
</div>
|
||||
<label [for]="'shelf-' + shelf.id" class="shelf-label">
|
||||
<div class="shelf-icon-wrapper">
|
||||
@if (shelf.icon) {
|
||||
@if (shelf.icon) {
|
||||
<div class="shelf-icon-wrapper">
|
||||
<app-icon-display
|
||||
[icon]="getShelfIcon(shelf)"
|
||||
size="20px"
|
||||
iconClass="shelf-icon"
|
||||
/>
|
||||
} @else {
|
||||
<i class="pi pi-bookmark shelf-icon"></i>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="shelf-icon-wrapper-empty">
|
||||
</div>
|
||||
}
|
||||
<span class="shelf-name">{{ shelf.name }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
+6
-3
@@ -153,12 +153,15 @@
|
||||
cursor: pointer;
|
||||
min-width: 0;
|
||||
|
||||
.shelf-icon-wrapper, .shelf-icon-wrapper-empty {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.shelf-icon-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
background: var(--overlay-background);
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
@@ -187,7 +190,7 @@
|
||||
.shelf-label {
|
||||
gap: 0.5rem;
|
||||
|
||||
.shelf-icon-wrapper {
|
||||
.shelf-icon-wrapper, .shelf-icon-wrapper-empty {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
||||
|
||||
+3
-3
@@ -123,10 +123,10 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
}
|
||||
|
||||
getShelfIcon(shelf: Shelf): IconSelection {
|
||||
if (shelf.iconType === 'PRIME_NG') {
|
||||
return {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
|
||||
if (shelf.iconType === 'CUSTOM_SVG') {
|
||||
return {type: 'CUSTOM_SVG', value: shelf.icon ?? ""};
|
||||
} else {
|
||||
return {type: 'CUSTOM_SVG', value: shelf.icon};
|
||||
return {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -55,8 +55,8 @@ export class ShelfCreatorComponent {
|
||||
}
|
||||
|
||||
createShelf(): void {
|
||||
const iconValue = this.selectedIcon?.value || 'bookmark';
|
||||
const iconType = this.selectedIcon?.type || 'PRIME_NG';
|
||||
const iconValue = this.selectedIcon?.value ?? null;
|
||||
const iconType = this.selectedIcon?.type ?? null;
|
||||
|
||||
const newShelf: Partial<Shelf> = {
|
||||
name: this.shelfName,
|
||||
|
||||
+8
-6
@@ -47,10 +47,12 @@ export class ShelfEditDialogComponent implements OnInit {
|
||||
if (this.shelf) {
|
||||
this.shelfName = this.shelf.name;
|
||||
this.isPublic = this.shelf.publicShelf ?? false;
|
||||
if (this.shelf.iconType === 'PRIME_NG') {
|
||||
this.selectedIcon = {type: 'PRIME_NG', value: `pi pi-${this.shelf.icon}`};
|
||||
} else {
|
||||
this.selectedIcon = {type: 'CUSTOM_SVG', value: this.shelf.icon};
|
||||
if (this.shelf.iconType && this.shelf.icon) {
|
||||
if (this.shelf.iconType === 'PRIME_NG') {
|
||||
this.selectedIcon = {type: 'PRIME_NG', value: `pi pi-${this.shelf.icon}`};
|
||||
} else {
|
||||
this.selectedIcon = {type: 'CUSTOM_SVG', value: this.shelf.icon};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,8 +70,8 @@ export class ShelfEditDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
const iconValue = this.selectedIcon?.value || 'bookmark';
|
||||
const iconType = this.selectedIcon?.type || 'PRIME_NG';
|
||||
const iconValue = this.selectedIcon?.value ?? null;
|
||||
const iconType = this.selectedIcon?.type ?? null;
|
||||
|
||||
const shelf: Shelf = {
|
||||
name: this.shelfName,
|
||||
|
||||
@@ -4,8 +4,8 @@ import {BookType} from './book.model';
|
||||
export interface Library {
|
||||
id?: number;
|
||||
name: string;
|
||||
icon: string;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG';
|
||||
icon?: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
|
||||
watch: boolean;
|
||||
fileNamingPattern?: string;
|
||||
sort?: SortOption;
|
||||
|
||||
@@ -3,8 +3,8 @@ import {SortOption} from './sort.model';
|
||||
export interface Shelf {
|
||||
id?: number;
|
||||
name: string;
|
||||
icon: string;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG';
|
||||
icon?: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
|
||||
sort?: SortOption;
|
||||
publicShelf?: boolean;
|
||||
userId?: number;
|
||||
|
||||
Reference in New Issue
Block a user