Skip to content

Commit

Permalink
feat: 🎸 add inline fallback input
Browse files Browse the repository at this point in the history
  • Loading branch information
NetanelBasal committed Dec 28, 2022
1 parent c495826 commit 9c6cef3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/ngneat/svg-icon/src/lib/svg-icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SVG_CONFIG, SVG_ICONS_CONFIG } from './providers';
})
export class SvgIconComponent {
@Input() key!: SvgIcons;
@Input() fallback!: SvgIcons;
@Input() size!: keyof SVG_CONFIG['sizes'];
@Input() width!: number | string;
@Input() height!: number | string;
Expand Down Expand Up @@ -117,7 +118,9 @@ export class SvgIconComponent {

private setIcon(name: string) {
const config = { preserveAspectRatio: this.preserveAspectRatio };
const icon = this.registry.get(name, config) ?? this.registry.get(this.config.missingIconFallback?.name, config);
const icon =
this.registry.get(name, config) ??
this.registry.get(this.fallback ?? this.config.missingIconFallback?.name, config);

if (icon) {
this.element.setAttribute('aria-label', `${name}-icon`);
Expand Down

0 comments on commit 9c6cef3

Please sign in to comment.