Skip to content

Commit ff2426a

Browse files
feat(icon): permite chavear lib de ícones
Permite chavear qual lib de ícones deverá ser utilizada Fixes DTHFUI-9157
1 parent b1a182b commit ff2426a

21 files changed

+486
-249
lines changed

projects/ui/src/lib/components/po-field/po-checkbox/po-checkbox.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
aria-label=" "
1818
[id]="id"
1919
class="po-checkbox"
20+
[ngClass]="iconNameLib === 'PhosphorIcon' ? 'po-checkbox-phosphor' : 'po-checkbox-poicon'"
2021
[attr.aria-disabled]="disabled"
2122
[attr.required]="checkBoxRequired"
2223
>

projects/ui/src/lib/components/po-field/po-checkbox/po-checkbox.component.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import {
2+
AfterViewInit,
23
ChangeDetectionStrategy,
34
ChangeDetectorRef,
45
Component,
56
ElementRef,
6-
forwardRef,
7+
Inject,
8+
Optional,
79
ViewChild,
8-
AfterViewInit
10+
forwardRef
911
} from '@angular/core';
1012
import { NG_VALUE_ACCESSOR } from '@angular/forms';
1113

1214
import { PoKeyCodeEnum } from './../../../enums/po-key-code.enum';
15+
import { ICONS_DICTIONARY, PoIconDictionary } from '../../po-icon';
1316

1417
import { PoCheckboxBaseComponent } from './po-checkbox-base.component';
1518

@@ -46,10 +49,17 @@ import { PoCheckboxBaseComponent } from './po-checkbox-base.component';
4649
]
4750
})
4851
export class PoCheckboxComponent extends PoCheckboxBaseComponent implements AfterViewInit {
52+
private _iconToken: { [key: string]: string };
53+
4954
@ViewChild('checkboxLabel', { static: true }) checkboxLabel: ElementRef;
5055

51-
constructor(private changeDetector: ChangeDetectorRef) {
56+
constructor(
57+
@Optional() @Inject(ICONS_DICTIONARY) value: { [key: string]: string },
58+
private changeDetector: ChangeDetectorRef
59+
) {
5260
super();
61+
62+
this._iconToken = value ?? PoIconDictionary;
5363
}
5464

5565
/**
@@ -103,4 +113,8 @@ export class PoCheckboxComponent extends PoCheckboxBaseComponent implements Afte
103113
}
104114
this.changeDetector.detectChanges();
105115
}
116+
117+
get iconNameLib() {
118+
return this._iconToken.NAME_LIB;
119+
}
106120
}

projects/ui/src/lib/components/po-field/po-select/po-select.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<select
1111
#select
1212
class="po-select"
13+
[ngClass]="iconNameLib === 'PhosphorIcon' ? 'po-select-phosphor' : 'po-select-poicon'"
1314
[attr.name]="name"
1415
[class.po-select-placeholder]="!selectedValue?.toString() && !!placeholder"
1516
[disabled]="disabled"

projects/ui/src/lib/components/po-field/po-select/po-select.component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import {
44
Component,
55
ElementRef,
66
EventEmitter,
7-
forwardRef,
7+
Inject,
88
Input,
99
OnChanges,
10+
Optional,
1011
Output,
1112
Renderer2,
1213
SimpleChanges,
13-
ViewChild
14+
ViewChild,
15+
forwardRef
1416
} from '@angular/core';
1517
import { AbstractControl, NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';
1618

@@ -23,6 +25,7 @@ import {
2325
validValue
2426
} from '../../../utils/util';
2527

28+
import { ICONS_DICTIONARY, PoIconDictionary } from '../../po-icon';
2629
import { PoFieldValidateModel } from '../po-field-validate.model';
2730
import { PoSelectOptionGroup } from './po-select-option-group.interface';
2831
import { PoSelectOption } from './po-select-option.interface';
@@ -90,6 +93,8 @@ const PO_SELECT_FIELD_VALUE_DEFAULT = 'value';
9093
]
9194
})
9295
export class PoSelectComponent extends PoFieldValidateModel<any> implements OnChanges {
96+
private _iconToken: { [key: string]: string };
97+
9398
@ViewChild('select', { read: ElementRef, static: true }) selectElement: ElementRef;
9499

95100
/**
@@ -244,12 +249,19 @@ export class PoSelectComponent extends PoFieldValidateModel<any> implements OnCh
244249
return this._fieldValue;
245250
}
246251

252+
get iconNameLib() {
253+
return this._iconToken.NAME_LIB;
254+
}
255+
247256
/* istanbul ignore next */
248257
constructor(
258+
@Optional() @Inject(ICONS_DICTIONARY) value: { [key: string]: string },
249259
private changeDetector: ChangeDetectorRef,
250260
public renderer: Renderer2
251261
) {
252262
super();
263+
264+
this._iconToken = value ?? PoIconDictionary;
253265
}
254266

255267
ngOnChanges(changes: SimpleChanges): void {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from './po-icon.component';
22

33
export * from './po-icon.module';
4+
5+
export * from './po-icon-dictionary';
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
import { InjectionToken } from '@angular/core';
2+
3+
export const ICONS_DICTIONARY = new InjectionToken<{ [key: string]: string }>('ICONS_TOKEN');
4+
5+
export const PoIconDictionary: { [key: string]: string } = {
6+
NAME_LIB: 'PoIcon',
7+
ICON_A11Y_ELDERLY: 'po-icon po-icon-a11y-elderly',
8+
ICON_A11Y_PREGNANT: 'po-icon po-icon-a11y-pregnant',
9+
ICON_A11Y_WHEELCHAIR: 'po-icon po-icon-a11y-wheelchair',
10+
ICON_AGRO_BUSINESS: 'po-icon po-icon-agro-business',
11+
ICON_ALIGN_CENTER: 'po-icon po-icon-align-center',
12+
ICON_ALIGN_JUSTIFY: 'po-icon po-icon-align-justify',
13+
ICON_ALIGN_LEFT: 'po-icon po-icon-align-left',
14+
ICON_ALIGN_RIGHT: 'po-icon po-icon-align-right',
15+
ICON_ANCHOR: 'po-icon po-icon-anchor',
16+
ICON_ARCHIVE: 'po-icon po-icon-archive',
17+
ICON_ARROW_DOWN: 'po-icon po-icon-arrow-down',
18+
ICON_ARROW_LEFT: 'po-icon po-icon-arrow-left',
19+
ICON_ARROW_RIGHT: 'po-icon po-icon-arrow-right',
20+
ICON_ARROW_UP: 'po-icon po-icon-arrow-up',
21+
ICON_ATTACH: 'po-icon po-icon-attach',
22+
ICON_AUTOMATIC_BARRIER: 'po-icon po-icon-automatic-barrier',
23+
ICON_BALANCE: 'po-icon po-icon-balance',
24+
ICON_BALANCE_WEIGHT: 'po-icon po-icon-balance-weight',
25+
ICON_BAR_CODE: 'po-icon po-icon-bar-code',
26+
ICON_BASKET: 'po-icon po-icon-basket',
27+
ICON_BLUETOOTH: 'po-icon po-icon-bluetooth',
28+
ICON_BOOK: 'po-icon po-icon-book',
29+
ICON_CALCULATOR: 'po-icon po-icon-calculator',
30+
ICON_CALENDAR: 'po-icon po-icon-calendar',
31+
ICON_CALENDAR_OK: 'po-icon po-icon-calendar-ok',
32+
ICON_CALENDAR_SETTINGS: 'po-icon po-icon-calendar-settings',
33+
ICON_CAMERA: 'po-icon po-icon-camera',
34+
ICON_CART: 'po-icon po-icon-cart',
35+
ICON_CHANGE: 'po-icon po-icon-change',
36+
ICON_CHART_AREA: 'po-icon po-icon-chart-area',
37+
ICON_CHART_COLUMNS: 'po-icon po-icon-chart-columns',
38+
ICON_CHAT: 'po-icon po-icon-chat',
39+
ICON_CLEAR_CONTENT: 'po-icon po-icon-clear-content',
40+
ICON_CLIPBOARD: 'po-icon po-icon-clipboard',
41+
ICON_CLOCK: 'po-icon po-icon-clock',
42+
ICON_CLOSE: 'po-icon po-icon-close',
43+
ICON_COMPANY: 'po-icon po-icon-company',
44+
ICON_CONSTRUCTION: 'po-icon po-icon-construction',
45+
ICON_COPY: 'po-icon po-icon-copy',
46+
ICON_COTTON: 'po-icon po-icon-cotton',
47+
ICON_CREDIT_PAYMENT: 'po-icon po-icon-credit-payment',
48+
ICON_CUT: 'po-icon po-icon-cut',
49+
ICON_DATABASE: 'po-icon po-icon-database',
50+
ICON_DEBIT_PAYMENT: 'po-icon po-icon-debit-payment',
51+
ICON_DELETE: 'po-icon po-icon-delete',
52+
ICON_DEVICE_DESKTOP: 'po-icon po-icon-device-desktop',
53+
ICON_DEVICE_NOTEBOOK: 'po-icon po-icon-device-notebook',
54+
ICON_DEVICE_SMARTPHONE: 'po-icon po-icon-device-smartphone',
55+
ICON_DEVICE_TABLET: 'po-icon po-icon-device-tablet',
56+
ICON_DOC_XLS: 'po-icon po-icon-doc-xls',
57+
ICON_DOCUMENT: 'po-icon po-icon-document',
58+
ICON_DOCUMENT_DOUBLE: 'po-icon po-icon-document-double',
59+
ICON_DOCUMENT_FILLED: 'po-icon po-icon-document-filled',
60+
ICON_DOWNLOAD: 'po-icon po-icon-download',
61+
ICON_EDIT: 'po-icon po-icon-edit',
62+
ICON_EXAM: 'po-icon po-icon-exam',
63+
ICON_EXCLAMATION: 'po-icon po-icon-exclamation',
64+
ICON_EXIT: 'po-icon po-icon-exit',
65+
ICON_EXPORT: 'po-icon po-icon-export',
66+
ICON_EYE: 'po-icon po-icon-eye',
67+
ICON_EYE_OFF: 'po-icon po-icon-eye-off',
68+
ICON_FILTER: 'po-icon po-icon-filter',
69+
ICON_FINANCE: 'po-icon po-icon-finance',
70+
ICON_FINANCE_BITCOIN: 'po-icon po-icon-finance-bitcoin',
71+
ICON_FINANCE_SECURE: 'po-icon po-icon-finance-secure',
72+
ICON_FIRST_PAGE: 'po-icon po-icon-first-page',
73+
ICON_FOLDER: 'po-icon po-icon-folder',
74+
ICON_FOOD: 'po-icon po-icon-food',
75+
ICON_FOOD_MENU: 'po-icon po-icon-food-menu',
76+
ICON_GAS: 'po-icon po-icon-gas',
77+
ICON_GIFT: 'po-icon po-icon-gift',
78+
ICON_GRID: 'po-icon po-icon-grid',
79+
ICON_HANDSHAKE: 'po-icon po-icon-handshake',
80+
ICON_HDD: 'po-icon po-icon-hdd',
81+
ICON_HELP: 'po-icon po-icon-help',
82+
ICON_HISTORY: 'po-icon po-icon-history',
83+
ICON_HOME: 'po-icon po-icon-home',
84+
ICON_IMAGE_ALIGN_INLINE: 'po-icon po-icon-image-align-inline',
85+
ICON_IMAGE_ALIGN_LEFT: 'po-icon po-icon-image-align-left',
86+
ICON_IMAGE_ALIGN_RIGHT: 'po-icon po-icon-image-align-right',
87+
ICON_INFO: 'po-icon po-icon-info',
88+
ICON_INJECTOR: 'po-icon po-icon-injector',
89+
ICON_KEYBOARD: 'po-icon po-icon-keyboard',
90+
ICON_LAST_PAGE: 'po-icon po-icon-last-page',
91+
ICON_LAYERS: 'po-icon po-icon-layers',
92+
ICON_LIGHT: 'po-icon po-icon-light',
93+
ICON_LIKE: 'po-icon po-icon-like',
94+
ICON_LINK: 'po-icon po-icon-link',
95+
ICON_LIST: 'po-icon po-icon-list',
96+
ICON_LOCK: 'po-icon po-icon-lock',
97+
ICON_LOCK_OFF: 'po-icon po-icon-lock-off',
98+
ICON_MAIL: 'po-icon po-icon-mail',
99+
ICON_MANUFACTURE: 'po-icon po-icon-manufacture',
100+
ICON_MAP: 'po-icon po-icon-map',
101+
ICON_MENU: 'po-icon po-icon-menu',
102+
ICON_MENU_CLOSE: 'po-icon po-icon-menu-close',
103+
ICON_MENU_OPEN: 'po-icon po-icon-menu-open',
104+
ICON_MESSAGE: 'po-icon po-icon-message',
105+
ICON_MICROPHONE: 'po-icon po-icon-microphone',
106+
ICON_MINUS: 'po-icon po-icon-minus',
107+
ICON_MINUS_CIRCLE: 'po-icon po-icon-minus-circle',
108+
ICON_MONEY: 'po-icon po-icon-money',
109+
ICON_MORE: 'po-icon po-icon-more',
110+
ICON_MORE_VERT: 'po-icon po-icon-more-vert',
111+
ICON_NEWS: 'po-icon po-icon-news',
112+
ICON_NO_SIGNAL: 'po-icon po-icon-no-signal',
113+
ICON_NOTIFICATION: 'po-icon po-icon-notification',
114+
ICON_OIL: 'po-icon po-icon-oil',
115+
ICON_OIL_ANALYSIS: 'po-icon po-icon-oil-analysis',
116+
ICON_OK: 'po-icon po-icon-ok',
117+
ICON_PALLET_FULL: 'po-icon po-icon-pallet-full',
118+
ICON_PALLET_PARTIAL: 'po-icon po-icon-pallet-partial',
119+
ICON_PARAMETERS: 'po-icon po-icon-parameters',
120+
ICON_PASTE: 'po-icon po-icon-paste',
121+
ICON_PAYMENT: 'po-icon po-icon-payment',
122+
ICON_PDF: 'po-icon po-icon-pdf',
123+
ICON_PICKER: 'po-icon po-icon-picker',
124+
ICON_PICTURE: 'po-icon po-icon-picture',
125+
ICON_PIN: 'po-icon po-icon-pin',
126+
ICON_PIX_LOGO: 'po-icon po-icon-pix-logo',
127+
ICON_PLUS: 'po-icon po-icon-plus',
128+
ICON_PLUS_CIRCLE: 'po-icon po-icon-plus-circle',
129+
ICON_PRINT: 'po-icon po-icon-print',
130+
ICON_PUSHCART: 'po-icon po-icon-pushcart',
131+
ICON_QR_CODE: 'po-icon po-icon-qr-code',
132+
ICON_REFRESH: 'po-icon po-icon-refresh',
133+
ICON_SALE: 'po-icon po-icon-sale',
134+
ICON_SCREEN_FULL: 'po-icon po-icon-screen-full',
135+
ICON_SCREEN_MINIMIZE: 'po-icon po-icon-screen-minimize',
136+
ICON_SEARCH: 'po-icon po-icon-search',
137+
ICON_SECURITY_GUARD: 'po-icon po-icon-security-guard',
138+
ICON_SERVER: 'po-icon po-icon-server',
139+
ICON_SETTINGS: 'po-icon po-icon-settings',
140+
ICON_SHARE: 'po-icon po-icon-share',
141+
ICON_SIGNAL: 'po-icon po-icon-signal',
142+
ICON_SMS: 'po-icon po-icon-sms',
143+
ICON_SOCIAL_GITHUB: 'po-icon po-icon-social-github',
144+
ICON_SOCIAL_INSTAGRAM: 'po-icon po-icon-social-instagram',
145+
ICON_SOCIAL_TWITTER: 'po-icon po-icon-social-twitter',
146+
ICON_SOCIAL_WHATSAPP: 'po-icon po-icon-social-whatsapp',
147+
ICON_SORT: 'po-icon po-icon-sort',
148+
ICON_SORT_ASC: 'po-icon po-icon-sort-asc',
149+
ICON_SORT_ASCENDING: 'po-icon po-icon-sort-ascending',
150+
ICON_SORT_DESC: 'po-icon po-icon-sort-desc',
151+
ICON_SORT_DESCENDING: 'po-icon po-icon-sort-descending',
152+
ICON_STAR: 'po-icon po-icon-star',
153+
ICON_STAR_FILLED: 'po-icon po-icon-star-filled',
154+
ICON_STAR_HALF: 'po-icon po-icon-star-half',
155+
ICON_STEERING_WHEEL: 'po-icon po-icon-steering-wheel',
156+
ICON_STOCK: 'po-icon po-icon-stock',
157+
ICON_TABLE: 'po-icon po-icon-table',
158+
ICON_TARGET: 'po-icon po-icon-target',
159+
ICON_TELEPHONE: 'po-icon po-icon-telephone',
160+
ICON_TEXT_BOLD: 'po-icon po-icon-text-bold',
161+
ICON_TEXT_ITALIC: 'po-icon po-icon-text-italic',
162+
ICON_TEXT_UNDERLINE: 'po-icon po-icon-text-underline',
163+
ICON_TOUCH: 'po-icon po-icon-touch',
164+
ICON_TRAVEL: 'po-icon po-icon-travel',
165+
ICON_TRUCK: 'po-icon po-icon-truck',
166+
ICON_UPLOAD: 'po-icon po-icon-upload',
167+
ICON_UPLOAD_CLOUD: 'po-icon po-icon-upload-cloud',
168+
ICON_USER: 'po-icon po-icon-user',
169+
ICON_USER_ADD: 'po-icon po-icon-user-add',
170+
ICON_USER_DELETE: 'po-icon po-icon-user-delete',
171+
ICON_USERS: 'po-icon po-icon-users',
172+
ICON_VIDEO_CALL: 'po-icon po-icon-video-call',
173+
ICON_WAITER: 'po-icon po-icon-waiter',
174+
ICON_WALLET: 'po-icon po-icon-wallet',
175+
ICON_WAREHOUSE: 'po-icon po-icon-warehouse',
176+
ICON_WARNING: 'po-icon po-icon-warning',
177+
ICON_WEIGHT: 'po-icon po-icon-weight',
178+
ICON_WORLD: 'po-icon po-icon-world',
179+
ICON_XML: 'po-icon po-icon-xml',
180+
ICON_ZOOM_IN: 'po-icon po-icon-zoom-in',
181+
ICON_ZOOM_OUT: 'po-icon po-icon-zoom-out'
182+
};
183+
184+
export const PhosphorIconDictionary: { [key: string]: string } = {
185+
NAME_LIB: 'PhosphorIcon',
186+
ICON_ALIGN_CENTER: 'ph ph-text-align-center',
187+
ICON_ALIGN_JUSTIFY: 'ph ph-text-align-justify',
188+
ICON_ALIGN_LEFT: 'ph ph-text-align-left',
189+
ICON_ALIGN_RIGHT: 'ph ph-text-align-right',
190+
ICON_ARROW_DOWN: 'ph ph-caret-down',
191+
ICON_ARROW_LEFT: 'ph ph-caret-left',
192+
ICON_ARROW_RIGHT: 'ph ph-caret-right',
193+
ICON_ARROW_UP: 'ph ph-caret-up',
194+
ICON_CALENDAR: 'ph ph-calendar-blank',
195+
ICON_CLEAR_CONTENT: 'ph ph-x-circle',
196+
ICON_CLOCK: 'ph ph-clock',
197+
ICON_CLOSE: 'ph ph-x',
198+
ICON_DELETE: 'ph ph-trash',
199+
ICON_DRAG: 'ph ph-dots-six-vertical',
200+
ICON_EDIT: 'ph ph-pencil-simple',
201+
ICON_EXCLAMATION: 'ph ph-warning-circle',
202+
ICON_EXIT: 'ph ph-sign-out',
203+
ICON_EYE: 'ph ph-eye',
204+
ICON_EYE_OFF: 'ph ph-eye-closed',
205+
ICON_FILTER: 'ph ph-funnel',
206+
ICON_HELP: 'ph ph-question',
207+
ICON_INFO: 'ph ph-info',
208+
ICON_LAST_PAGE: 'ph ph-caret-double-right',
209+
ICON_LINK: 'ph ph-link',
210+
ICON_LIST: 'ph ph-list-dashes',
211+
ICON_LOCK: 'ph ph-lock',
212+
ICON_MAIL: 'ph ph-envelope-simple',
213+
ICON_MENU: 'ph ph-list',
214+
ICON_MENU_CLOSE: 'ph ph-caret-circle-left',
215+
ICON_MENU_OPEN: 'ph ph-caret-circle-right',
216+
ICON_MINUS: 'ph ph-minus',
217+
ICON_MORE: 'ph ph-dots-three',
218+
ICON_MORE_VERT: 'ph ph-dots-three-vertical',
219+
ICON_NOTIFICATION: 'ph ph-bell',
220+
ICON_OK: 'ph ph-check',
221+
ICON_PARAMETERS: 'ph ph-sliders-horizontal',
222+
ICON_PICTURE: 'ph ph-image',
223+
ICON_PUSH_PIN: 'ph ph-push-pin',
224+
ICON_PUSH_PIN_SLASH: 'ph ph-push-pin-slash',
225+
ICON_REFRESH: 'ph ph-arrow-clockwise',
226+
ICON_SEARCH: 'ph ph-magnifying-glass',
227+
ICON_SETTINGS: 'ph ph-gear-six',
228+
ICON_SORT: 'ph ph-caret-up-down ',
229+
ICON_SORT_ASC: 'ph ph-caret-up',
230+
ICON_SORT_DESC: 'ph ph-caret-down',
231+
ICON_STAR: 'ph ph-star',
232+
ICON_TELEPHONE: 'ph ph-phone',
233+
ICON_TEXT_BOLD: 'ph ph-text-b',
234+
ICON_TEXT_ITALIC: 'ph ph-text-italic',
235+
ICON_TEXT_UNDERLINE: 'ph ph-text-underline',
236+
ICON_UPLOAD_CLOUD: 'ph ph-cloud-arrow-up',
237+
ICON_USER: 'ph ph-user',
238+
ICON_WARNING: 'ph ph-exclamation-mark',
239+
ICON_WORLD: 'ph ph-globe-simple'
240+
};

0 commit comments

Comments
 (0)