1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-13 23:13:36 +00:00
Files
browser/libs/auth/src/angular/anon-layout/anon-layout.component.ts
rr-bw c5a267baad [PM-11000] AnonLayout Icon/Logo theme refactor (#10549)
* update base anon-layout logo/icon

* update ExtensionAnonLayout logo/icon based on theme

* remove hard-coded fill

* remove solarizedDark class

---------

Co-authored-by: Bernd Schoolmann <mail@quexten.com>
2024-08-31 12:26:11 -07:00

69 lines
2.3 KiB
TypeScript

import { CommonModule } from "@angular/common";
import { Component, Input, OnChanges, OnInit, SimpleChanges } from "@angular/core";
import { firstValueFrom } from "rxjs";
import { ClientType } from "@bitwarden/common/enums";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { IconModule, Icon } from "../../../../components/src/icon";
import { SharedModule } from "../../../../components/src/shared";
import { TypographyModule } from "../../../../components/src/typography";
import { BitwardenLogo, BitwardenShield } from "../icons";
@Component({
standalone: true,
selector: "auth-anon-layout",
templateUrl: "./anon-layout.component.html",
imports: [IconModule, CommonModule, TypographyModule, SharedModule],
})
export class AnonLayoutComponent implements OnInit, OnChanges {
@Input() title: string;
@Input() subtitle: string;
@Input() icon: Icon;
@Input() showReadonlyHostname: boolean;
@Input() hideLogo: boolean = false;
@Input() hideFooter: boolean = false;
@Input() decreaseTopPadding: boolean = false;
/**
* Max width of the layout content
*
* @default 'md'
*/
@Input() maxWidth: "md" | "3xl" = "md";
protected logo = BitwardenLogo;
protected year = "2024";
protected clientType: ClientType;
protected hostname: string;
protected version: string;
protected hideYearAndVersion = false;
constructor(
private environmentService: EnvironmentService,
private platformUtilsService: PlatformUtilsService,
) {
this.year = new Date().getFullYear().toString();
this.clientType = this.platformUtilsService.getClientType();
this.hideYearAndVersion = this.clientType !== ClientType.Web;
}
async ngOnInit() {
this.maxWidth = this.maxWidth ?? "md";
this.hostname = (await firstValueFrom(this.environmentService.environment$)).getHostname();
this.version = await this.platformUtilsService.getApplicationVersion();
// If there is no icon input, then use the default icon
if (this.icon == null) {
this.icon = BitwardenShield;
}
}
async ngOnChanges(changes: SimpleChanges) {
if (changes.maxWidth) {
this.maxWidth = changes.maxWidth.currentValue ?? "md";
}
}
}