mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
* adds aria-hidden to bit-icon when no aria-label provided * add ariaLabel to logo svg usages * add ariaLabel documentation * default ariaLable value to undefined * add logo label to translations * adds i18n pipe to component * Add binding to example docs
32 lines
720 B
TypeScript
32 lines
720 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: ``,
|
|
standalone: true,
|
|
})
|
|
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) {}
|
|
}
|