From 225824b6f578efe2e88138888107a5132a8739d8 Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <8075870+adityachandelgit@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:53:16 -0600 Subject: [PATCH] Enhance icon picker UI and usability --- .../booklore/service/VersionService.java | 2 +- .../library-creator.component.html | 5 +- .../library-creator.component.ts | 82 +++++++++---------- .../shelf-assigner.component.html | 7 +- .../shelf-assigner.component.ts | 24 +++--- .../shelf-edit-dialog.component.html | 1 - .../shelf-edit-dialog.component.ts | 22 ++--- .../icon-picker-v2-component.ts | 71 ---------------- .../magic-shelf-component.ts | 28 ++----- .../icon-picker-component.html} | 0 .../icon-picker-component.scss} | 0 .../icon-picker-component.ts | 77 +++++++++++++++++ .../icon-picker/icon-picker.component.html | 18 ---- .../icon-picker/icon-picker.component.scss | 32 -------- .../icon-picker/icon-picker.component.ts | 78 ------------------ .../utilities/services/icon-picker.service.ts | 27 ++++++ 16 files changed, 172 insertions(+), 302 deletions(-) delete mode 100644 booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.ts rename booklore-ui/src/app/{icon-picker-v2-component/icon-picker-v2-component.html => utilities/component/icon-picker-component/icon-picker-component.html} (100%) rename booklore-ui/src/app/{icon-picker-v2-component/icon-picker-v2-component.scss => utilities/component/icon-picker-component/icon-picker-component.scss} (100%) create mode 100644 booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.ts delete mode 100644 booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.html delete mode 100644 booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.scss delete mode 100644 booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.ts create mode 100644 booklore-ui/src/app/utilities/services/icon-picker.service.ts diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/VersionService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/VersionService.java index 977937a0b..6091b29c1 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/VersionService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/VersionService.java @@ -21,7 +21,7 @@ public class VersionService { @Value("${app.version:unknown}") private String appVersion; - private static final String GITHUB_REPO = "adityachandelgit/BookLore"; + private static final String GITHUB_REPO = "booklore-app/booklore"; public VersionInfo getVersionInfo() { String latestVersion = fetchLatestGitHubReleaseVersion(); diff --git a/booklore-ui/src/app/book/components/library-creator/library-creator.component.html b/booklore-ui/src/app/book/components/library-creator/library-creator.component.html index 04a6b4bd6..53647d3f0 100644 --- a/booklore-ui/src/app/book/components/library-creator/library-creator.component.html +++ b/booklore-ui/src/app/book/components/library-creator/library-creator.component.html @@ -9,7 +9,7 @@ -
+
@@ -46,7 +46,6 @@ tooltipPosition="right">
-
@@ -63,7 +62,7 @@ -
+
diff --git a/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts b/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts index 7073871f9..152a8910c 100644 --- a/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts +++ b/booklore-ui/src/app/book/components/library-creator/library-creator.component.ts @@ -1,10 +1,9 @@ -import {Component, inject, OnInit, ViewChild} from '@angular/core'; +import {Component, inject, OnInit} from '@angular/core'; import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; import {DirectoryPickerComponent} from '../../../utilities/component/directory-picker/directory-picker.component'; import {MessageService} from 'primeng/api'; import {Router} from '@angular/router'; import {LibraryService} from '../../service/library.service'; -import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component'; import {Button} from 'primeng/button'; import {TableModule} from 'primeng/table'; import {Step, StepList, StepPanel, StepPanels, Stepper} from 'primeng/stepper'; @@ -13,18 +12,16 @@ import {InputText} from 'primeng/inputtext'; import {Library} from '../../model/library.model'; import {ToggleSwitch} from 'primeng/toggleswitch'; import {Tooltip} from 'primeng/tooltip'; +import { IconPickerService } from '../../../utilities/services/icon-picker.service'; @Component({ selector: 'app-library-creator', standalone: true, templateUrl: './library-creator.component.html', - imports: [Button, TableModule, StepPanel, IconPickerComponent, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip], + imports: [Button, TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip], styleUrl: './library-creator.component.scss' }) export class LibraryCreatorComponent implements OnInit { - - @ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined; - chosenLibraryName: string = ''; folders: string[] = []; selectedIcon: string | null = null; @@ -35,13 +32,13 @@ export class LibraryCreatorComponent implements OnInit { directoryPickerDialogRef!: DynamicDialogRef; watch: boolean = false; - private dialogService = inject(DialogService); - private dynamicDialogRef = inject(DynamicDialogRef); + private dialogService = inject(DialogService); + private dynamicDialogRef = inject(DynamicDialogRef); private dynamicDialogConfig = inject(DynamicDialogConfig); - private libraryService = inject(LibraryService); - private messageService = inject(MessageService); - private router = inject(Router); - + private libraryService = inject(LibraryService); + private messageService = inject(MessageService); + private router = inject(Router); + private iconPicker = inject(IconPickerService); ngOnInit(): void { const data = this.dynamicDialogConfig?.data; @@ -59,7 +56,7 @@ export class LibraryCreatorComponent implements OnInit { } } - openDirectoryPicker() { + openDirectoryPicker(): void { this.directoryPickerDialogRef = this.dialogService.open(DirectoryPickerComponent, { header: 'Select Media Directory', modal: true, @@ -74,6 +71,14 @@ export class LibraryCreatorComponent implements OnInit { }); } + openIconPicker(): void { + this.iconPicker.open().subscribe(icon => { + if (icon) { + this.selectedIcon = icon; + } + }); + } + addFolder(folder: string): void { this.folders.push(folder); } @@ -82,17 +87,7 @@ export class LibraryCreatorComponent implements OnInit { this.folders.splice(index, 1); } - openIconPicker() { - if (this.iconPicker) { - this.iconPicker.open(); - } - } - - onIconSelected(icon: string) { - this.selectedIcon = icon; - } - - clearSelectedIcon() { + clearSelectedIcon(): void { this.selectedIcon = null; } @@ -104,7 +99,25 @@ export class LibraryCreatorComponent implements OnInit { return this.folders.length > 0; } - createOrUpdateLibrary() { + validateLibraryNameAndProceed(activateCallback: Function): void { + let trimmedLibraryName = this.chosenLibraryName.trim(); + if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) { + let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName); + if (exists) { + this.messageService.add({ + severity: 'error', + summary: 'Library Name Exists', + detail: 'This library name is already taken.', + }); + } else { + activateCallback(2); + } + } else { + activateCallback(2); + } + } + + createOrUpdateLibrary(): void { if (this.mode === 'edit') { const library: Library = { name: this.chosenLibraryName, @@ -142,23 +155,4 @@ export class LibraryCreatorComponent implements OnInit { }); } } - - validateLibraryNameAndProceed(activateCallback: Function) { - let trimmedLibraryName = this.chosenLibraryName.trim(); - if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) { - let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName); - if (exists) { - this.messageService.add({ - severity: 'error', - summary: 'Library Name Exists', - detail: 'This library name is already taken.', - }); - } else { - activateCallback(2); - } - } else { - activateCallback(2); - } - } - } diff --git a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.html b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.html index bcd3406a8..e85c0b516 100644 --- a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.html +++ b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.html @@ -1,7 +1,7 @@
- + @for (shelf of (shelfState$ | async)?.shelves; track shelf) {
@@ -11,7 +11,6 @@
} -
@@ -21,10 +20,6 @@
- - - -
diff --git a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts index 345eef183..4d37ea85f 100644 --- a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts +++ b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts @@ -1,5 +1,5 @@ -import {Component, inject, OnInit, ViewChild} from '@angular/core'; -import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; +import {Component, inject, OnInit} from '@angular/core'; +import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; import {Book} from '../../model/book.model'; import {MessageService, PrimeTemplate} from 'primeng/api'; import {ShelfService} from '../../service/shelf.service'; @@ -7,14 +7,14 @@ import {Observable} from 'rxjs'; import {BookService} from '../../service/book.service'; import {map, tap} from 'rxjs/operators'; import {Shelf} from '../../model/shelf.model'; -import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component'; import {ShelfState} from '../../model/state/shelf-state.model'; import {Button} from 'primeng/button'; -import { AsyncPipe } from '@angular/common'; +import {AsyncPipe} from '@angular/common'; import {Checkbox} from 'primeng/checkbox'; import {FormsModule} from '@angular/forms'; import {Dialog} from 'primeng/dialog'; import {InputText} from 'primeng/inputtext'; +import {IconPickerService} from '../../../utilities/services/icon-picker.service'; @Component({ selector: 'app-shelf-assigner', @@ -25,7 +25,6 @@ import {InputText} from 'primeng/inputtext'; Checkbox, AsyncPipe, FormsModule, - IconPickerComponent, Dialog, InputText, PrimeTemplate @@ -39,6 +38,7 @@ export class ShelfAssignerComponent implements OnInit { private dynamicDialogRef = inject(DynamicDialogRef); private messageService = inject(MessageService); private bookService = inject(BookService); + private iconPickerService = inject(IconPickerService); shelfState$: Observable = this.shelfService.shelfState$; book: Book = this.dynamicDialogConfig.data.book; @@ -49,8 +49,6 @@ export class ShelfAssignerComponent implements OnInit { isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks; selectedIcon: string | null = null; - @ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined; - ngOnInit(): void { if (!this.isMultiBooks && this.book.shelves) { this.shelfState$.pipe( @@ -124,16 +122,14 @@ export class ShelfAssignerComponent implements OnInit { } openIconPicker() { - if (this.iconPicker) { - this.iconPicker.open(); - } + this.iconPickerService.open().subscribe(icon => { + if (icon) { + this.selectedIcon = icon; + } + }) } clearSelectedIcon() { this.selectedIcon = null; } - - onIconSelected(icon: string) { - this.selectedIcon = icon; - } } diff --git a/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.html b/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.html index abc812cba..6e0b10253 100644 --- a/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.html +++ b/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.html @@ -23,4 +23,3 @@
- diff --git a/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts b/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts index ae0abf825..6f33e30e1 100644 --- a/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts +++ b/booklore-ui/src/app/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts @@ -1,19 +1,18 @@ -import {Component, inject, OnInit, ViewChild} from '@angular/core'; +import {Component, inject, OnInit} from '@angular/core'; import {ShelfService} from '../../service/shelf.service'; -import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; +import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; import {Button} from 'primeng/button'; -import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component'; import {InputText} from 'primeng/inputtext'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {Shelf} from '../../model/shelf.model'; import {MessageService} from 'primeng/api'; +import {IconPickerService} from '../../../utilities/services/icon-picker.service'; @Component({ selector: 'app-shelf-edit-dialog', imports: [ Button, - IconPickerComponent, InputText, ReactiveFormsModule, FormsModule @@ -28,13 +27,12 @@ export class ShelfEditDialogComponent implements OnInit{ private dynamicDialogConfig = inject(DynamicDialogConfig); private dynamicDialogRef = inject(DynamicDialogRef); private messageService = inject(MessageService); + private iconPickerService = inject(IconPickerService); shelfName: string = ''; selectedIcon: string | null = null; shelf!: Shelf | undefined; - @ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined; - ngOnInit(): void { const shelfId = this.dynamicDialogConfig?.data.shelfId; this.shelf = this.shelfService.getShelfById(shelfId); @@ -45,19 +43,17 @@ export class ShelfEditDialogComponent implements OnInit{ } openIconPicker() { - if (this.iconPicker) { - this.iconPicker.open(); - } + this.iconPickerService.open().subscribe(icon => { + if (icon) { + this.selectedIcon = icon; + } + }) } clearSelectedIcon() { this.selectedIcon = null; } - onIconSelected(icon: string) { - this.selectedIcon = icon; - } - save() { const shelf: Shelf = { name: this.shelfName, diff --git a/booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.ts b/booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.ts deleted file mode 100644 index 44e43b0d2..000000000 --- a/booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.ts +++ /dev/null @@ -1,71 +0,0 @@ -import {Component, EventEmitter, inject, Output} from '@angular/core'; -import {FormsModule} from '@angular/forms'; -import {DynamicDialogRef} from 'primeng/dynamicdialog'; - -@Component({ - selector: 'app-icon-picker-v2-component', - imports: [ - FormsModule - ], - templateUrl: './icon-picker-v2-component.html', - styleUrl: './icon-picker-v2-component.scss' -}) -export class IconPickerV2Component { - - iconCategories: string[] = [ - "address-book", "align-center", "align-justify", "align-left", "align-right", "android", - "angle-double-down", "angle-double-left", "angle-double-right", "angle-double-up", "angle-down", "angle-left", - "angle-right", "angle-up", "apple", "arrow-circle-down", "arrow-circle-left", "arrow-circle-right", - "arrow-circle-up", "arrow-down-left-and-arrow-up-right-to-center", "arrow-down-left", "arrow-down-right", "arrow-down", "arrow-left", - "arrow-right-arrow-left", "arrow-right", "arrow-up-left", "arrow-up-right-and-arrow-down-left-from-center", "arrow-up-right", "arrow-up", - "arrows-alt", "arrows-h", "arrows-v", "asterisks", "at", "backward", "ban", "barcode", "bars", "bell-slash", "bell", "bitcoin", - "bolt", "book", "bookmark-fill", "bookmark", "box", "briefcase", "building-columns", "building", "bullseye", "calculator", "calendar-clock", "calendar-minus", - "calendar-plus", "calendar-times", "calendar", "camera", "car", "caret-down", "caret-left", "caret-right", "caret-up", "cart-arrow-down", "cart-minus", "cart-plus", - "chart-bar", "chart-line", "chart-pie", "chart-scatter", "check-circle", "check-square", "check", "chevron-circle-down", "chevron-circle-left", "chevron-circle-right", - "chevron-circle-up", "chevron-down", "chevron-left", "chevron-right", "chevron-up", "circle-fill", "circle-off", "circle-on", "circle", "clipboard", "clock", "clone", "cloud-download", "cloud-upload", - "cloud", "code", "cog", "comment", "comments", "compass", "copy", "credit-card", "crown", "database", "delete-left", "desktop", - "directions-alt", "directions", "discord", "dollar", "download", "eject", "ellipsis-h", "ellipsis-v", "envelope", "equals", "eraser", "ethereum", - "euro", "exclamation-circle", "exclamation-triangle", "expand", "external-link", "eye-slash", "eye", "face-smile", "facebook", "fast-backward", "fast-forward", "file-arrow-up", - "file-check", "file-edit", "file-excel", "file-export", "file-import", "file-o", "file-pdf", "file-plus", "file-word", "file", "filter-fill", "filter-slash", - "filter", "flag-fill", "flag", "folder-open", "folder-plus", "folder", "forward", "gauge", "gift", "github", "globe", "google", - "graduation-cap", "hammer", "hashtag", "headphones", "heart-fill", "heart", "history", "home", "hourglass", "id-card", "image", "images", - "inbox", "indian-rupee", "info-circle", "info", "instagram", "key", "language", "lightbulb", "link", "linkedin", "list-check", "list", - "lock-open", "lock", "map-marker", "map", "mars", "megaphone", "microchip-ai", "microchip", "microphone", "microsoft", "minus-circle", "minus", - "mobile", "money-bill", "moon", "objects-column", "palette", "paperclip", "pause-circle", "pause", "paypal", "pen-to-square", "pencil", "percentage", - "phone", "pinterest", "play-circle", "play", "plus-circle", "plus", "pound", "power-off", "prime", "print", "qrcode", "question-circle", - "question", "receipt", "reddit", "refresh", "replay", "reply", "save", "search-minus", "search-plus", "search", "send", "server", - "share-alt", "shield", "shop", "shopping-bag", "shopping-cart", "sign-in", "sign-out", "sitemap", "slack", "sliders-h", "sliders-v", "sort-alpha-alt-down", - "sort-alpha-alt-up", "sort-alpha-down", "sort-alpha-up", "sort-alt-slash", "sort-alt", "sort-amount-down-alt", "sort-amount-down", "sort-amount-up-alt", - "sort-amount-up", "sort-down-fill", "sort-down", "sort-numeric-alt-down", - "sort-numeric-alt-up", "sort-numeric-down", "sort-numeric-up", "sort-up-fill", "sort-up", "sort", "sparkles", "spinner-dotted", "spinner", "star-fill", "star-half-fill", "star-half", - "star", "step-backward-alt", "step-backward", "step-forward-alt", "step-forward", "stop-circle", "stop", "stopwatch", "sun", "sync", "table", "tablet", - "tag", "tags", "telegram", "th-large", "thumbs-down-fill", "thumbs-down", "thumbs-up-fill", "thumbs-up", "thumbtack", "ticket", "tiktok", "times-circle", - "times", "trash", "trophy", "truck", "turkish-lira", "twitch", "twitter", "undo", "unlock", "upload", "user-edit", "user-minus", - "user-plus", "user", "users", "venus", "verified", "video", "vimeo", "volume-down", "volume-off", "volume-up", "wallet", "warehouse", - "wave-pulse", "whatsapp", "wifi", "window-maximize", "window-minimize", "wrench", "youtube" - ]; - - searchText: string = ''; - selectedIcon: string | null = null; - icons: string[] = this.createIconList(this.iconCategories); - - ref = inject(DynamicDialogRef); - - createIconList(categories: string[]): string[] { - return categories.map(iconName => `pi pi-${iconName}`); - } - - filteredIcons(): string[] { - if (!this.searchText) return this.icons; - return this.icons.filter(icon => icon.toLowerCase().includes(this.searchText.toLowerCase())); - } - - selectIcon(icon: string) { - this.selectedIcon = icon; - this.ref.close(icon); - } - - cancel() { - this.ref.close(); - } -} diff --git a/booklore-ui/src/app/magic-shelf-component/magic-shelf-component.ts b/booklore-ui/src/app/magic-shelf-component/magic-shelf-component.ts index 3ce7f091a..0f2322350 100644 --- a/booklore-ui/src/app/magic-shelf-component/magic-shelf-component.ts +++ b/booklore-ui/src/app/magic-shelf-component/magic-shelf-component.ts @@ -12,11 +12,11 @@ import {LibraryService} from '../book/service/library.service'; import {Library} from '../book/model/library.model'; import {MagicShelfService} from '../magic-shelf-service'; import {MessageService} from 'primeng/api'; -import {IconPickerV2Component} from '../icon-picker-v2-component/icon-picker-v2-component'; -import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; +import {DynamicDialogConfig} from 'primeng/dynamicdialog'; import {Chips} from 'primeng/chips'; import {MultiSelect} from 'primeng/multiselect'; import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../magic-shelf-utils'; +import { IconPickerService } from '../utilities/services/icon-picker.service'; export type RuleOperator = | 'equals' @@ -191,11 +191,11 @@ export class MagicShelfComponent implements OnInit { shelfId: number | null = null; - libraryService = inject(LibraryService); + libraryService = inject(LibraryService); magicShelfService = inject(MagicShelfService); - messageService = inject(MessageService); - dialogService = inject(DialogService); - config = inject(DynamicDialogConfig); + messageService = inject(MessageService); + config = inject(DynamicDialogConfig); + private iconPicker = inject(IconPickerService); trackByFn(ruleCtrl: AbstractControl, index: number): any { return ruleCtrl; @@ -390,21 +390,7 @@ export class MagicShelfComponent implements OnInit { } openIconPicker() { - const isMobile = window.innerWidth <= 768; - const ref: DynamicDialogRef = this.dialogService.open(IconPickerV2Component, { - header: 'Choose an Icon', - style: { - position: 'absolute', - top: '10%', - bottom: '10%', - width: isMobile ? '90vw' : '800px', - maxWidth: isMobile ? '90vw' : '800px', - minWidth: isMobile ? '90vw' : '800px', - }, - dismissableMask: true, - }); - - ref.onClose.subscribe((icon: string) => { + this.iconPicker.open().subscribe(icon => { if (icon) { this.form.get('icon')?.setValue(icon); } diff --git a/booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.html b/booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.html similarity index 100% rename from booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.html rename to booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.html diff --git a/booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.scss b/booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.scss similarity index 100% rename from booklore-ui/src/app/icon-picker-v2-component/icon-picker-v2-component.scss rename to booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.scss diff --git a/booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.ts b/booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.ts new file mode 100644 index 000000000..dbbff34ff --- /dev/null +++ b/booklore-ui/src/app/utilities/component/icon-picker-component/icon-picker-component.ts @@ -0,0 +1,77 @@ +import {Component, EventEmitter, inject, Output} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {DynamicDialogRef} from 'primeng/dynamicdialog'; + +@Component({ + selector: 'app-icon-picker-component', + imports: [ + FormsModule + ], + templateUrl: './icon-picker-component.html', + styleUrl: './icon-picker-component.scss' +}) +export class IconPickerComponent { + + iconCategories: string[] = [ + "address-book", "align-center", "align-justify", "align-left", "align-right", "amazon", "android", + "angle-double-down", "angle-double-left", "angle-double-right", "angle-double-up", "angle-down", "angle-left", + "angle-right", "angle-up", "apple", "arrow-circle-down", "arrow-circle-left", "arrow-circle-right", "arrow-circle-up", + "arrow-down", "arrow-down-left", "arrow-down-left-and-arrow-up-right-to-center", "arrow-down-right", "arrow-left", + "arrow-right", "arrow-right-arrow-left", "arrow-up", "arrow-up-left", "arrow-up-right", "arrow-up-right-and-arrow-down-left-from-center", + "arrows-alt", "arrows-h", "arrows-v", "asterisk", "at", "backward", "ban", "barcode", "bars", "bell", "bell-slash", + "bitcoin", "bolt", "book", "bookmark", "bookmark-fill", "box", "briefcase", "building", "building-columns", "bullseye", + "calculator", "calendar", "calendar-clock", "calendar-minus", "calendar-plus", "calendar-times", "camera", "car", + "caret-down", "caret-left", "caret-right", "caret-up", "cart-arrow-down", "cart-minus", "cart-plus", "chart-bar", + "chart-line", "chart-pie", "chart-scatter", "check", "check-circle", "check-square", "chevron-circle-down", + "chevron-circle-left", "chevron-circle-right", "chevron-circle-up", "chevron-down", "chevron-left", "chevron-right", + "chevron-up", "circle", "circle-fill", "circle-off", "circle-on", "clipboard", "clock", "clone", "cloud", "cloud-download", + "cloud-upload", "code", "cog", "comment", "comments", "compass", "copy", "credit-card", "crown", "database", "delete-left", + "desktop", "directions", "directions-alt", "discord", "dollar", "download", "eject", "ellipsis-h", "ellipsis-v", + "envelope", "equals", "eraser", "ethereum", "euro", "exclamation-circle", "exclamation-triangle", "expand", + "external-link", "eye", "eye-slash", "face-smile", "facebook", "fast-backward", "fast-forward", "file", "file-arrow-up", + "file-check", "file-edit", "file-excel", "file-export", "file-import", "file-o", "file-pdf", "file-plus", "file-word", + "filter", "filter-fill", "filter-slash", "flag", "flag-fill", "folder", "folder-open", "folder-plus", "forward", "gauge", + "gift", "github", "globe", "google", "graduation-cap", "hammer", "hashtag", "headphones", "heart", "heart-fill", "history", + "home", "hourglass", "id-card", "image", "images", "inbox", "indian-rupee", "info", "info-circle", "instagram", "key", + "language", "lightbulb", "link", "linkedin", "list", "list-check", "lock", "lock-open", "map", "map-marker", "mars", "megaphone", + "microchip", "microchip-ai", "microphone", "microsoft", "minus", "minus-circle", "mobile", "money-bill", "moon", "objects-column", + "palette", "paperclip", "pause", "pause-circle", "paypal", "pen-to-square", "pencil", "percentage", "phone", "pinterest", "play", + "play-circle", "plus", "plus-circle", "pound", "power-off", "prime", "print", "qrcode", "question", "question-circle", "receipt", + "reddit", "refresh", "replay", "reply", "save", "search", "search-minus", "search-plus", "send", "server", "share-alt", "shield", + "shop", "shopping-bag", "shopping-cart", "sign-in", "sign-out", "sitemap", "slack", "sliders-h", "sliders-v", "sort", + "sort-alpha-down", "sort-alpha-down-alt", "sort-alpha-up", "sort-alpha-up-alt", "sort-alt", "sort-alt-slash", + "sort-amount-down", "sort-amount-down-alt", "sort-amount-up", "sort-amount-up-alt", "sort-down", "sort-down-fill", + "sort-numeric-down", "sort-numeric-down-alt", "sort-numeric-up", "sort-numeric-up-alt", "sort-up", "sort-up-fill", "sparkles", + "spinner", "spinner-dotted", "star", "star-fill", "star-half", "star-half-fill", "step-backward", "step-backward-alt", + "step-forward", "step-forward-alt", "stop", "stop-circle", "stopwatch", "sun", "sync", "table", "tablet", "tag", "tags", + "telegram", "th-large", "thumbs-down", "thumbs-down-fill", "thumbs-up", "thumbs-up-fill", "thumbtack", "ticket", "tiktok", + "times", "times-circle", "trash", "trophy", "truck", "turkish-lira", "twitch", "twitter", "undo", "unlock", "upload", "user", + "user-edit", "user-minus", "user-plus", "users", "venus", "verified", "video", "vimeo", "volume-down", "volume-off", + "volume-up", "wallet", "warehouse", "wave-pulse", "whatsapp", "wifi", "window-maximize", "window-minimize", "wrench", + "youtube" + ]; + + searchText: string = ''; + selectedIcon: string | null = null; + icons: string[] = this.createIconList(this.iconCategories); + + ref = inject(DynamicDialogRef); + + createIconList(categories: string[]): string[] { + return categories.map(iconName => `pi pi-${iconName}`); + } + + filteredIcons(): string[] { + if (!this.searchText) return this.icons; + return this.icons.filter(icon => icon.toLowerCase().includes(this.searchText.toLowerCase())); + } + + selectIcon(icon: string) { + this.selectedIcon = icon; + this.ref.close(icon); + } + + cancel() { + this.ref.close(); + } +} diff --git a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.html b/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.html deleted file mode 100644 index 7d0827499..000000000 --- a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.html +++ /dev/null @@ -1,18 +0,0 @@ - - -
- @for (icon of filteredIcons(); track icon) { -
- -
- } -
-
diff --git a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.scss b/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.scss deleted file mode 100644 index 1e7731398..000000000 --- a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.scss +++ /dev/null @@ -1,32 +0,0 @@ -.icon-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(25px, 1fr)); - gap: 30px; -} - -.icon-item { - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; -} - -.icon-search { - width: 100%; - padding: 8px 12px; - font-size: 16px; - border: 1px solid var(--text-color-secondary); - border-radius: 4px; - margin-bottom: 15px; - box-sizing: border-box; -} - -.icon-search:focus { - border-color: var(--primary-color); - outline: none; -} - -.icon-search::placeholder { - color: var(--text-color-secondary); - opacity: 1; -} diff --git a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.ts b/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.ts deleted file mode 100644 index b46927ea9..000000000 --- a/booklore-ui/src/app/utilities/component/icon-picker/icon-picker.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; -import {DialogModule} from 'primeng/dialog'; - -import {FormsModule} from '@angular/forms'; - -@Component({ - selector: 'app-icon-picker', - templateUrl: './icon-picker.component.html', - styleUrls: ['./icon-picker.component.scss'], - imports: [ - DialogModule, - FormsModule -], - standalone: true -}) -export class IconPickerComponent { - iconCategories: string[] = [ - "address-book", "align-center", "align-justify", "align-left", "align-right", "android", - "angle-double-down", "angle-double-left", "angle-double-right", "angle-double-up", "angle-down", "angle-left", - "angle-right", "angle-up", "apple", "arrow-circle-down", "arrow-circle-left", "arrow-circle-right", - "arrow-circle-up", "arrow-down-left-and-arrow-up-right-to-center", "arrow-down-left", "arrow-down-right", "arrow-down", "arrow-left", - "arrow-right-arrow-left", "arrow-right", "arrow-up-left", "arrow-up-right-and-arrow-down-left-from-center", "arrow-up-right", "arrow-up", - "arrows-alt", "arrows-h", "arrows-v", "asterisks", "at", "backward", "ban", "barcode", "bars", "bell-slash", "bell", "bitcoin", - "bolt", "book", "bookmark-fill", "bookmark", "box", "briefcase", "building-columns", "building", "bullseye", "calculator", "calendar-clock", "calendar-minus", - "calendar-plus", "calendar-times", "calendar", "camera", "car", "caret-down", "caret-left", "caret-right", "caret-up", "cart-arrow-down", "cart-minus", "cart-plus", - "chart-bar", "chart-line", "chart-pie", "chart-scatter", "check-circle", "check-square", "check", "chevron-circle-down", "chevron-circle-left", "chevron-circle-right", - "chevron-circle-up", "chevron-down", "chevron-left", "chevron-right", "chevron-up", "circle-fill", "circle-off", "circle-on", "circle", "clipboard", "clock", "clone", "cloud-download", "cloud-upload", - "cloud", "code", "cog", "comment", "comments", "compass", "copy", "credit-card", "crown", "database", "delete-left", "desktop", - "directions-alt", "directions", "discord", "dollar", "download", "eject", "ellipsis-h", "ellipsis-v", "envelope", "equals", "eraser", "ethereum", - "euro", "exclamation-circle", "exclamation-triangle", "expand", "external-link", "eye-slash", "eye", "face-smile", "facebook", "fast-backward", "fast-forward", "file-arrow-up", - "file-check", "file-edit", "file-excel", "file-export", "file-import", "file-o", "file-pdf", "file-plus", "file-word", "file", "filter-fill", "filter-slash", - "filter", "flag-fill", "flag", "folder-open", "folder-plus", "folder", "forward", "gauge", "gift", "github", "globe", "google", - "graduation-cap", "hammer", "hashtag", "headphones", "heart-fill", "heart", "history", "home", "hourglass", "id-card", "image", "images", - "inbox", "indian-rupee", "info-circle", "info", "instagram", "key", "language", "lightbulb", "link", "linkedin", "list-check", "list", - "lock-open", "lock", "map-marker", "map", "mars", "megaphone", "microchip-ai", "microchip", "microphone", "microsoft", "minus-circle", "minus", - "mobile", "money-bill", "moon", "objects-column", "palette", "paperclip", "pause-circle", "pause", "paypal", "pen-to-square", "pencil", "percentage", - "phone", "pinterest", "play-circle", "play", "plus-circle", "plus", "pound", "power-off", "prime", "print", "qrcode", "question-circle", - "question", "receipt", "reddit", "refresh", "replay", "reply", "save", "search-minus", "search-plus", "search", "send", "server", - "share-alt", "shield", "shop", "shopping-bag", "shopping-cart", "sign-in", "sign-out", "sitemap", "slack", "sliders-h", "sliders-v", "sort-alpha-alt-down", - "sort-alpha-alt-up", "sort-alpha-down", "sort-alpha-up", "sort-alt-slash", "sort-alt", "sort-amount-down-alt", "sort-amount-down", "sort-amount-up-alt", - "sort-amount-up", "sort-down-fill", "sort-down", "sort-numeric-alt-down", - "sort-numeric-alt-up", "sort-numeric-down", "sort-numeric-up", "sort-up-fill", "sort-up", "sort", "sparkles", "spinner-dotted", "spinner", "star-fill", "star-half-fill", "star-half", - "star", "step-backward-alt", "step-backward", "step-forward-alt", "step-forward", "stop-circle", "stop", "stopwatch", "sun", "sync", "table", "tablet", - "tag", "tags", "telegram", "th-large", "thumbs-down-fill", "thumbs-down", "thumbs-up-fill", "thumbs-up", "thumbtack", "ticket", "tiktok", "times-circle", - "times", "trash", "trophy", "truck", "turkish-lira", "twitch", "twitter", "undo", "unlock", "upload", "user-edit", "user-minus", - "user-plus", "user", "users", "venus", "verified", "video", "vimeo", "volume-down", "volume-off", "volume-up", "wallet", "warehouse", - "wave-pulse", "whatsapp", "wifi", "window-maximize", "window-minimize", "wrench", "youtube" - ]; - - icons: string[] = this.createIconList(this.iconCategories); - iconDialogVisible: boolean = false; - searchText: string = ''; - - selectedIcon: string | null = null; - @Output() iconSelected = new EventEmitter(); - - createIconList(categories: string[]): string[] { - return categories.map(iconName => `pi pi-${iconName}`); - } - - filteredIcons(): string[] { - if (!this.searchText) { - return this.icons; - } - return this.icons.filter(icon => icon.toLowerCase().includes(this.searchText.toLowerCase())); - } - - open() { - this.iconDialogVisible = true; - } - - selectIcon(icon: string) { - this.selectedIcon = icon; - this.iconDialogVisible = false; - this.iconSelected.emit(icon); - } - -} diff --git a/booklore-ui/src/app/utilities/services/icon-picker.service.ts b/booklore-ui/src/app/utilities/services/icon-picker.service.ts new file mode 100644 index 000000000..2c4be03db --- /dev/null +++ b/booklore-ui/src/app/utilities/services/icon-picker.service.ts @@ -0,0 +1,27 @@ +import { Injectable, inject } from '@angular/core'; +import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; +import { IconPickerComponent } from '../component/icon-picker-component/icon-picker-component'; +import { Observable } from 'rxjs'; + +@Injectable({ providedIn: 'root' }) +export class IconPickerService { + private dialog = inject(DialogService); + + open(): Observable { + const isMobile = window.innerWidth <= 768; + const ref: DynamicDialogRef = 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; + } +}