Files
grimmory/booklore-ui/src/app/shared/service/icon-picker.service.ts
T
Aditya Chandel ad0a99bcbc Add support for uploading and assigning custom SVG icons to libraries… (#1788)
* Add support for uploading and assigning custom SVG icons to libraries and shelves

* Add few default icons
2025-12-07 15:16:22 -07:00

33 lines
979 B
TypeScript

import {inject, Injectable} from '@angular/core';
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {IconPickerComponent} from '../components/icon-picker/icon-picker-component';
import {Observable} from 'rxjs';
export interface IconSelection {
type: 'PRIME_NG' | 'CUSTOM_SVG';
value: string;
}
@Injectable({providedIn: 'root'})
export class IconPickerService {
private dialog = inject(DialogService);
open(): Observable<IconSelection> {
const isMobile = window.innerWidth <= 768;
const ref: DynamicDialogRef | null = this.dialog.open(IconPickerComponent, {
header: 'Choose an Icon',
modal: true,
closable: true,
style: {
position: 'absolute',
top: '10%',
bottom: '10%',
width: isMobile ? '90vw' : '800px',
maxWidth: isMobile ? '90vw' : '800px',
minWidth: isMobile ? '90vw' : '800px',
}
});
return ref!.onClose as Observable<IconSelection>;
}
}