AAE-43331 Expand adf-icon (#11744)

* AAE-43331 Expand adf-icon

* AAE-43331 Fix css
This commit is contained in:
Diogo Bastos
2026-03-18 11:12:58 +00:00
committed by GitHub
parent 759d206302
commit ebf742c54b
3 changed files with 18 additions and 4 deletions
@@ -84,5 +84,14 @@ describe('IconDirective', () => {
expect(await iconHarness.getType()).toBe(IconType.SVG);
expect(await iconHarness.getName()).toContain('mock_alias');
});
it('should set svg icon if alias map is provided and name matches an alias value directly', async () => {
component.name = 'mock_alias';
const iconHarness = await loader.getHarness(MatIconHarness);
expect(await iconHarness.getType()).toBe(IconType.SVG);
expect(await iconHarness.getName()).toContain('mock_alias');
});
});
});
+9 -1
View File
@@ -31,7 +31,7 @@ export class IconDirective implements OnChanges {
@Input('adf-icon') name: string;
ngOnChanges() {
const iconAlias = this.aliasMap?.[this.name];
const iconAlias = this.getIconAlias();
iconAlias ? this.setSvgIcon(iconAlias) : this.appendLigatureText();
}
@@ -60,4 +60,12 @@ export class IconDirective implements OnChanges {
private resetSvgIcon() {
this.matIcon.svgIcon = null;
}
private getIconAlias(): string | undefined {
if (!this.aliasMap) {
return undefined;
}
return this.aliasMap[this.name] ?? (Object.values(this.aliasMap).includes(this.name) ? this.name : undefined);
}
}
@@ -8,9 +8,6 @@
width: 100%;
&__icon > *:first-child {
font-size: var(--theme-display-3-font-size);
height: var(--theme-display-3-font-size);
width: var(--theme-display-3-font-size);
opacity: 0.6;
}