mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
31 lines
700 B
TypeScript
31 lines
700 B
TypeScript
import { Component, Input } from "@angular/core";
|
|
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
|
|
|
|
import { Icon, isIcon } from "./icon";
|
|
|
|
@Component({
|
|
selector: "bit-icon",
|
|
host: {
|
|
"[attr.aria-hidden]": "!ariaLabel",
|
|
"[attr.aria-label]": "ariaLabel",
|
|
"[innerHtml]": "innerHtml",
|
|
},
|
|
template: ``,
|
|
})
|
|
export class BitIconComponent {
|
|
innerHtml: SafeHtml | null = null;
|
|
|
|
@Input() set icon(icon: Icon) {
|
|
if (!isIcon(icon)) {
|
|
return;
|
|
}
|
|
|
|
const svg = icon.svg;
|
|
this.innerHtml = this.domSanitizer.bypassSecurityTrustHtml(svg);
|
|
}
|
|
|
|
@Input() ariaLabel: string | undefined = undefined;
|
|
|
|
constructor(private domSanitizer: DomSanitizer) {}
|
|
}
|