Skip to content

Commit cb089fb

Browse files
simeonoffChronosSFdamyanpetev
authored
refactor(icon-service): update icon reference names and registration (#14598)
* refactor(icon-service): update icon reference names and registration --------- Co-authored-by: Stamen Stoychev <[email protected]> Co-authored-by: Damyan Petev <[email protected]>
1 parent 3908350 commit cb089fb

File tree

75 files changed

+818
-1380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+818
-1380
lines changed

projects/igniteui-angular-elements/src/lib/icon.broadcast.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable, Optional } from '@angular/core';
22
import { PlatformUtil } from '../../../igniteui-angular/src/lib/core/utils';
3-
import { IconMeta, IgxIconService } from '../../../igniteui-angular/src/lib/icon/icon.service';
3+
import { IgxIconService } from '../../../igniteui-angular/src/lib/icon/icon.service';
4+
import { IconMeta } from '../../../igniteui-angular/src/lib/icon/public_api';
45

56

67
export interface SvgIcon {

projects/igniteui-angular/src/lib/action-strip/action-strip.component.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common';
2929
import { getCurrentResourceStrings } from '../core/i18n/resources';
3030
import { IgxIconButtonDirective } from '../directives/button/icon-button.directive';
3131
import { IgxActionStripToken } from './token';
32-
import { IgxIconService } from '../icon/icon.service';
3332

3433
@Directive({
3534
selector: '[igxActionStripMenuItem]',
@@ -202,13 +201,7 @@ export class IgxActionStripComponent implements IgxActionStripToken, AfterConten
202201
protected el: ElementRef,
203202
/** @hidden @internal **/
204203
public cdr: ChangeDetectorRef,
205-
protected _iconService: IgxIconService,
206-
) {
207-
this._iconService.addIconRef('more_vert', 'default', {
208-
name: 'more_vert',
209-
family: 'material',
210-
});
211-
}
204+
) { }
212205

213206
/**
214207
* Menu Items list.
@@ -336,4 +329,3 @@ export class IgxActionStripComponent implements IgxActionStripToken, AfterConten
336329
}
337330
}
338331
}
339-
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
<ng-container *ngIf="isRowContext">
33
<igx-grid-action-button *ngIf="!disabled && editRow" [asMenuItem]="asMenuItems" iconName="edit" [labelText]="grid.resourceStrings.igx_grid_actions_edit_label" (actionClick)="startEdit($event)"></igx-grid-action-button>
4-
<igx-grid-action-button *ngIf="addRow && isRootRow" [asMenuItem]="asMenuItems" iconName="add-row" iconSet="imx-icons" [labelText]="grid.resourceStrings.igx_grid_actions_add_label" (actionClick)="addRowHandler($event)"></igx-grid-action-button>
5-
<igx-grid-action-button *ngIf="addChild && hasChildren" [asMenuItem]="asMenuItems" iconName="add-child" iconSet="imx-icons" [labelText]="grid.resourceStrings.igx_grid_actions_add_child_label" (actionClick)="addRowHandler($event, true)"></igx-grid-action-button>
4+
<igx-grid-action-button *ngIf="addRow && isRootRow" [asMenuItem]="asMenuItems" iconName="add_row" iconSet="default" [labelText]="grid.resourceStrings.igx_grid_actions_add_label" (actionClick)="addRowHandler($event)"></igx-grid-action-button>
5+
<igx-grid-action-button *ngIf="addChild && hasChildren" [asMenuItem]="asMenuItems" iconName="add_child" iconSet="default" [labelText]="grid.resourceStrings.igx_grid_actions_add_child_label" (actionClick)="addRowHandler($event, true)"></igx-grid-action-button>
66
<igx-grid-action-button *ngIf="!disabled && deleteRow" class="igx-action-strip__delete" classNames='igx-action-strip__menu-item--danger' [asMenuItem]="asMenuItems" iconName="delete" [labelText]="grid.resourceStrings.igx_grid_actions_delete_label" (actionClick)="deleteRowHandler($event)"></igx-grid-action-button>
77
</ng-container>
88

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-editing-actions.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,5 @@ export class IgxGridEditingActionsComponent extends IgxGridActionsBaseDirective
178178
private registerIcons() {
179179
this.iconService.addSvgIconFromText(addRow.name, addRow.value, 'imx-icons', true,);
180180
this.iconService.addSvgIconFromText(addChild.name, addChild.value, 'imx-icons', true);
181-
this.iconService.addIconRef(addRow.name, 'default', { name: addRow.name, family: 'imx-icons' });
182-
this.iconService.addIconRef(addChild.name, 'default', { name: addChild.name, family: 'imx-icons' });
183181
}
184182
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ng-container *ngIf="isRowContext">
2-
<igx-grid-action-button *ngIf="inPinnedArea && pinnedTop" [asMenuItem]="asMenuItems" iconSet="default" iconName="jump-down" [labelText]="grid.resourceStrings.igx_grid_actions_jumpDown_label" (actionClick)="scrollToRow($event)"></igx-grid-action-button>
3-
<igx-grid-action-button *ngIf="inPinnedArea && !pinnedTop" [asMenuItem]="asMenuItems" iconSet="default" iconName="jump-up" [labelText]="grid.resourceStrings.igx_grid_actions_jumpUp_label" (actionClick)="scrollToRow($event)"></igx-grid-action-button>
4-
<igx-grid-action-button *ngIf="!pinned" [asMenuItem]="asMenuItems" iconSet="default" iconName="pin-left" [labelText]="grid.resourceStrings.igx_grid_actions_pin_label" (actionClick)="pin($event)"></igx-grid-action-button>
5-
<igx-grid-action-button *ngIf="pinned" [asMenuItem]="asMenuItems" iconSet="default" iconName="unpin-left" [labelText]="grid.resourceStrings.igx_grid_actions_unpin_label" (actionClick)="unpin($event)"></igx-grid-action-button>
2+
<igx-grid-action-button *ngIf="inPinnedArea && pinnedTop" [asMenuItem]="asMenuItems" iconSet="default" iconName="jump_down" [labelText]="grid.resourceStrings.igx_grid_actions_jumpDown_label" (actionClick)="scrollToRow($event)"></igx-grid-action-button>
3+
<igx-grid-action-button *ngIf="inPinnedArea && !pinnedTop" [asMenuItem]="asMenuItems" iconSet="default" iconName="jump_up" [labelText]="grid.resourceStrings.igx_grid_actions_jumpUp_label" (actionClick)="scrollToRow($event)"></igx-grid-action-button>
4+
<igx-grid-action-button *ngIf="!pinned" [asMenuItem]="asMenuItems" iconSet="default" iconName="pin" [labelText]="grid.resourceStrings.igx_grid_actions_pin_label" (actionClick)="pin($event)"></igx-grid-action-button>
5+
<igx-grid-action-button *ngIf="pinned" [asMenuItem]="asMenuItems" iconSet="default" iconName="unpin" [labelText]="grid.resourceStrings.igx_grid_actions_unpin_label" (actionClick)="unpin($event)"></igx-grid-action-button>
66
</ng-container>

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-pinning-actions.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('igxGridPinningActions #grid ', () => {
3939
fixture.detectChanges();
4040
let pinningButtons = fixture.debugElement.queryAll(By.css(`igx-grid-pinning-actions button`));
4141
expect(pinningButtons.length).toBe(1);
42-
expect(pinningButtons[0].componentInstance.iconName).toBe('pin-left');
42+
expect(pinningButtons[0].componentInstance.iconName).toBe('pin');
4343
pinningButtons[0].triggerEventHandler('click', new Event('click'));
4444
actionStrip.hide();
4545
fixture.detectChanges();
@@ -49,7 +49,7 @@ describe('igxGridPinningActions #grid ', () => {
4949
fixture.detectChanges();
5050
pinningButtons = fixture.debugElement.queryAll(By.css(`igx-grid-pinning-actions button`));
5151
expect(pinningButtons.length).toBe(2);
52-
expect(pinningButtons[1].componentInstance.iconName).toBe('unpin-left');
52+
expect(pinningButtons[1].componentInstance.iconName).toBe('unpin');
5353
pinningButtons[1].triggerEventHandler('click', new Event('click'));
5454
actionStrip.hide();
5555
fixture.detectChanges();

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-pinning-actions.component.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,7 @@ export class IgxGridPinningActionsComponent extends IgxGridActionsBaseDirective
140140
this.iconService.addSvgIconFromText(pinLeft.name, pinLeft.value, 'imx-icons', true);
141141
this.iconService.addSvgIconFromText(unpinLeft.name, unpinLeft.value, 'imx-icons', true);
142142
this.iconService.addSvgIconFromText(jumpDown.name, jumpDown.value, 'imx-icons', true);
143-
this.iconService.addSvgIconFromText(jumpUp.name, jumpDown.value, 'imx-icons', true);
144-
145-
this.iconService.addIconRef(pinLeft.name, "default", {
146-
name: pinLeft.name,
147-
family: "imx-icons",
148-
});
149-
this.iconService.addIconRef(unpinLeft.name, "default", {
150-
name: unpinLeft.name,
151-
family: "imx-icons",
152-
});
153-
this.iconService.addIconRef(jumpDown.name, "default", {
154-
name: jumpDown.name,
155-
family: "imx-icons",
156-
});
157-
this.iconService.addIconRef(jumpUp.name, "default", {
158-
name: jumpDown.name,
159-
family: "imx-icons",
160-
});
143+
this.iconService.addSvgIconFromText(jumpUp.name, jumpUp.value, 'imx-icons', true);
161144
}
162145
}
163146
}

projects/igniteui-angular/src/lib/calendar/calendar-base.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { getCurrentResourceStrings } from '../core/i18n/resources';
1111
import { KeyboardNavigationService } from './calendar.services';
1212
import { getYearRange, isDateInRanges } from './common/helpers';
1313
import { CalendarDay } from './common/model';
14-
import { IgxIconService } from '../icon/icon.service';
1514

1615
/** @hidden @internal */
1716
@Directive({
@@ -240,25 +239,6 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
240239
year: false
241240
};
242241

243-
private _icons = [
244-
{
245-
family: 'default',
246-
name: 'arrow_next',
247-
ref: {
248-
name: 'keyboard_arrow_right',
249-
family: 'material',
250-
}
251-
},
252-
{
253-
family: 'default',
254-
name: 'arrow_prev',
255-
ref: {
256-
name: 'keyboard_arrow_left',
257-
family: 'material',
258-
}
259-
}
260-
];
261-
262242
/**
263243
* An accessor that sets the resource strings.
264244
* By default it uses EN resources.
@@ -675,15 +655,9 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
675655
protected _localeId: string,
676656
protected keyboardNavigation?: KeyboardNavigationService,
677657
protected cdr?: ChangeDetectorRef,
678-
protected iconService?: IgxIconService,
679658
) {
680659
this.locale = _localeId;
681660
this.viewDate = this.viewDate ? this.viewDate : new Date();
682-
683-
for (const icon of this._icons) {
684-
this.iconService?.addIconRef(icon.name, icon.family, icon.ref);
685-
}
686-
687661
this.initFormatters();
688662
}
689663

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
isDateInRanges,
3232
} from "../common/helpers";
3333
import { CalendarDay } from '../common/model';
34-
import { IgxIconService } from '../../icon/icon.service';
3534

3635
let NEXT_ID = 0;
3736

@@ -207,9 +206,8 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
207206
@Inject(LOCALE_ID) _localeId: string,
208207
protected el: ElementRef,
209208
public override cdr: ChangeDetectorRef,
210-
protected override iconService: IgxIconService
211209
) {
212-
super(platform, _localeId, null, cdr, iconService);
210+
super(platform, _localeId, null, cdr);
213211
}
214212

215213
/**

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NgIf, NgClass, NgFor, NgTemplateOutlet } from '@angular/common';
22
import {
33
AfterContentInit,
4-
AfterViewInit,
54
ChangeDetectorRef,
65
Component,
76
ContentChild,
@@ -37,9 +36,6 @@ import { IgxIconComponent } from '../icon/icon.component';
3736
import { getCurrentResourceStrings } from '../core/i18n/resources';
3837
import { HammerGesturesManager } from '../core/touch';
3938
import { CarouselIndicatorsOrientation, HorizontalAnimationType } from './enums';
40-
import { ThemeService } from '../services/theme/theme.service';
41-
import type { IgxTheme } from '../services/theme/theme.service';
42-
import { IgxIconService } from '../icon/icon.service';
4339

4440
let NEXT_ID = 0;
4541

@@ -89,7 +85,7 @@ export class CarouselHammerConfig extends HammerGestureConfig {
8985
imports: [IgxIconComponent, NgIf, NgClass, NgFor, NgTemplateOutlet]
9086
})
9187

92-
export class IgxCarouselComponent extends IgxCarouselComponentBase implements OnDestroy, AfterViewInit, AfterContentInit {
88+
export class IgxCarouselComponent extends IgxCarouselComponentBase implements OnDestroy, AfterContentInit {
9389

9490
/**
9591
* Sets the `id` of the carousel.
@@ -145,11 +141,6 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
145141
return this.gesturesSupport ? 'pan-y' : 'auto';
146142
}
147143

148-
/**
149-
* @hidden @internal
150-
*/
151-
protected theme: IgxTheme;
152-
153144
/**
154145
* Sets whether the carousel should `loop` back to the first slide after reaching the last slide.
155146
* Default value is `true`.
@@ -398,36 +389,6 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
398389
private destroy$ = new Subject<any>();
399390
private differ: IterableDiffer<IgxSlideComponent> | null = null;
400391
private incomingSlide: IgxSlideComponent;
401-
private _icons = [
402-
{
403-
name: 'carousel_prev',
404-
family: 'default',
405-
ref: new Map(Object.entries({
406-
'material': {
407-
name: 'arrow_back',
408-
family: 'material'
409-
},
410-
'indigo': {
411-
name: 'keyboard_arrow_left',
412-
family: 'material'
413-
}
414-
}))
415-
},
416-
{
417-
name: 'carousel_next',
418-
family: 'default',
419-
ref: new Map(Object.entries({
420-
'material': {
421-
name: 'arrow_forward',
422-
family: 'material'
423-
},
424-
'indigo': {
425-
name: 'keyboard_arrow_right',
426-
family: 'material'
427-
}
428-
}))
429-
}
430-
]
431392

432393
/**
433394
* An accessor that sets the resource strings.
@@ -583,8 +544,6 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
583544
private iterableDiffers: IterableDiffers,
584545
@Inject(IgxAngularAnimationService) animationService: AnimationService,
585546
private platformUtil: PlatformUtil,
586-
private themeService: ThemeService,
587-
private iconService: IgxIconService
588547
) {
589548
super(animationService, cdr);
590549
this.differ = this.iterableDiffers.find([]).create(null);
@@ -719,37 +678,6 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
719678
}
720679
}
721680

722-
/** @hidden */
723-
public ngAfterViewInit() {
724-
this.cdr.detach();
725-
726-
if (!this.theme) {
727-
this.theme = this.themeService.getComponentTheme(this.element);
728-
}
729-
730-
for (const icon of this._icons) {
731-
switch(this.theme) {
732-
case 'indigo':
733-
this.iconService.addIconRef(
734-
icon.name,
735-
icon.family,
736-
icon.ref.get('indigo'),
737-
);
738-
break;
739-
case 'material':
740-
default:
741-
this.iconService.addIconRef(
742-
icon.name,
743-
icon.family,
744-
icon.ref.get('material'),
745-
);
746-
}
747-
}
748-
749-
this.cdr.detectChanges();
750-
this.cdr.reattach();
751-
}
752-
753681
/** @hidden */
754682
public ngAfterContentInit() {
755683
this.slides.changes

0 commit comments

Comments
 (0)