From d0d884a06be463eec5f537ee8a02805c3aad88b6 Mon Sep 17 00:00:00 2001
From: Alex <25013571+alexhb1@users.noreply.github.com>
Date: Thu, 25 Jun 2026 08:57:48 +0100
Subject: [PATCH] refactor(ui): new icon library and user migration (#1828)
---
.../org/booklore/model/enums/IconType.java | 3 +-
.../org/booklore/model/enums/ShelfType.java | 2 +-
.../service/kobo/KoboSettingsService.java | 2 +-
.../service/user/UserDefaultsService.java | 4 +-
.../V144__Migrate_entity_icons_to_lucide.sql | 344 ++++++++++++++++++
.../service/MagicShelfServiceTest.java | 10 +-
.../booklore/service/ShelfServiceTest.java | 10 +-
.../library/LibraryServiceIconTest.java | 12 +-
.../service/user/UserDefaultsServiceTest.java | 2 +-
frontend/angular.json | 5 +
frontend/package.json | 2 +
.../shelf-assigner.component.spec.ts | 8 +-
.../shelf-assigner.component.ts | 10 +-
.../shelf-creator.component.html | 4 +-
.../shelf-creator.component.spec.ts | 15 +-
.../shelf-creator/shelf-creator.component.ts | 3 +-
.../shelf-edit-dialog.component.spec.ts | 25 +-
.../shelf-edit-dialog.component.ts | 9 +-
.../app/features/book/model/library.model.ts | 3 +-
.../app/features/book/model/shelf.model.ts | 3 +-
.../command-palette.component.html | 18 +-
.../command-palette.component.scss | 15 +-
.../command-palette.component.ts | 3 +-
.../command-palette/command-palette.model.ts | 2 +-
.../command-palette.service.spec.ts | 4 +-
.../command-palette.service.ts | 28 +-
.../library-creator.component.html | 20 +-
.../library-creator.component.ts | 10 +-
.../component/magic-shelf-component.ts | 7 +-
.../service/magic-shelf.service.spec.ts | 12 +-
.../service/magic-shelf.service.ts | 5 +-
.../icon-display.component.spec.ts | 84 ++---
.../icon-display/icon-display.component.ts | 92 ++---
.../icon-picker/icon-picker-component.html | 27 +-
.../icon-picker/icon-picker-component.ts | 63 +++-
.../components/icon/app-icon.directive.ts | 90 +++++
.../components/icon/svg-content.directive.ts | 40 ++
.../helpers/icon-categories.helper.spec.ts | 15 -
.../shared/helpers/icon-categories.helper.ts | 44 ---
.../src/app/shared/icons/icon-selection.ts | 9 +
.../app.mobile-topbar.component.html | 6 +-
.../app.mobile-topbar.component.scss | 5 +-
.../app.mobile-topbar.component.spec.ts | 15 +-
.../app.mobile-topbar.component.ts | 3 +-
.../app.sidebar-item-row.component.html | 2 +-
.../app.sidebar-item-row.component.ts | 9 +-
.../app.sidebar-section.component.html | 10 +-
.../app.sidebar-section.component.scss | 3 +-
.../app.sidebar-section.component.ts | 4 +-
.../layout-sidebar/app.sidebar.component.html | 67 ++--
.../layout-sidebar/app.sidebar.component.scss | 15 +-
.../layout-sidebar/app.sidebar.component.ts | 45 ++-
.../layout-sidebar/sidebar-sections.spec.ts | 10 +-
.../layout/layout-sidebar/sidebar-sections.ts | 3 +-
.../shared/layout/navigation/nav-catalog.ts | 28 +-
.../layout/navigation/nav-item.model.ts | 5 +-
.../shared/layout/theme/appearance-options.ts | 9 +-
.../service/icon-picker.service.spec.ts | 6 +-
.../app/shared/service/icon-picker.service.ts | 6 +-
...ec.ts => custom-svg-cache.service.spec.ts} | 8 +-
...service.ts => custom-svg-cache.service.ts} | 15 +-
...ice.spec.ts => custom-svg.service.spec.ts} | 44 +--
...{icon.service.ts => custom-svg.service.ts} | 41 +--
frontend/src/i18n/en/book.json | 1 +
frontend/src/main.ts | 2 +
pnpm-lock.yaml | 23 ++
66 files changed, 963 insertions(+), 486 deletions(-)
create mode 100644 backend/src/main/resources/db/migration/V144__Migrate_entity_icons_to_lucide.sql
create mode 100644 frontend/src/app/shared/components/icon/app-icon.directive.ts
create mode 100644 frontend/src/app/shared/components/icon/svg-content.directive.ts
delete mode 100644 frontend/src/app/shared/helpers/icon-categories.helper.spec.ts
delete mode 100644 frontend/src/app/shared/helpers/icon-categories.helper.ts
create mode 100644 frontend/src/app/shared/icons/icon-selection.ts
rename frontend/src/app/shared/services/{icon-cache.service.spec.ts => custom-svg-cache.service.spec.ts} (74%)
rename frontend/src/app/shared/services/{icon-cache.service.ts => custom-svg-cache.service.ts} (56%)
rename frontend/src/app/shared/services/{icon.service.spec.ts => custom-svg.service.spec.ts} (75%)
rename frontend/src/app/shared/services/{icon.service.ts => custom-svg.service.ts} (68%)
diff --git a/backend/src/main/java/org/booklore/model/enums/IconType.java b/backend/src/main/java/org/booklore/model/enums/IconType.java
index 015e76a4a..dbc82fad2 100644
--- a/backend/src/main/java/org/booklore/model/enums/IconType.java
+++ b/backend/src/main/java/org/booklore/model/enums/IconType.java
@@ -1,7 +1,6 @@
package org.booklore.model.enums;
public enum IconType {
- PRIME_NG,
+ LUCIDE,
CUSTOM_SVG
}
-
diff --git a/backend/src/main/java/org/booklore/model/enums/ShelfType.java b/backend/src/main/java/org/booklore/model/enums/ShelfType.java
index b037961f6..a3c5b6ca0 100644
--- a/backend/src/main/java/org/booklore/model/enums/ShelfType.java
+++ b/backend/src/main/java/org/booklore/model/enums/ShelfType.java
@@ -4,7 +4,7 @@ import lombok.Getter;
@Getter
public enum ShelfType {
- KOBO("Kobo", "pi pi-tablet");
+ KOBO("Kobo", "tablet");
private final String name;
private final String icon;
diff --git a/backend/src/main/java/org/booklore/service/kobo/KoboSettingsService.java b/backend/src/main/java/org/booklore/service/kobo/KoboSettingsService.java
index acb803ce2..b1d54f2b0 100644
--- a/backend/src/main/java/org/booklore/service/kobo/KoboSettingsService.java
+++ b/backend/src/main/java/org/booklore/service/kobo/KoboSettingsService.java
@@ -107,7 +107,7 @@ public class KoboSettingsService {
ShelfCreateRequest.builder()
.name(ShelfType.KOBO.getName())
.icon(ShelfType.KOBO.getIcon())
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.build()
);
}
diff --git a/backend/src/main/java/org/booklore/service/user/UserDefaultsService.java b/backend/src/main/java/org/booklore/service/user/UserDefaultsService.java
index d9f80bee9..52dd41c6a 100644
--- a/backend/src/main/java/org/booklore/service/user/UserDefaultsService.java
+++ b/backend/src/main/java/org/booklore/service/user/UserDefaultsService.java
@@ -25,7 +25,7 @@ public class UserDefaultsService {
.user(user)
.name("Favorites")
.icon("heart")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.build();
shelfRepository.save(shelf);
}
@@ -52,4 +52,4 @@ public class UserDefaultsService {
log.error("Error serializing setting {} for user {}", key, user.getUsername(), e);
}
}
-}
\ No newline at end of file
+}
diff --git a/backend/src/main/resources/db/migration/V144__Migrate_entity_icons_to_lucide.sql b/backend/src/main/resources/db/migration/V144__Migrate_entity_icons_to_lucide.sql
new file mode 100644
index 000000000..dcba5adab
--- /dev/null
+++ b/backend/src/main/resources/db/migration/V144__Migrate_entity_icons_to_lucide.sql
@@ -0,0 +1,344 @@
+-- Migrates Prime icons to Lucide. Brand-logo icons without a close Lucide replacement use the default book icon.
+CREATE TEMPORARY TABLE prime_to_lucide_icon_map (
+ prime_icon VARCHAR(64) NOT NULL PRIMARY KEY,
+ lucide_icon VARCHAR(64) NOT NULL
+);
+
+INSERT INTO prime_to_lucide_icon_map (prime_icon, lucide_icon) VALUES
+ ('address-book', 'contact'),
+ ('align-center', 'text-align-center'),
+ ('align-justify', 'text-align-justify'),
+ ('align-left', 'text-align-start'),
+ ('align-right', 'text-align-end'),
+ ('amazon', 'book'),
+ ('android', 'book'),
+ ('angle-double-down', 'chevrons-down'),
+ ('angle-double-left', 'chevrons-left'),
+ ('angle-double-right', 'chevrons-right'),
+ ('angle-double-up', 'chevrons-up'),
+ ('angle-down', 'chevron-down'),
+ ('angle-left', 'chevron-left'),
+ ('angle-right', 'chevron-right'),
+ ('angle-up', 'chevron-up'),
+ ('apple', 'book'),
+ ('arrow-circle-down', 'circle-arrow-down'),
+ ('arrow-circle-left', 'circle-arrow-left'),
+ ('arrow-circle-right', 'circle-arrow-right'),
+ ('arrow-circle-up', 'circle-arrow-up'),
+ ('arrow-down', 'arrow-down'),
+ ('arrow-down-left', 'arrow-down-left'),
+ ('arrow-down-left-and-arrow-up-right-to-center', 'shrink'),
+ ('arrow-down-right', 'arrow-down-right'),
+ ('arrow-left', 'arrow-left'),
+ ('arrow-right', 'arrow-right'),
+ ('arrow-right-arrow-left', 'arrow-right-left'),
+ ('arrow-up', 'arrow-up'),
+ ('arrow-up-left', 'arrow-up-left'),
+ ('arrow-up-right', 'arrow-up-right'),
+ ('arrow-up-right-and-arrow-down-left-from-center', 'expand'),
+ ('arrows-alt', 'move'),
+ ('arrows-h', 'move-horizontal'),
+ ('arrows-v', 'move-vertical'),
+ ('asterisk', 'asterisk'),
+ ('at', 'at-sign'),
+ ('backward', 'rewind'),
+ ('ban', 'ban'),
+ ('barcode', 'barcode'),
+ ('bars', 'menu'),
+ ('bell', 'bell'),
+ ('bell-slash', 'bell-off'),
+ ('bitcoin', 'bitcoin'),
+ ('bolt', 'zap'),
+ ('book', 'book'),
+ ('bookmark', 'bookmark'),
+ ('bookmark-fill', 'bookmark'),
+ ('box', 'box'),
+ ('briefcase', 'briefcase'),
+ ('building', 'building'),
+ ('building-columns', 'building-2'),
+ ('bullseye', 'target'),
+ ('calculator', 'calculator'),
+ ('calendar', 'calendar'),
+ ('calendar-clock', 'calendar-clock'),
+ ('calendar-minus', 'calendar-minus'),
+ ('calendar-plus', 'calendar-plus'),
+ ('calendar-times', 'calendar-x'),
+ ('camera', 'camera'),
+ ('car', 'car'),
+ ('caret-down', 'chevron-down'),
+ ('caret-left', 'chevron-left'),
+ ('caret-right', 'chevron-right'),
+ ('caret-up', 'chevron-up'),
+ ('cart-arrow-down', 'shopping-cart'),
+ ('cart-minus', 'shopping-cart'),
+ ('cart-plus', 'shopping-cart'),
+ ('chart-bar', 'chart-column'),
+ ('chart-line', 'chart-line'),
+ ('chart-pie', 'chart-pie'),
+ ('chart-scatter', 'chart-scatter'),
+ ('check', 'check'),
+ ('check-circle', 'circle-check'),
+ ('check-square', 'square-check'),
+ ('chevron-circle-down', 'circle-chevron-down'),
+ ('chevron-circle-left', 'circle-chevron-left'),
+ ('chevron-circle-right', 'circle-chevron-right'),
+ ('chevron-circle-up', 'circle-chevron-up'),
+ ('chevron-down', 'chevron-down'),
+ ('chevron-left', 'chevron-left'),
+ ('chevron-right', 'chevron-right'),
+ ('chevron-up', 'chevron-up'),
+ ('circle', 'circle'),
+ ('circle-fill', 'circle'),
+ ('circle-off', 'circle-slash'),
+ ('circle-on', 'circle'),
+ ('clipboard', 'clipboard'),
+ ('clock', 'clock'),
+ ('clone', 'copy'),
+ ('cloud', 'cloud'),
+ ('cloud-download', 'cloud-download'),
+ ('cloud-upload', 'cloud-upload'),
+ ('code', 'code'),
+ ('cog', 'settings'),
+ ('comment', 'message-circle'),
+ ('comments', 'messages-square'),
+ ('compass', 'compass'),
+ ('copy', 'copy'),
+ ('credit-card', 'credit-card'),
+ ('crown', 'crown'),
+ ('database', 'database'),
+ ('delete-left', 'delete'),
+ ('desktop', 'monitor'),
+ ('directions', 'navigation'),
+ ('directions-alt', 'navigation-2'),
+ ('discord', 'book'),
+ ('dollar', 'dollar-sign'),
+ ('download', 'download'),
+ ('eject', 'unplug'),
+ ('ellipsis-h', 'ellipsis'),
+ ('ellipsis-v', 'ellipsis-vertical'),
+ ('envelope', 'mail'),
+ ('equals', 'equal'),
+ ('eraser', 'eraser'),
+ ('ethereum', 'book'),
+ ('euro', 'euro'),
+ ('exclamation-circle', 'circle-alert'),
+ ('exclamation-triangle', 'triangle-alert'),
+ ('expand', 'expand'),
+ ('external-link', 'external-link'),
+ ('eye', 'eye'),
+ ('eye-slash', 'eye-off'),
+ ('facebook', 'book'),
+ ('face-smile', 'smile'),
+ ('fast-backward', 'skip-back'),
+ ('fast-forward', 'skip-forward'),
+ ('file', 'file'),
+ ('file-arrow-up', 'file-up'),
+ ('file-check', 'file-check'),
+ ('file-edit', 'file-pen'),
+ ('file-excel', 'file-spreadsheet'),
+ ('file-export', 'file-output'),
+ ('file-import', 'file-input'),
+ ('file-o', 'file'),
+ ('file-pdf', 'file-text'),
+ ('file-plus', 'file-plus'),
+ ('file-word', 'file-text'),
+ ('filter', 'funnel'),
+ ('filter-fill', 'funnel'),
+ ('filter-slash', 'funnel-x'),
+ ('flag', 'flag'),
+ ('flag-fill', 'flag'),
+ ('folder', 'folder'),
+ ('folder-open', 'folder-open'),
+ ('folder-plus', 'folder-plus'),
+ ('forward', 'fast-forward'),
+ ('gauge', 'gauge'),
+ ('gift', 'gift'),
+ ('github', 'book'),
+ ('globe', 'globe'),
+ ('google', 'book'),
+ ('graduation-cap', 'graduation-cap'),
+ ('hammer', 'hammer'),
+ ('hashtag', 'hash'),
+ ('headphones', 'headphones'),
+ ('heart', 'heart'),
+ ('heart-fill', 'heart'),
+ ('history', 'history'),
+ ('home', 'house'),
+ ('hourglass', 'hourglass'),
+ ('id-card', 'id-card'),
+ ('image', 'image'),
+ ('images', 'images'),
+ ('instagram', 'book'),
+ ('inbox', 'inbox'),
+ ('indian-rupee', 'indian-rupee'),
+ ('info', 'info'),
+ ('info-circle', 'info'),
+ ('key', 'key'),
+ ('language', 'languages'),
+ ('lightbulb', 'lightbulb'),
+ ('link', 'link'),
+ ('linkedin', 'book'),
+ ('list', 'list'),
+ ('list-check', 'list-checks'),
+ ('lock', 'lock'),
+ ('lock-open', 'lock-open'),
+ ('map', 'map'),
+ ('map-marker', 'map-pin'),
+ ('mars', 'mars'),
+ ('megaphone', 'megaphone'),
+ ('microchip', 'cpu'),
+ ('microchip-ai', 'brain-circuit'),
+ ('microphone', 'mic'),
+ ('microsoft', 'book'),
+ ('minus', 'minus'),
+ ('minus-circle', 'circle-minus'),
+ ('mobile', 'smartphone'),
+ ('money-bill', 'banknote'),
+ ('moon', 'moon'),
+ ('objects-column', 'columns-3'),
+ ('palette', 'palette'),
+ ('paperclip', 'paperclip'),
+ ('paypal', 'book'),
+ ('pause', 'pause'),
+ ('pause-circle', 'circle-pause'),
+ ('pen-to-square', 'square-pen'),
+ ('pencil', 'pencil'),
+ ('percentage', 'percent'),
+ ('phone', 'phone'),
+ ('pinterest', 'book'),
+ ('play', 'play'),
+ ('play-circle', 'circle-play'),
+ ('plus', 'plus'),
+ ('plus-circle', 'circle-plus'),
+ ('pound', 'pound-sterling'),
+ ('power-off', 'power'),
+ ('prime', 'sparkles'),
+ ('print', 'printer'),
+ ('qrcode', 'qr-code'),
+ ('question', 'circle-question-mark'),
+ ('question-circle', 'circle-question-mark'),
+ ('receipt', 'receipt'),
+ ('reddit', 'book'),
+ ('refresh', 'rotate-cw'),
+ ('replay', 'rotate-ccw'),
+ ('reply', 'reply'),
+ ('save', 'save'),
+ ('search', 'search'),
+ ('search-minus', 'zoom-out'),
+ ('search-plus', 'zoom-in'),
+ ('send', 'send'),
+ ('server', 'server'),
+ ('share-alt', 'share-2'),
+ ('shield', 'shield'),
+ ('shop', 'store'),
+ ('shopping-bag', 'shopping-bag'),
+ ('shopping-cart', 'shopping-cart'),
+ ('sign-in', 'log-in'),
+ ('sign-out', 'log-out'),
+ ('sitemap', 'network'),
+ ('slack', 'book'),
+ ('sliders-h', 'sliders-horizontal'),
+ ('sliders-v', 'sliders-vertical'),
+ ('sort', 'arrow-up-down'),
+ ('sort-alpha-down', 'arrow-down-a-z'),
+ ('sort-alpha-down-alt', 'arrow-down-z-a'),
+ ('sort-alpha-up', 'arrow-up-a-z'),
+ ('sort-alpha-up-alt', 'arrow-up-z-a'),
+ ('sort-alt', 'arrow-up-down'),
+ ('sort-alt-slash', 'arrow-up-down'),
+ ('sort-amount-down', 'arrow-down-wide-narrow'),
+ ('sort-amount-down-alt', 'arrow-down-narrow-wide'),
+ ('sort-amount-up', 'arrow-up-narrow-wide'),
+ ('sort-amount-up-alt', 'arrow-up-wide-narrow'),
+ ('sort-down', 'chevron-down'),
+ ('sort-down-fill', 'chevron-down'),
+ ('sort-numeric-down', 'arrow-down-0-1'),
+ ('sort-numeric-down-alt', 'arrow-down-1-0'),
+ ('sort-numeric-up', 'arrow-up-0-1'),
+ ('sort-numeric-up-alt', 'arrow-up-1-0'),
+ ('sort-up', 'chevron-up'),
+ ('sort-up-fill', 'chevron-up'),
+ ('sparkles', 'sparkles'),
+ ('spinner', 'loader-circle'),
+ ('spinner-dotted', 'loader'),
+ ('star', 'star'),
+ ('star-fill', 'star'),
+ ('star-half', 'star-half'),
+ ('star-half-fill', 'star-half'),
+ ('step-backward', 'skip-back'),
+ ('step-backward-alt', 'skip-back'),
+ ('step-forward', 'skip-forward'),
+ ('step-forward-alt', 'skip-forward'),
+ ('stop', 'square'),
+ ('stop-circle', 'circle-stop'),
+ ('stopwatch', 'timer'),
+ ('sun', 'sun'),
+ ('sync', 'refresh-cw'),
+ ('table', 'table'),
+ ('tablet', 'tablet'),
+ ('tag', 'tag'),
+ ('tags', 'tags'),
+ ('telegram', 'book'),
+ ('th-large', 'layout-grid'),
+ ('thumbs-down', 'thumbs-down'),
+ ('thumbs-down-fill', 'thumbs-down'),
+ ('thumbs-up', 'thumbs-up'),
+ ('thumbs-up-fill', 'thumbs-up'),
+ ('thumbtack', 'pin'),
+ ('ticket', 'ticket'),
+ ('tiktok', 'book'),
+ ('times', 'x'),
+ ('times-circle', 'circle-x'),
+ ('trash', 'trash-2'),
+ ('trophy', 'trophy'),
+ ('truck', 'truck'),
+ ('turkish-lira', 'turkish-lira'),
+ ('twitch', 'book'),
+ ('twitter', 'book'),
+ ('undo', 'undo'),
+ ('unlock', 'lock-open'),
+ ('upload', 'upload'),
+ ('user', 'user'),
+ ('user-edit', 'user-pen'),
+ ('user-minus', 'user-minus'),
+ ('user-plus', 'user-plus'),
+ ('users', 'users'),
+ ('venus', 'venus'),
+ ('verified', 'badge-check'),
+ ('video', 'video'),
+ ('vimeo', 'book'),
+ ('volume-down', 'volume-1'),
+ ('volume-off', 'volume-x'),
+ ('volume-up', 'volume-2'),
+ ('wallet', 'wallet'),
+ ('warehouse', 'warehouse'),
+ ('wave-pulse', 'activity'),
+ ('whatsapp', 'book'),
+ ('wifi', 'wifi'),
+ ('window-maximize', 'maximize'),
+ ('window-minimize', 'minimize'),
+ ('wrench', 'wrench'),
+ ('youtube', 'book');
+
+UPDATE library
+LEFT JOIN prime_to_lucide_icon_map
+ ON REPLACE(REPLACE(library.icon, 'pi pi-', ''), 'pi-', '') = prime_to_lucide_icon_map.prime_icon
+SET library.icon = COALESCE(prime_to_lucide_icon_map.lucide_icon, IF(library.icon IS NULL, NULL, 'book')),
+ library.icon_type = IF(library.icon IS NULL, NULL, 'LUCIDE')
+WHERE library.icon_type = 'PRIME_NG';
+
+UPDATE shelf
+LEFT JOIN prime_to_lucide_icon_map
+ ON REPLACE(REPLACE(shelf.icon, 'pi pi-', ''), 'pi-', '') = prime_to_lucide_icon_map.prime_icon
+SET shelf.icon = COALESCE(prime_to_lucide_icon_map.lucide_icon, IF(shelf.icon IS NULL, NULL, 'book')),
+ shelf.icon_type = IF(shelf.icon IS NULL, NULL, 'LUCIDE')
+WHERE shelf.icon_type = 'PRIME_NG';
+
+UPDATE magic_shelf
+LEFT JOIN prime_to_lucide_icon_map
+ ON REPLACE(REPLACE(magic_shelf.icon, 'pi pi-', ''), 'pi-', '') = prime_to_lucide_icon_map.prime_icon
+SET magic_shelf.icon = COALESCE(prime_to_lucide_icon_map.lucide_icon, IF(magic_shelf.icon IS NULL, NULL, 'book')),
+ magic_shelf.icon_type = IF(magic_shelf.icon IS NULL, NULL, 'LUCIDE')
+WHERE magic_shelf.icon_type = 'PRIME_NG';
+
+DROP TEMPORARY TABLE prime_to_lucide_icon_map;
diff --git a/backend/src/test/java/org/booklore/service/MagicShelfServiceTest.java b/backend/src/test/java/org/booklore/service/MagicShelfServiceTest.java
index 41cf36d28..60e5bfa2d 100644
--- a/backend/src/test/java/org/booklore/service/MagicShelfServiceTest.java
+++ b/backend/src/test/java/org/booklore/service/MagicShelfServiceTest.java
@@ -77,7 +77,7 @@ class MagicShelfServiceTest {
MagicShelf dto = new MagicShelf();
dto.setName("Favorites");
dto.setIcon("star");
- dto.setIconType(IconType.PRIME_NG);
+ dto.setIconType(IconType.LUCIDE);
dto.setFilterJson("{\"rating\": 5}");
dto.setIsPublic(false);
@@ -93,7 +93,7 @@ class MagicShelfServiceTest {
assertNotNull(result);
assertEquals("star", result.getIcon());
- assertEquals(IconType.PRIME_NG, result.getIconType());
+ assertEquals(IconType.LUCIDE, result.getIconType());
}
@Test
@@ -103,7 +103,7 @@ class MagicShelfServiceTest {
.userId(1L)
.name("Old Shelf")
.icon("star")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.filterJson("{\"status\": \"reading\"}")
.build();
@@ -137,7 +137,7 @@ class MagicShelfServiceTest {
.userId(1L)
.name("Old Shelf")
.icon("star")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.filterJson("{\"status\": \"reading\"}")
.build();
@@ -170,7 +170,7 @@ class MagicShelfServiceTest {
.userId(1L)
.name("Shelf With Icon")
.icon("heart")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.filterJson("{}")
.build();
diff --git a/backend/src/test/java/org/booklore/service/ShelfServiceTest.java b/backend/src/test/java/org/booklore/service/ShelfServiceTest.java
index 3a9d4df0a..a5dfe73fa 100644
--- a/backend/src/test/java/org/booklore/service/ShelfServiceTest.java
+++ b/backend/src/test/java/org/booklore/service/ShelfServiceTest.java
@@ -84,7 +84,7 @@ class ShelfServiceTest {
ShelfCreateRequest request = ShelfCreateRequest.builder()
.name("My Shelf")
.icon("heart")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.build();
when(authenticationService.getAuthenticatedUser()).thenReturn(user);
@@ -92,7 +92,7 @@ class ShelfServiceTest {
when(userRepository.findById(1L)).thenReturn(Optional.of(userEntity));
when(shelfRepository.save(any(ShelfEntity.class))).thenAnswer(invocation -> invocation.getArgument(0));
when(shelfMapper.toShelf(any(ShelfEntity.class))).thenReturn(
- Shelf.builder().name("My Shelf").icon("heart").iconType(IconType.PRIME_NG).build());
+ Shelf.builder().name("My Shelf").icon("heart").iconType(IconType.LUCIDE).build());
shelfService.createShelf(request);
@@ -101,7 +101,7 @@ class ShelfServiceTest {
ShelfEntity saved = captor.getValue();
assertEquals("heart", saved.getIcon());
- assertEquals(IconType.PRIME_NG, saved.getIconType());
+ assertEquals(IconType.LUCIDE, saved.getIconType());
}
@Test
@@ -110,7 +110,7 @@ class ShelfServiceTest {
.id(1L)
.name("Old Shelf")
.icon("star")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.user(userEntity)
.build();
@@ -141,7 +141,7 @@ class ShelfServiceTest {
.id(1L)
.name("Old Shelf")
.icon("star")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.user(userEntity)
.build();
diff --git a/backend/src/test/java/org/booklore/service/library/LibraryServiceIconTest.java b/backend/src/test/java/org/booklore/service/library/LibraryServiceIconTest.java
index 8e659e493..4822b700e 100644
--- a/backend/src/test/java/org/booklore/service/library/LibraryServiceIconTest.java
+++ b/backend/src/test/java/org/booklore/service/library/LibraryServiceIconTest.java
@@ -88,7 +88,7 @@ class LibraryServiceIconTest {
.id(1L)
.name("My Library")
.icon("book")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.libraryPaths(new ArrayList<>())
.watch(false)
.build();
@@ -122,7 +122,7 @@ class LibraryServiceIconTest {
.id(1L)
.name("My Library")
.icon("book")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.libraryPaths(new ArrayList<>())
.watch(false)
.build();
@@ -156,7 +156,7 @@ class LibraryServiceIconTest {
.id(1L)
.name("Library With Icon")
.icon("star")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.libraryPaths(new ArrayList<>())
.watch(false)
.build();
@@ -218,7 +218,7 @@ class LibraryServiceIconTest {
CreateLibraryRequest request = CreateLibraryRequest.builder()
.name("Icon Library")
.icon("book")
- .iconType(IconType.PRIME_NG)
+ .iconType(IconType.LUCIDE)
.paths(Collections.emptyList())
.watch(false)
.build();
@@ -231,7 +231,7 @@ class LibraryServiceIconTest {
return entity;
});
when(libraryMapper.toLibrary(any(LibraryEntity.class))).thenReturn(
- Library.builder().name("Icon Library").icon("book").iconType(IconType.PRIME_NG).build());
+ Library.builder().name("Icon Library").icon("book").iconType(IconType.LUCIDE).build());
libraryService.createLibrary(request);
@@ -240,6 +240,6 @@ class LibraryServiceIconTest {
LibraryEntity saved = captor.getValue();
assertEquals("book", saved.getIcon());
- assertEquals(IconType.PRIME_NG, saved.getIconType());
+ assertEquals(IconType.LUCIDE, saved.getIconType());
}
}
diff --git a/backend/src/test/java/org/booklore/service/user/UserDefaultsServiceTest.java b/backend/src/test/java/org/booklore/service/user/UserDefaultsServiceTest.java
index a5925f782..b901344f9 100644
--- a/backend/src/test/java/org/booklore/service/user/UserDefaultsServiceTest.java
+++ b/backend/src/test/java/org/booklore/service/user/UserDefaultsServiceTest.java
@@ -46,7 +46,7 @@ class UserDefaultsServiceTest {
ShelfEntity saved = captor.getValue();
assertEquals("Favorites", saved.getName());
assertEquals("heart", saved.getIcon());
- assertEquals(IconType.PRIME_NG, saved.getIconType());
+ assertEquals(IconType.LUCIDE, saved.getIconType());
assertEquals(user, saved.getUser());
}
diff --git a/frontend/angular.json b/frontend/angular.json
index 631e31326..9a62402c8 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -50,6 +50,11 @@
"glob": "**/*",
"input": "node_modules/@embedpdf/snippet/dist/",
"output": "/assets/embedpdf/"
+ },
+ {
+ "glob": "**/*.svg",
+ "input": "node_modules/lucide-static/icons",
+ "output": "/assets/lucide/"
}
],
"styles": [
diff --git a/frontend/package.json b/frontend/package.json
index a11f83b9c..b41d9906d 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -35,6 +35,7 @@
"@embedpdf/pdfium": "2.14.4",
"@embedpdf/snippet": "2.14.4",
"@jsverse/transloco": "^8.4.0",
+ "@lucide/angular": "^1.18.0",
"@primeuix/themes": "^2.0.3",
"@stomp/rx-stomp": "^2.4.0",
"@stomp/stompjs": "^7.3.0",
@@ -47,6 +48,7 @@
"class-variance-authority": "^0.7.1",
"date-fns": "^4.4.0",
"dompurify": "^3.4.10",
+ "lucide-static": "1.18.0",
"markdown-it": "^14.2.0",
"ng-lazyload-image": "^9.1.3",
"ng2-charts": "^10.0.0",
diff --git a/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.spec.ts b/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.spec.ts
index adae5bc25..54008f3c9 100644
--- a/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.spec.ts
+++ b/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.spec.ts
@@ -196,7 +196,7 @@ describe('ShelfAssignerComponent', () => {
]);
});
- it('maps custom svg and PrimeNG shelf icons to icon-display selections', () => {
+ it('maps custom svg and Lucide shelf icons to icon-display selections', () => {
const {component} = createHarness();
expect(component.getShelfIcon(createShelf({
@@ -207,11 +207,11 @@ describe('ShelfAssignerComponent', () => {
value: 'custom-icons/moon.svg',
});
expect(component.getShelfIcon(createShelf({
- iconType: 'PRIME_NG',
+ iconType: 'LUCIDE',
icon: 'bookmark',
}))).toEqual({
- type: 'PRIME_NG',
- value: 'pi pi-bookmark',
+ type: 'LUCIDE',
+ value: 'bookmark',
});
});
diff --git a/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.ts b/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.ts
index 6ebef8377..8b493f31f 100644
--- a/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.ts
+++ b/frontend/src/app/features/book/components/shelf-assigner/shelf-assigner.component.ts
@@ -13,11 +13,11 @@ import {BookDialogHelperService} from '../book-browser/book-dialog-helper.servic
import {LoadingService} from '../../../../core/services/loading.service';
import {UserService} from '../../../settings/user-management/user.service';
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
-import {IconSelection} from '../../../../shared/service/icon-picker.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {InputText} from 'primeng/inputtext';
import {IconField} from 'primeng/iconfield';
import {InputIcon} from 'primeng/inputicon';
+import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-selection';
@Component({
selector: 'app-shelf-assigner',
@@ -129,12 +129,8 @@ export class ShelfAssignerComponent {
return this.selectedShelves.some(s => s.id === shelf.id);
}
- getShelfIcon(shelf: Shelf): IconSelection {
- if (shelf.iconType === 'CUSTOM_SVG') {
- return {type: 'CUSTOM_SVG', value: shelf.icon ?? ""};
- } else {
- return {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
- }
+ getShelfIcon(shelf: Shelf): IconSelection | null {
+ return shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : null;
}
filterShelves(shelves: Shelf[]): Shelf[] {
diff --git a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.html b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.html
index fe7adce4d..87c31e619 100644
--- a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.html
+++ b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.html
@@ -69,8 +69,8 @@
{{ t('selectedIcon') }}
- @if (selectedIcon.type === 'PRIME_NG') {
- {{ selectedIcon.value }}
+ @if (selectedIcon.type === 'CUSTOM_SVG') {
+ {{ t('customSvg') }}
} @else {
{{ selectedIcon.value }}
}
diff --git a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.spec.ts b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.spec.ts
index 4ae8455a6..71de80b72 100644
--- a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.spec.ts
+++ b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.spec.ts
@@ -5,7 +5,8 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {Observable, of, throwError} from 'rxjs';
import {afterEach, describe, expect, it, vi} from 'vitest';
-import {IconSelection, IconPickerService} from '../../../../shared/service/icon-picker.service';
+import {IconPickerService} from '../../../../shared/service/icon-picker.service';
+import {IconSelection} from '../../../../shared/icons/icon-selection';
import {UserService} from '../../../settings/user-management/user.service';
import {Shelf} from '../../model/shelf.model';
import {ShelfService} from '../../service/shelf.service';
@@ -67,8 +68,8 @@ describe('ShelfCreatorComponent', () => {
it('picks an icon through the injected icon picker and ignores empty selections', () => {
const pickedIcon: IconSelection = {
- type: 'PRIME_NG',
- value: 'pi pi-star',
+ type: 'LUCIDE',
+ value: 'star',
};
const {component, iconPickerService} = createHarness({
iconPickerResult: pickedIcon,
@@ -114,16 +115,16 @@ describe('ShelfCreatorComponent', () => {
component.shelfName = 'Weekend Reads';
component.isPublic = true;
component.selectedIcon = {
- type: 'PRIME_NG',
- value: 'pi pi-bookmark',
+ type: 'LUCIDE',
+ value: 'bookmark',
};
component.createShelf();
expect(createShelf).toHaveBeenCalledWith({
name: 'Weekend Reads',
- icon: 'pi pi-bookmark',
- iconType: 'PRIME_NG',
+ icon: 'bookmark',
+ iconType: 'LUCIDE',
publicShelf: true,
});
expect(translate).toHaveBeenCalledWith('common.success');
diff --git a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.ts b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.ts
index 88d00c330..eb91036f5 100644
--- a/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.ts
+++ b/frontend/src/app/features/book/components/shelf-creator/shelf-creator.component.ts
@@ -2,7 +2,8 @@ import {Component, inject} from '@angular/core';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {MessageService} from 'primeng/api';
import {ShelfService} from '../../service/shelf.service';
-import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
+import {IconPickerService} from '../../../../shared/service/icon-picker.service';
+import {IconSelection} from '../../../../shared/icons/icon-selection';
import {Shelf} from '../../model/shelf.model';
import {FormsModule} from '@angular/forms';
import {Button} from 'primeng/button';
diff --git a/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.spec.ts b/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.spec.ts
index f60a20928..db8a68f37 100644
--- a/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.spec.ts
+++ b/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.spec.ts
@@ -6,7 +6,8 @@ import {Observable, of, throwError} from 'rxjs';
import {afterEach, describe, expect, it, vi} from 'vitest';
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
-import {IconSelection, IconPickerService} from '../../../../shared/service/icon-picker.service';
+import {IconPickerService} from '../../../../shared/service/icon-picker.service';
+import {IconSelection} from '../../../../shared/icons/icon-selection';
import {UserService} from '../../../settings/user-management/user.service';
import {Shelf} from '../../model/shelf.model';
import {ShelfService} from '../../service/shelf.service';
@@ -71,12 +72,12 @@ describe('ShelfEditDialogComponent', () => {
};
}
- it('hydrates the dialog from a matching PrimeNG shelf', () => {
+ it('hydrates the dialog from a matching Lucide shelf', () => {
const shelf = createShelf({
id: 42,
name: 'Queue',
icon: 'bookmark',
- iconType: 'PRIME_NG',
+ iconType: 'LUCIDE',
publicShelf: true,
});
@@ -89,8 +90,8 @@ describe('ShelfEditDialogComponent', () => {
expect(component.shelfName).toBe('Queue');
expect(component.isPublic).toBe(true);
expect(component.selectedIcon).toEqual({
- type: 'PRIME_NG',
- value: 'pi pi-bookmark',
+ type: 'LUCIDE',
+ value: 'bookmark',
});
});
@@ -125,7 +126,7 @@ describe('ShelfEditDialogComponent', () => {
id: 11,
name: 'Should Not Replace',
icon: 'bookmark',
- iconType: 'PRIME_NG',
+ iconType: 'LUCIDE',
publicShelf: true,
}),
]);
@@ -141,8 +142,8 @@ describe('ShelfEditDialogComponent', () => {
it('picks and clears icons through the dialog-local icon selection methods', () => {
const pickedIcon: IconSelection = {
- type: 'PRIME_NG',
- value: 'pi pi-star',
+ type: 'LUCIDE',
+ value: 'star',
};
const {component, iconPickerService} = createHarness({
shelvesData: [createShelf()],
@@ -166,16 +167,16 @@ describe('ShelfEditDialogComponent', () => {
component.shelfName = 'Renamed Shelf';
component.isPublic = true;
component.selectedIcon = {
- type: 'PRIME_NG',
- value: 'pi pi-heart',
+ type: 'LUCIDE',
+ value: 'heart',
};
component.save();
expect(updateShelf).toHaveBeenCalledWith({
name: 'Renamed Shelf',
- icon: 'pi pi-heart',
- iconType: 'PRIME_NG',
+ icon: 'heart',
+ iconType: 'LUCIDE',
publicShelf: true,
}, 7);
expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({
diff --git a/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts b/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts
index 75f30e261..c87f94f89 100644
--- a/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts
+++ b/frontend/src/app/features/book/components/shelf-edit-dialog/shelf-edit-dialog.component.ts
@@ -7,11 +7,12 @@ import {InputText} from 'primeng/inputtext';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {Shelf} from '../../model/shelf.model';
import {MessageService} from 'primeng/api';
-import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
+import {IconPickerService} from '../../../../shared/service/icon-picker.service';
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
import {Checkbox} from 'primeng/checkbox';
import {UserService} from '../../../settings/user-management/user.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
+import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-selection';
@Component({
selector: 'app-shelf-edit-dialog',
@@ -63,11 +64,7 @@ export class ShelfEditDialogComponent implements OnInit {
this.shelfName = shelf.name;
this.isPublic = shelf.publicShelf ?? false;
if (shelf.iconType && shelf.icon) {
- if (shelf.iconType === 'PRIME_NG') {
- this.selectedIcon = {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
- } else {
- this.selectedIcon = {type: 'CUSTOM_SVG', value: shelf.icon};
- }
+ this.selectedIcon = toIconSelection(shelf.icon, shelf.iconType);
}
}, {injector: this.injector});
}
diff --git a/frontend/src/app/features/book/model/library.model.ts b/frontend/src/app/features/book/model/library.model.ts
index 05a493475..40fdb7734 100644
--- a/frontend/src/app/features/book/model/library.model.ts
+++ b/frontend/src/app/features/book/model/library.model.ts
@@ -1,5 +1,6 @@
import {SortOption} from './sort.model';
import {BookType} from './book.model';
+import {IconType} from '../../../shared/icons/icon-selection';
export type MetadataSource = 'EMBEDDED' | 'SIDECAR' | 'PREFER_SIDECAR' | 'PREFER_EMBEDDED' | 'NONE';
@@ -9,7 +10,7 @@ export interface Library {
id?: number;
name: string;
icon?: string | null;
- iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
+ iconType?: IconType | null;
watch: boolean;
fileNamingPattern?: string;
sort?: SortOption;
diff --git a/frontend/src/app/features/book/model/shelf.model.ts b/frontend/src/app/features/book/model/shelf.model.ts
index 6dd2f2dd6..0e8f2d673 100644
--- a/frontend/src/app/features/book/model/shelf.model.ts
+++ b/frontend/src/app/features/book/model/shelf.model.ts
@@ -1,4 +1,5 @@
import {SortOption} from './sort.model';
+import {IconType} from '../../../shared/icons/icon-selection';
export type ShelfSystemKey = 'kobo';
@@ -6,7 +7,7 @@ export interface Shelf {
id?: number;
name: string;
icon?: string | null;
- iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
+ iconType?: IconType | null;
sort?: SortOption;
publicShelf?: boolean;
userId?: number;
diff --git a/frontend/src/app/features/command-palette/command-palette.component.html b/frontend/src/app/features/command-palette/command-palette.component.html
index eb806fb7b..c1af794b3 100644
--- a/frontend/src/app/features/command-palette/command-palette.component.html
+++ b/frontend/src/app/features/command-palette/command-palette.component.html
@@ -5,7 +5,7 @@
@@ -86,14 +86,12 @@
} @else {
- @if (item.icon) {
-
- }
+
{{ item.title }}
@if (item.subtitle) {
{{ item.subtitle }}
diff --git a/frontend/src/app/features/command-palette/command-palette.component.scss b/frontend/src/app/features/command-palette/command-palette.component.scss
index 2b68b2d55..2279f9cca 100644
--- a/frontend/src/app/features/command-palette/command-palette.component.scss
+++ b/frontend/src/app/features/command-palette/command-palette.component.scss
@@ -36,9 +36,11 @@
gap: var(--space-3);
padding: var(--space-4) var(--space-5);
- i {
+ .command-palette-search-icon {
+ flex-shrink: 0;
+ width: 1.125rem;
+ height: 1.125rem;
color: var(--color-text-secondary);
- font-size: var(--app-text-lg);
}
}
@@ -88,8 +90,9 @@
outline-offset: 2px;
}
- i {
- font-size: 1.0938rem;
+ svg {
+ width: 1.0938rem;
+ height: 1.0938rem;
}
}
@@ -295,12 +298,12 @@
0
calc(0.6563rem + env(safe-area-inset-left));
- > .pi-search {
+ > .command-palette-search-icon {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
- width: 2.1875rem;
+ width: 1.125rem;
}
}
diff --git a/frontend/src/app/features/command-palette/command-palette.component.ts b/frontend/src/app/features/command-palette/command-palette.component.ts
index a1c3f64d1..2943dc6fa 100644
--- a/frontend/src/app/features/command-palette/command-palette.component.ts
+++ b/frontend/src/app/features/command-palette/command-palette.component.ts
@@ -7,6 +7,7 @@ import { filter, take } from 'rxjs/operators';
import { FormsModule } from '@angular/forms';
import { TranslocoDirective, TranslocoPipe } from '@jsverse/transloco';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { LucideSearch, LucideX } from '@lucide/angular';
import { CoverPlaceholderComponent } from '../../shared/components/cover-generator/cover-generator.component';
import { IconDisplayComponent } from '../../shared/components/icon-display/icon-display.component';
@@ -17,7 +18,7 @@ import { CommandPaletteService } from './command-palette.service';
@Component({
selector: 'app-command-palette',
standalone: true,
- imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, TranslocoPipe, IconDisplayComponent, CoverPlaceholderComponent],
+ imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, TranslocoPipe, IconDisplayComponent, CoverPlaceholderComponent, LucideSearch, LucideX],
templateUrl: './command-palette.component.html',
styleUrl: './command-palette.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
diff --git a/frontend/src/app/features/command-palette/command-palette.model.ts b/frontend/src/app/features/command-palette/command-palette.model.ts
index e283016db..ef5466b9d 100644
--- a/frontend/src/app/features/command-palette/command-palette.model.ts
+++ b/frontend/src/app/features/command-palette/command-palette.model.ts
@@ -1,4 +1,4 @@
-import { IconSelection } from '../../shared/service/icon-picker.service';
+import { IconSelection } from '../../shared/icons/icon-selection';
export type PaletteItemKind =
| 'action'
diff --git a/frontend/src/app/features/command-palette/command-palette.service.spec.ts b/frontend/src/app/features/command-palette/command-palette.service.spec.ts
index 8b40ac400..ad1b65ed5 100644
--- a/frontend/src/app/features/command-palette/command-palette.service.spec.ts
+++ b/frontend/src/app/features/command-palette/command-palette.service.spec.ts
@@ -14,7 +14,7 @@ import { ShelfService } from '../book/service/shelf.service';
import { MagicShelfService } from '../magic-shelf/service/magic-shelf.service';
import { UrlHelperService } from '../../shared/service/url-helper.service';
import { UserService } from '../settings/user-management/user.service';
-import { IconService } from '../../shared/services/icon.service';
+import { CustomSvgService } from '../../shared/services/custom-svg.service';
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
import { CommandPaletteService } from './command-palette.service';
@@ -68,7 +68,7 @@ describe('CommandPaletteService', () => {
{ provide: UserService, useValue: { currentUser: signal({ permissions: {} }) } },
{ provide: MessageService, useValue: { add: vi.fn() } },
{ provide: UrlHelperService, useValue: urlHelper },
- { provide: IconService, useValue: { getSvgIconContent: vi.fn(() => of('')) } },
+ { provide: CustomSvgService, useValue: { getSvgIconContent: vi.fn(() => of('')) } },
{
provide: DialogLauncherService,
useValue: {
diff --git a/frontend/src/app/features/command-palette/command-palette.service.ts b/frontend/src/app/features/command-palette/command-palette.service.ts
index 03f59a2f4..a59c2889e 100644
--- a/frontend/src/app/features/command-palette/command-palette.service.ts
+++ b/frontend/src/app/features/command-palette/command-palette.service.ts
@@ -15,10 +15,10 @@ import { MagicShelfService } from '../magic-shelf/service/magic-shelf.service';
import { UserService } from '../settings/user-management/user.service';
import { NavItem } from '../../shared/layout/navigation/nav-item.model';
import { buildAllNavPages, buildQuickActionNavItems } from '../../shared/layout/navigation/nav-catalog';
-import { IconSelection } from '../../shared/service/icon-picker.service';
import { UrlHelperService } from '../../shared/service/url-helper.service';
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
-import { IconService } from '../../shared/services/icon.service';
+import { CustomSvgService } from '../../shared/services/custom-svg.service';
+import { toIconSelection } from '../../shared/icons/icon-selection';
import { PaletteGroup, PaletteItem, PaletteItemKind } from './command-palette.model';
@@ -49,7 +49,7 @@ export class CommandPaletteService {
private readonly libraryService = inject(LibraryService);
private readonly dialogLauncherService = inject(DialogLauncherService);
private readonly bookDialogHelperService = inject(BookDialogHelperService);
- private readonly iconService = inject(IconService);
+ private readonly customSvgService = inject(CustomSvgService);
private readonly urlHelper = inject(UrlHelperService);
private readonly messageService = inject(MessageService);
@@ -106,7 +106,7 @@ export class CommandPaletteService {
for (const item of items) {
if (item.icon?.type === 'CUSTOM_SVG' && !seen.has(item.icon.value)) {
seen.add(item.icon.value);
- this.iconService.getSvgIconContent(item.icon.value).subscribe({ error: () => undefined });
+ this.customSvgService.getSvgIconContent(item.icon.value).subscribe({ error: () => undefined });
}
}
};
@@ -235,7 +235,7 @@ export class CommandPaletteService {
id: `shelf:${shelf.id}`,
kind: 'shelf' as const,
title: shelf.name,
- icon: this.iconSelectionFor(shelf.icon, shelf.iconType, 'pi-bookmark'),
+ icon: shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : undefined,
searchText: normalizeSearchTerm(shelf.name),
route: [`/shelf/${shelf.id}/books`],
}))
@@ -248,7 +248,7 @@ export class CommandPaletteService {
id: `magic-shelf:${shelf.id}`,
kind: 'magicShelf' as const,
title: shelf.name,
- icon: this.iconSelectionFor(shelf.icon, shelf.iconType, 'pi-sparkles'),
+ icon: shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : undefined,
searchText: normalizeSearchTerm(shelf.name),
route: [`/magic-shelf/${shelf.id}/books`],
}))
@@ -261,7 +261,7 @@ export class CommandPaletteService {
id: `library:${library.id}`,
kind: 'library' as const,
title: library.name,
- icon: this.iconSelectionFor(library.icon, library.iconType, 'pi-folder'),
+ icon: library.icon ? toIconSelection(library.icon, library.iconType) : undefined,
searchText: normalizeSearchTerm(library.name),
route: [`/library/${library.id}/books`],
}))
@@ -271,16 +271,6 @@ export class CommandPaletteService {
this.trimmedQuery().length >= MIN_BOOK_SEARCH_LENGTH ? this.localBookItems() : []
);
- private iconSelectionFor(
- value: string | null | undefined,
- iconType: string | null | undefined,
- fallback: string,
- ): IconSelection {
- if (!value) return { type: 'PRIME_NG', value: fallback };
- if (iconType === 'CUSTOM_SVG') return { type: 'CUSTOM_SVG', value };
- return { type: 'PRIME_NG', value };
- }
-
private toPaletteBookItem(book: Book): PaletteItem {
const metadata = book.metadata;
const title = metadata?.title ?? book.primaryFile?.fileName ?? book.fileName ?? '';
@@ -294,7 +284,7 @@ export class CommandPaletteService {
id: `book:${book.id}`,
kind: 'book',
title,
- icon: { type: 'PRIME_NG', value: 'pi-book' },
+ icon: { type: 'LUCIDE', value: 'book-open' },
searchText: normalizeSearchTerm(haystack),
route: ['/book', book.id],
queryParams: { tab: 'view' },
@@ -316,7 +306,7 @@ export class CommandPaletteService {
id: `${kind}:${item.id}`,
kind,
title: item.label,
- icon: item.icon ? { type: 'PRIME_NG', value: item.icon } : undefined,
+ icon: item.icon ? toIconSelection(item.icon, item.iconType) : undefined,
searchText: normalizeSearchTerm(item.label),
route: item.routerLink,
command: item.action,
diff --git a/frontend/src/app/features/library-creator/library-creator.component.html b/frontend/src/app/features/library-creator/library-creator.component.html
index a39af1f93..a2bfa0f2b 100644
--- a/frontend/src/app/features/library-creator/library-creator.component.html
+++ b/frontend/src/app/features/library-creator/library-creator.component.html
@@ -50,27 +50,27 @@
{{ t('iconLabel') }}
- @if (!selectedIcon()) {
-
- } @else {
+ @if (selectedIcon(); as icon) {
- @if (selectedIcon()!.type === 'PRIME_NG') {
- {{ selectedIcon()!.value }}
- } @else {
+ @if (icon.type === 'CUSTOM_SVG') {
{{ t('customSvg') }}
+ } @else {
+ {{ icon.value }}
}
+ } @else {
+
}
diff --git a/frontend/src/app/features/library-creator/library-creator.component.ts b/frontend/src/app/features/library-creator/library-creator.component.ts
index a829c2910..c1c8774b9 100644
--- a/frontend/src/app/features/library-creator/library-creator.component.ts
+++ b/frontend/src/app/features/library-creator/library-creator.component.ts
@@ -10,7 +10,7 @@ import { Library, MetadataSource, OrganizationMode } from '../book/model/library
import { BookType } from '../book/model/book.model';
import { ToggleSwitch } from 'primeng/toggleswitch';
import { Tooltip } from 'primeng/tooltip';
-import { IconPickerService, IconSelection } from '../../shared/service/icon-picker.service';
+import { IconPickerService } from '../../shared/service/icon-picker.service';
import { Button } from 'primeng/button';
import { IconDisplayComponent } from '../../shared/components/icon-display/icon-display.component';
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
@@ -20,6 +20,7 @@ import { Checkbox } from 'primeng/checkbox';
import { Select } from 'primeng/select';
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
import { LibraryImportProgressService } from '../../shared/service/library-import-progress.service';
+import { IconSelection, toIconSelection } from '../../shared/icons/icon-selection';
interface FormatEntry { type: BookType; label: string }
@@ -139,12 +140,7 @@ export class LibraryCreatorComponent {
this.folders.set(paths.map(p => p.path));
if (icon != null && iconType) {
- if (iconType === 'CUSTOM_SVG') {
- this.selectedIcon.set({ type: 'CUSTOM_SVG', value: icon });
- } else {
- const value = icon.slice(0, 6) === 'pi pi-' ? icon : `pi pi-${icon}`;
- this.selectedIcon.set({ type: 'PRIME_NG', value });
- }
+ this.selectedIcon.set(toIconSelection(icon, iconType));
}
if (formatPriority && formatPriority.length > 0) {
diff --git a/frontend/src/app/features/magic-shelf/component/magic-shelf-component.ts b/frontend/src/app/features/magic-shelf/component/magic-shelf-component.ts
index 02f2121f1..c9e5eb6a8 100644
--- a/frontend/src/app/features/magic-shelf/component/magic-shelf-component.ts
+++ b/frontend/src/app/features/magic-shelf/component/magic-shelf-component.ts
@@ -14,7 +14,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {MultiSelect} from 'primeng/multiselect';
import {AutoComplete} from 'primeng/autocomplete';
import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, RELATIVE_DATE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../service/magic-shelf-utils';
-import {IconPickerService, IconSelection} from '../../../shared/service/icon-picker.service';
+import {IconPickerService} from '../../../shared/service/icon-picker.service';
import {CheckboxChangeEvent, Checkbox} from "primeng/checkbox";
import {UserService} from "../../settings/user-management/user.service";
import {IconDisplayComponent} from '../../../shared/components/icon-display/icon-display.component';
@@ -23,6 +23,7 @@ import {BookService} from '../../book/service/book.service';
import {ShelfService} from '../../book/service/shelf.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {Textarea} from 'primeng/textarea';
+import {IconSelection, toIconSelection} from '../../../shared/icons/icon-selection';
export type RuleOperator =
| 'equals'
@@ -543,9 +544,7 @@ export class MagicShelfComponent implements OnInit {
});
if (iconValue) {
- this.selectedIcon = iconValue.startsWith('pi ')
- ? {type: 'PRIME_NG', value: iconValue}
- : {type: 'CUSTOM_SVG', value: iconValue};
+ this.selectedIcon = toIconSelection(iconValue, shelf?.iconType);
} else {
this.selectedIcon = null;
}
diff --git a/frontend/src/app/features/magic-shelf/service/magic-shelf.service.spec.ts b/frontend/src/app/features/magic-shelf/service/magic-shelf.service.spec.ts
index 3b7fd20a1..f5efff53a 100644
--- a/frontend/src/app/features/magic-shelf/service/magic-shelf.service.spec.ts
+++ b/frontend/src/app/features/magic-shelf/service/magic-shelf.service.spec.ts
@@ -14,8 +14,8 @@ function buildMagicShelf(overrides: Partial = {}): MagicShelf {
return {
id: 1,
name: 'Favorites',
- icon: 'pi pi-star',
- iconType: 'PRIME_NG',
+ icon: 'star',
+ iconType: 'LUCIDE',
filterJson: JSON.stringify(buildGroupRule()),
isPublic: false,
...overrides,
@@ -152,8 +152,8 @@ describe('MagicShelfService', () => {
service.saveShelf({
name: 'Magic',
- icon: 'pi pi-bolt',
- iconType: 'PRIME_NG',
+ icon: 'zap',
+ iconType: 'LUCIDE',
group,
isPublic: true,
}).subscribe();
@@ -162,8 +162,8 @@ describe('MagicShelfService', () => {
expect(request.request.method).toBe('POST');
expect(request.request.body).toEqual(expect.objectContaining({
name: 'Magic',
- icon: 'pi pi-bolt',
- iconType: 'PRIME_NG',
+ icon: 'zap',
+ iconType: 'LUCIDE',
filterJson: JSON.stringify(group),
isPublic: true,
}));
diff --git a/frontend/src/app/features/magic-shelf/service/magic-shelf.service.ts b/frontend/src/app/features/magic-shelf/service/magic-shelf.service.ts
index 52bc05994..6ccf92a9c 100644
--- a/frontend/src/app/features/magic-shelf/service/magic-shelf.service.ts
+++ b/frontend/src/app/features/magic-shelf/service/magic-shelf.service.ts
@@ -9,12 +9,13 @@ import {BookService} from '../../book/service/book.service';
import {BookRuleEvaluatorService} from './book-rule-evaluator.service';
import {AuthService} from '../../../shared/service/auth.service';
import {GroupRule} from '../component/magic-shelf-component';
+import {IconType} from '../../../shared/icons/icon-selection';
export interface MagicShelf {
id?: number | null;
name: string;
icon?: string | null;
- iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
+ iconType?: IconType | null;
filterJson: string;
isPublic?: boolean;
}
@@ -72,7 +73,7 @@ export class MagicShelfService {
id?: number;
name: string | null;
icon: string | null;
- iconType?: 'PRIME_NG' | 'CUSTOM_SVG';
+ iconType?: IconType | null;
group: unknown;
isPublic?: boolean | null;
}): Observable {
diff --git a/frontend/src/app/shared/components/icon-display/icon-display.component.spec.ts b/frontend/src/app/shared/components/icon-display/icon-display.component.spec.ts
index 829726383..9e73ee639 100644
--- a/frontend/src/app/shared/components/icon-display/icon-display.component.spec.ts
+++ b/frontend/src/app/shared/components/icon-display/icon-display.component.spec.ts
@@ -1,35 +1,34 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
-import {SafeHtml} from '@angular/platform-browser';
-import {of, throwError} from 'rxjs';
+import {Subject, of, throwError} from 'rxjs';
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {IconDisplayComponent} from './icon-display.component';
-import {IconCacheService} from '../../services/icon-cache.service';
-import {IconService} from '../../services/icon.service';
+import {CustomSvgCacheService} from '../../services/custom-svg-cache.service';
+import {CustomSvgService} from '../../services/custom-svg.service';
describe('IconDisplayComponent', () => {
let fixture: ComponentFixture;
let component: IconDisplayComponent;
- let iconCache: {
+ let customSvgCache: {
getCachedSanitized: ReturnType;
cacheIcon: ReturnType;
};
- let iconService: {getSanitizedSvgContent: ReturnType};
+ let customSvgService: {getSanitizedSvgContent: ReturnType};
beforeEach(async () => {
- iconCache = {
+ customSvgCache = {
getCachedSanitized: vi.fn(() => null),
cacheIcon: vi.fn(),
};
- iconService = {
- getSanitizedSvgContent: vi.fn(() => of('' as SafeHtml)),
+ customSvgService = {
+ getSanitizedSvgContent: vi.fn(() => of('')),
};
await TestBed.configureTestingModule({
imports: [IconDisplayComponent],
providers: [
- {provide: IconCacheService, useValue: iconCache},
- {provide: IconService, useValue: iconService},
+ {provide: CustomSvgCacheService, useValue: customSvgCache},
+ {provide: CustomSvgService, useValue: customSvgService},
],
}).compileComponents();
@@ -42,38 +41,20 @@ describe('IconDisplayComponent', () => {
TestBed.resetTestingModule();
});
- it('normalizes PrimeNG icon class names', () => {
- expect(component.getPrimeNgIconClass('pi pi-book')).toBe('pi pi-book');
- expect(component.getPrimeNgIconClass('pi-book')).toBe('pi pi-book');
- expect(component.getPrimeNgIconClass('book')).toBe('pi pi-book');
- });
-
- it('builds PrimeNG styles from the configured size and extra icon style', () => {
- component.size = '20px';
- component.iconStyle = {color: 'tomato'};
-
- expect(component.getPrimeNgStyle()).toEqual({
- fontSize: '17px',
- width: '20px',
- height: '20px',
- display: 'inline-flex',
- alignItems: 'center',
- justifyContent: 'center',
- color: 'tomato',
- });
- });
-
it('loads uncached custom SVG icons on initialization', () => {
component.icon = {type: 'CUSTOM_SVG', value: 'dragon'};
fixture.detectChanges();
- expect(iconCache.getCachedSanitized).toHaveBeenCalledWith('dragon');
- expect(iconService.getSanitizedSvgContent).toHaveBeenCalledWith('dragon');
+ expect(customSvgCache.getCachedSanitized).toHaveBeenCalledWith('dragon');
+ expect(customSvgService.getSanitizedSvgContent).toHaveBeenCalledWith('dragon');
});
it('does not reload the same custom SVG when the value has not changed', () => {
- const loadSpy = vi.spyOn(component as never, 'loadIconIfNeeded');
+ component.icon = {type: 'CUSTOM_SVG', value: 'dragon'};
+ fixture.detectChanges();
+ customSvgService.getSanitizedSvgContent.mockClear();
+
component.ngOnChanges({
icon: {
currentValue: {type: 'CUSTOM_SVG', value: 'dragon'},
@@ -83,12 +64,15 @@ describe('IconDisplayComponent', () => {
},
});
- expect(loadSpy).not.toHaveBeenCalled();
+ expect(customSvgService.getSanitizedSvgContent).not.toHaveBeenCalled();
});
it('reloads when the custom SVG icon value changes', () => {
- const loadSpy = vi.spyOn(component as never, 'loadIconIfNeeded');
+ component.icon = {type: 'CUSTOM_SVG', value: 'phoenix'};
+ fixture.detectChanges();
+ customSvgService.getSanitizedSvgContent.mockClear();
+ component.icon = {type: 'CUSTOM_SVG', value: 'dragon'};
component.ngOnChanges({
icon: {
currentValue: {type: 'CUSTOM_SVG', value: 'dragon'},
@@ -98,14 +82,14 @@ describe('IconDisplayComponent', () => {
},
});
- expect(loadSpy).toHaveBeenCalled();
+ expect(customSvgService.getSanitizedSvgContent).toHaveBeenCalledWith('dragon');
});
it('exposes cached SVG content and empty-icon dimensions', () => {
- iconCache.getCachedSanitized.mockReturnValueOnce('' as SafeHtml);
+ customSvgCache.getCachedSanitized.mockReturnValueOnce('');
component.size = '2rem';
- expect(component.getSvgContent('cached')).toBe('' as SafeHtml);
+ expect(component.getSvgContent('cached')).toBe('');
expect(component.getEmptyIconStyle()).toEqual({
width: '2rem',
height: '2rem',
@@ -113,15 +97,27 @@ describe('IconDisplayComponent', () => {
});
it('caches an error SVG when loading a custom icon fails', () => {
- iconService.getSanitizedSvgContent.mockReturnValueOnce(
+ customSvgService.getSanitizedSvgContent.mockReturnValueOnce(
throwError(() => new Error('nope'))
);
component.icon = {type: 'CUSTOM_SVG', value: 'broken'};
fixture.detectChanges();
- expect(iconCache.cacheIcon).toHaveBeenCalledOnce();
- expect(iconCache.cacheIcon.mock.calls[0]?.[0]).toBe('broken');
- expect(iconCache.cacheIcon.mock.calls[0]?.[1]).toContain('stroke="red"');
+ expect(customSvgCache.cacheIcon).toHaveBeenCalledOnce();
+ expect(customSvgCache.cacheIcon.mock.calls[0]?.[0]).toBe('broken');
+ expect(customSvgCache.cacheIcon.mock.calls[0]?.[1]).toContain('stroke="red"');
+ });
+
+ it('caches a load failure under the originally requested custom icon name', () => {
+ const loadResult = new Subject();
+ customSvgService.getSanitizedSvgContent.mockReturnValueOnce(loadResult.asObservable());
+ component.icon = {type: 'CUSTOM_SVG', value: 'dragon'};
+
+ fixture.detectChanges();
+ component.icon = {type: 'CUSTOM_SVG', value: 'phoenix'};
+ loadResult.error(new Error('nope'));
+
+ expect(customSvgCache.cacheIcon.mock.calls[0]?.[0]).toBe('dragon');
});
});
diff --git a/frontend/src/app/shared/components/icon-display/icon-display.component.ts b/frontend/src/app/shared/components/icon-display/icon-display.component.ts
index f67e92426..92503d288 100644
--- a/frontend/src/app/shared/components/icon-display/icon-display.component.ts
+++ b/frontend/src/app/shared/components/icon-display/icon-display.component.ts
@@ -1,25 +1,39 @@
-import {Component, inject, Input, OnInit, OnChanges, SimpleChanges, ChangeDetectionStrategy, ChangeDetectorRef} from '@angular/core';
-import {IconSelection} from '../../service/icon-picker.service';
+import {Component, inject, Input, OnInit, OnChanges, SimpleChanges, ChangeDetectionStrategy, ChangeDetectorRef, DestroyRef} from '@angular/core';
+import {IconSelection} from '../../icons/icon-selection';
import {NgClass, NgStyle} from '@angular/common';
-import {IconCacheService} from '../../services/icon-cache.service';
-import {IconService} from '../../services/icon.service';
-import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
+import {CustomSvgCacheService} from '../../services/custom-svg-cache.service';
+import {CustomSvgService} from '../../services/custom-svg.service';
+import {AppIconDirective} from '../icon/app-icon.directive';
+import {SvgContentDirective} from '../icon/svg-content.directive';
+import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
+
+const ERROR_SVG = [
+ '',
+].join('');
@Component({
selector: 'app-icon-display',
standalone: true,
- imports: [NgClass, NgStyle],
+ imports: [NgClass, NgStyle, AppIconDirective, SvgContentDirective],
template: `
@if (icon) {
- @if (icon.type === 'PRIME_NG') {
-
- } @else {
+ @if (icon.type === 'CUSTOM_SVG') {
+ } @else {
+
}
} @else if (displayEmpty) {
this.cdr.markForCheck(),
- error: () => {
- if (this.icon?.type === 'CUSTOM_SVG') {
- const errorSvg = '';
- const sanitized = this.sanitizer.bypassSecurityTrustHtml(errorSvg);
- this.iconCache.cacheIcon(this.icon.value, errorSvg, sanitized);
+ if (this.customSvgCache.getCachedSanitized(requestedIconName) === null) {
+ this.customSvgService.getSanitizedSvgContent(requestedIconName)
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe({
+ next: () => this.cdr.markForCheck(),
+ error: () => {
+ this.customSvgCache.cacheIcon(requestedIconName, ERROR_SVG, ERROR_SVG);
this.cdr.markForCheck();
}
- }
- });
+ });
}
}
}
- getSvgContent(iconName: string): SafeHtml | null {
- return this.iconCache.getCachedSanitized(iconName) || null;
- }
-
- getPrimeNgIconClass(iconValue: string): string {
- if (iconValue.startsWith('pi pi-')) {
- return iconValue;
- }
- if (iconValue.startsWith('pi-')) {
- return `pi ${iconValue}`;
- }
- return `pi pi-${iconValue}`;
+ getSvgContent(iconName: string): string | null {
+ return this.customSvgCache.getCachedSanitized(iconName);
}
getSvgStyle(): Record {
@@ -139,19 +142,4 @@ export class IconDisplayComponent implements OnInit, OnChanges {
};
}
- getPrimeNgStyle(): Record {
- const fontSize = this.size.endsWith('px')
- ? `${parseInt(this.size) * 0.85}px`
- : `calc(${this.size} * 0.85)`;
-
- return {
- fontSize: fontSize,
- width: this.size,
- height: this.size,
- display: 'inline-flex',
- alignItems: 'center',
- justifyContent: 'center',
- ...this.iconStyle
- };
- }
}
diff --git a/frontend/src/app/shared/components/icon-picker/icon-picker-component.html b/frontend/src/app/shared/components/icon-picker/icon-picker-component.html
index 0d9c9650a..5a685916a 100644
--- a/frontend/src/app/shared/components/icon-picker/icon-picker-component.html
+++ b/frontend/src/app/shared/components/icon-picker/icon-picker-component.html
@@ -2,7 +2,7 @@
-
+
@if (entry.error) {
{{ entry.error }}
}
diff --git a/frontend/src/app/shared/components/icon-picker/icon-picker-component.ts b/frontend/src/app/shared/components/icon-picker/icon-picker-component.ts
index 86f3d2ec9..4cbd8f59e 100644
--- a/frontend/src/app/shared/components/icon-picker/icon-picker-component.ts
+++ b/frontend/src/app/shared/components/icon-picker/icon-picker-component.ts
@@ -1,23 +1,24 @@
import {Component, inject, OnInit} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
-import {IconService} from '../../services/icon.service';
-import {IconCacheService} from '../../services/icon-cache.service';
-import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
+import {CustomSvgService} from '../../services/custom-svg.service';
+import {CustomSvgCacheService} from '../../services/custom-svg-cache.service';
import DOMPurify from 'dompurify';
import {UrlHelperService} from '../../service/url-helper.service';
import {MessageService} from 'primeng/api';
-import {IconCategoriesHelper} from '../../helpers/icon-categories.helper';
import {Button} from 'primeng/button';
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
import {UserService} from '../../../features/settings/user-management/user.service';
import {from, of} from 'rxjs';
import {catchError, mergeMap, toArray} from 'rxjs/operators';
+import {LucideCirclePlus, LucideDynamicIcon, LucideImages, LucidePalette, LucideSearch, LucideSparkles, provideLucideConfig, type LucideIconData, type LucideIconNode} from '@lucide/angular';
+import iconNodes from 'lucide-static/icon-nodes.json';
+import {SvgContentDirective} from '../icon/svg-content.directive';
interface SvgEntry {
name: string;
content: string;
- preview: SafeHtml | null;
+ preview: string | null;
error: string;
}
@@ -34,13 +35,23 @@ interface SvgIconBatchResponse {
results: IconSaveResult[];
}
+const lucideIconNodes = iconNodes as unknown as Record;
+
@Component({
selector: 'app-icon-picker-component',
imports: [
FormsModule,
Button,
- Tabs, TabList, Tab, TabPanels, TabPanel
+ Tabs, TabList, Tab, TabPanels, TabPanel,
+ SvgContentDirective,
+ LucideDynamicIcon,
+ LucideCirclePlus,
+ LucideImages,
+ LucidePalette,
+ LucideSearch,
+ LucideSparkles
],
+ providers: [provideLucideConfig({ size: 16, strokeWidth: 2 })],
templateUrl: './icon-picker-component.html',
styleUrl: './icon-picker-component.scss'
})
@@ -65,16 +76,20 @@ export class IconPickerComponent implements OnInit {
};
ref = inject(DynamicDialogRef);
- iconService = inject(IconService);
- iconCache = inject(IconCacheService);
- sanitizer = inject(DomSanitizer);
+ customSvgService = inject(CustomSvgService);
+ customSvgCache = inject(CustomSvgCacheService);
urlHelper = inject(UrlHelperService);
messageService = inject(MessageService);
userService = inject(UserService);
searchText: string = '';
selectedIcon: string | null = null;
- icons: string[] = IconCategoriesHelper.createIconList();
+ readonly lucideIconData = new Map(
+ Object.entries(lucideIconNodes)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([name, node]): [string, LucideIconData] => [name, {name, size: 24, node}]),
+ );
+ icons: string[] = [...this.lucideIconData.keys()];
private _activeTabIndex: string = '0';
@@ -91,7 +106,7 @@ export class IconPickerComponent implements OnInit {
svgContent: string = '';
svgName: string = '';
- svgPreview: SafeHtml | null = null;
+ svgPreview: string | null = null;
errorMessage: string = '';
svgEntries: SvgEntry[] = [];
@@ -131,14 +146,22 @@ export class IconPickerComponent implements OnInit {
selectIcon(icon: string): void {
this.selectedIcon = icon;
- this.ref.close({type: 'PRIME_NG', value: icon});
+ this.ref.close({type: 'LUCIDE', value: icon});
+ }
+
+ displayIconName(icon: string): string {
+ return icon.trim().replaceAll('-', ' ');
+ }
+
+ getLucideIconData(icon: string): LucideIconData | null {
+ return this.lucideIconData.get(icon) ?? null;
}
private loadSvgIcons(): void {
this.isLoadingSvgIcons = true;
this.svgIconsError = '';
- this.iconService.getIconNames().subscribe({
+ this.customSvgService.getIconNames().subscribe({
next: (names) => {
this.hasLoadedSvgIcons = true;
if (names.length === 0) {
@@ -148,9 +171,9 @@ export class IconPickerComponent implements OnInit {
}
from(names).pipe(
mergeMap(name =>
- this.iconCache.getCachedSanitized(name)
+ this.customSvgCache.getCachedSanitized(name)
? of(null)
- : this.iconService.getSvgIconContent(name).pipe(catchError(() => of(null))),
+ : this.customSvgService.getSvgIconContent(name).pipe(catchError(() => of(null))),
5
),
toArray()
@@ -167,8 +190,8 @@ export class IconPickerComponent implements OnInit {
});
}
- getSvgContent(iconName: string): SafeHtml | null {
- return this.iconCache.getCachedSanitized(iconName) || null;
+ getSvgContent(iconName: string): string | null {
+ return this.customSvgCache.getCachedSanitized(iconName) || null;
}
selectSvgIcon(iconName: string): void {
@@ -196,7 +219,7 @@ export class IconPickerComponent implements OnInit {
USE_PROFILES: { svg: true },
FORBID_TAGS: ['script', 'style', 'foreignObject']
});
- this.svgPreview = this.sanitizer.bypassSecurityTrustHtml(sanitized);
+ this.svgPreview = sanitized;
} catch {
this.svgPreview = null;
this.errorMessage = this.ERROR_MESSAGES.PARSE_ERROR;
@@ -256,7 +279,7 @@ export class IconPickerComponent implements OnInit {
svgData: entry.content
}));
- this.iconService.saveBatchSvgIcons(svgData).subscribe({
+ this.customSvgService.saveBatchSvgIcons(svgData).subscribe({
next: (response: SvgIconBatchResponse) => {
this.isSavingBatch = false;
let successCount = 0;
@@ -310,7 +333,7 @@ export class IconPickerComponent implements OnInit {
private deleteSvgIcon(iconName: string): void {
this.isLoadingSvgIcons = true;
- this.iconService.deleteSvgIcon(iconName).subscribe({
+ this.customSvgService.deleteSvgIcon(iconName).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
diff --git a/frontend/src/app/shared/components/icon/app-icon.directive.ts b/frontend/src/app/shared/components/icon/app-icon.directive.ts
new file mode 100644
index 000000000..04f47ee2a
--- /dev/null
+++ b/frontend/src/app/shared/components/icon/app-icon.directive.ts
@@ -0,0 +1,90 @@
+import {
+ Directive,
+ ElementRef,
+ effect,
+ inject,
+ Injectable,
+ input,
+ Renderer2,
+ Signal,
+ signal,
+ WritableSignal,
+} from '@angular/core';
+import DOMPurify from 'dompurify';
+
+@Injectable({providedIn: 'root'})
+export class LucideIconService {
+ private readonly cache = new Map>();
+
+ icon(name: string): Signal {
+ const cached = this.cache.get(name);
+ if (cached) {
+ return cached;
+ }
+
+ const result = signal(null);
+ this.cache.set(name, result);
+
+ fetch(`assets/lucide/${encodeURIComponent(name)}.svg`)
+ .then(response => {
+ if (!response.ok) {
+ return '';
+ }
+
+ return response.text();
+ })
+ .then(text => result.set(this.parseSvg(text)))
+ .catch(() => result.set(null));
+
+ return result;
+ }
+
+ private parseSvg(svgText: string): SVGSVGElement | null {
+ if (!svgText) {
+ return null;
+ }
+
+ const sanitizedSvgText = DOMPurify.sanitize(svgText, {USE_PROFILES: {svg: true}});
+ const parsed = new DOMParser().parseFromString(sanitizedSvgText, 'image/svg+xml');
+ if (parsed.querySelector('parsererror')) {
+ return null;
+ }
+
+ const svg = parsed.querySelector('svg');
+ return svg instanceof SVGSVGElement ? svg : null;
+ }
+}
+
+@Directive({
+ selector: 'svg[appIcon]',
+ standalone: true,
+})
+export class AppIconDirective {
+ readonly appIcon = input.required();
+
+ private readonly svg = inject>(ElementRef).nativeElement;
+ private readonly icons = inject(LucideIconService);
+ private readonly renderer = inject(Renderer2);
+
+ constructor() {
+ this.renderer.setAttribute(this.svg, 'viewBox', '0 0 24 24');
+ this.renderer.setAttribute(this.svg, 'width', '1em');
+ this.renderer.setAttribute(this.svg, 'height', '1em');
+ this.renderer.setAttribute(this.svg, 'fill', 'none');
+ this.renderer.setAttribute(this.svg, 'stroke', 'currentColor');
+ this.renderer.setAttribute(this.svg, 'stroke-width', '2');
+ this.renderer.setAttribute(this.svg, 'stroke-linecap', 'round');
+ this.renderer.setAttribute(this.svg, 'stroke-linejoin', 'round');
+ this.renderer.setAttribute(this.svg, 'aria-hidden', 'true');
+
+ effect(() => {
+ const icon = this.icons.icon(this.appIcon())();
+ while (this.svg.firstChild) {
+ this.renderer.removeChild(this.svg, this.svg.firstChild);
+ }
+ for (const child of Array.from(icon?.childNodes ?? [])) {
+ this.renderer.appendChild(this.svg, document.importNode(child, true));
+ }
+ });
+ }
+}
diff --git a/frontend/src/app/shared/components/icon/svg-content.directive.ts b/frontend/src/app/shared/components/icon/svg-content.directive.ts
new file mode 100644
index 000000000..3fa7e061e
--- /dev/null
+++ b/frontend/src/app/shared/components/icon/svg-content.directive.ts
@@ -0,0 +1,40 @@
+import {Directive, ElementRef, Renderer2, effect, inject, input} from '@angular/core';
+
+@Directive({
+ selector: '[appSvgContent]',
+ standalone: true,
+})
+export class SvgContentDirective {
+ readonly appSvgContent = input(null);
+
+ private readonly host = inject>(ElementRef).nativeElement;
+ private readonly renderer = inject(Renderer2);
+
+ constructor() {
+ effect(() => {
+ this.render(this.appSvgContent());
+ });
+ }
+
+ private render(svgText: string | null): void {
+ while (this.host.firstChild) {
+ this.renderer.removeChild(this.host, this.host.firstChild);
+ }
+
+ if (!svgText) {
+ return;
+ }
+
+ const parsed = new DOMParser().parseFromString(svgText, 'image/svg+xml');
+ if (parsed.querySelector('parsererror')) {
+ return;
+ }
+
+ const svg = parsed.querySelector('svg');
+ if (!(svg instanceof SVGSVGElement)) {
+ return;
+ }
+
+ this.renderer.appendChild(this.host, document.importNode(svg, true));
+ }
+}
diff --git a/frontend/src/app/shared/helpers/icon-categories.helper.spec.ts b/frontend/src/app/shared/helpers/icon-categories.helper.spec.ts
deleted file mode 100644
index ac70346f6..000000000
--- a/frontend/src/app/shared/helpers/icon-categories.helper.spec.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import {describe, expect, it} from 'vitest';
-
-import {IconCategoriesHelper} from './icon-categories.helper';
-
-describe('IconCategoriesHelper', () => {
- it('creates a prime icon class list from the static categories', () => {
- const icons = IconCategoriesHelper.createIconList();
-
- expect(icons[0]).toBe('pi pi-address-book');
- expect(icons.at(-1)).toBe('pi pi-youtube');
- expect(new Set(icons).size).toBe(icons.length);
- expect(icons).toContain('pi pi-book');
- expect(icons).toContain('pi pi-shield');
- });
-});
diff --git a/frontend/src/app/shared/helpers/icon-categories.helper.ts b/frontend/src/app/shared/helpers/icon-categories.helper.ts
deleted file mode 100644
index a20b50c75..000000000
--- a/frontend/src/app/shared/helpers/icon-categories.helper.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-export class IconCategoriesHelper {
- static readonly CATEGORIES: 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"
- ];
-
- static createIconList(): string[] {
- return this.CATEGORIES.map(iconName => `pi pi-${iconName}`);
- }
-}
diff --git a/frontend/src/app/shared/icons/icon-selection.ts b/frontend/src/app/shared/icons/icon-selection.ts
new file mode 100644
index 000000000..c1369fa63
--- /dev/null
+++ b/frontend/src/app/shared/icons/icon-selection.ts
@@ -0,0 +1,9 @@
+export type IconType = 'LUCIDE' | 'CUSTOM_SVG';
+
+export interface IconSelection {
+ type: IconType;
+ value: string;
+}
+
+export const toIconSelection = (value: string, type: IconType | null | undefined): IconSelection =>
+ type === 'CUSTOM_SVG' ? {type: 'CUSTOM_SVG', value} : {type: 'LUCIDE', value};
diff --git a/frontend/src/app/shared/layout/layout-mobile-topbar/app.mobile-topbar.component.html b/frontend/src/app/shared/layout/layout-mobile-topbar/app.mobile-topbar.component.html
index 53e5a2dcf..df160379d 100644
--- a/frontend/src/app/shared/layout/layout-mobile-topbar/app.mobile-topbar.component.html
+++ b/frontend/src/app/shared/layout/layout-mobile-topbar/app.mobile-topbar.component.html
@@ -6,7 +6,7 @@
[attr.aria-label]="t('menu.toggleNavigation')"
(click)="layoutService.onMenuToggle()"
>
-
+
@@ -154,7 +154,7 @@
tooltipPosition="right"
(click)="openSearch()"
>
-
+
@@ -181,7 +181,7 @@
[attr.aria-expanded]="addMenuOpen() ? 'true' : 'false'"
(click)="toggleAddMenu($event, addMenu)"
>
-
+
@@ -195,7 +195,7 @@
tooltipPosition="top"
(click)="openUploadDialog()"
>
-
+
}
@@ -214,7 +214,7 @@
(click)="toggleFooterNotificationsPopover(notificationsFooterOrigin)"
>