1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00
Files
browser/libs/vault/src/components/org-icon.directive.ts
Nick Krantz cf9bc7c455 Vault Strict Typing cleanup (#12512)
* remove strict types from `NewDeviceVerificationNotice`
- Add null default value for class properties
- Enforce that the userId is passed
- noticeState$ can return null

* remove strict types from `CopyCipherFieldService`
- refactor title to be a string rather than null

* remove strict types from `PasswordRepromptComponent`
- add guard to exit early on submit but also solves removing null/undefined from typing

* use bang to ensure required input

* remove strict types from `CopyCipherFieldDirective`
- add bang for required types
- add default values for null types

* add bang for constant variables in cipher form stories

* remove strict types from `DeleteAttachmentComponent`
- add bang for required types
- refactor title to be an empty string

* fix tests
2025-01-02 15:37:48 -06:00

51 lines
1.2 KiB
TypeScript

import { Directive, ElementRef, HostBinding, Input, Renderer2 } from "@angular/core";
import { ProductTierType } from "@bitwarden/common/billing/enums";
export type OrgIconSize = "default" | "small" | "large";
@Directive({
standalone: true,
selector: "[appOrgIcon]",
})
export class OrgIconDirective {
@Input({ required: true }) tierType!: ProductTierType;
@Input() size?: OrgIconSize = "default";
constructor(
private el: ElementRef,
private renderer: Renderer2,
) {
this.renderer.setAttribute(this.el.nativeElement, "aria-hidden", "true");
}
get iconSize(): "bwi-sm" | "bwi-lg" | "" {
switch (this.size) {
case "small":
return "bwi-sm";
case "large":
return "bwi-lg";
default:
return "";
}
}
get orgIcon(): string {
switch (this.tierType) {
case ProductTierType.Free:
case ProductTierType.Families:
return "bwi-family";
case ProductTierType.Teams:
case ProductTierType.Enterprise:
case ProductTierType.TeamsStarter:
return "bwi-business";
default:
return "";
}
}
@HostBinding("class") get classList() {
return ["bwi", this.iconSize, this.orgIcon];
}
}