mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Move to libs
This commit is contained in:
39
libs/components/src/banner/banner.component.ts
Normal file
39
libs/components/src/banner/banner.component.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Component, Input, OnInit, Output, EventEmitter } from "@angular/core";
|
||||
|
||||
type BannerTypes = "premium" | "info" | "warning" | "danger";
|
||||
|
||||
const defaultIcon: Record<BannerTypes, string> = {
|
||||
premium: "bwi-star",
|
||||
info: "bwi-info-circle",
|
||||
warning: "bwi-exclamation-triangle",
|
||||
danger: "bwi-error",
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: "bit-banner",
|
||||
templateUrl: "./banner.component.html",
|
||||
})
|
||||
export class BannerComponent implements OnInit {
|
||||
@Input("bannerType") bannerType: BannerTypes = "info";
|
||||
@Input() icon: string;
|
||||
@Input() useAlertRole = true;
|
||||
|
||||
@Output() onClose = new EventEmitter<void>();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.icon ??= defaultIcon[this.bannerType];
|
||||
}
|
||||
|
||||
get bannerClass() {
|
||||
switch (this.bannerType) {
|
||||
case "danger":
|
||||
return "tw-bg-danger-500";
|
||||
case "info":
|
||||
return "tw-bg-info-500";
|
||||
case "premium":
|
||||
return "tw-bg-success-500";
|
||||
case "warning":
|
||||
return "tw-bg-warning-500";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user