mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
* create libs/assets * treeshake lib and filter out non-icons from icon story * update docs * fix icon colors in browser and desktop * better name for vault icon * move illustrations
33 lines
779 B
TypeScript
33 lines
779 B
TypeScript
import { Component, effect, input } from "@angular/core";
|
|
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
|
|
|
|
import { Icon, isIcon } from "@bitwarden/assets/svg";
|
|
|
|
@Component({
|
|
selector: "bit-icon",
|
|
host: {
|
|
"[attr.aria-hidden]": "!ariaLabel()",
|
|
"[attr.aria-label]": "ariaLabel()",
|
|
"[innerHtml]": "innerHtml",
|
|
},
|
|
template: ``,
|
|
})
|
|
export class BitIconComponent {
|
|
innerHtml: SafeHtml | null = null;
|
|
|
|
readonly icon = input<Icon>();
|
|
|
|
readonly ariaLabel = input<string>();
|
|
|
|
constructor(private domSanitizer: DomSanitizer) {
|
|
effect(() => {
|
|
const icon = this.icon();
|
|
if (!isIcon(icon)) {
|
|
return;
|
|
}
|
|
const svg = icon.svg;
|
|
this.innerHtml = this.domSanitizer.bypassSecurityTrustHtml(svg);
|
|
});
|
|
}
|
|
}
|