mirror of
https://github.com/bitwarden/browser
synced 2026-02-02 17:53:41 +00:00
clean up callout
This commit is contained in:
@@ -16,21 +16,11 @@
|
||||
}
|
||||
<div class="tw-flex tw-flex-col tw-gap-0.5" [ngClass]="_truncate ? 'tw-truncate' : ''">
|
||||
@if (title) {
|
||||
<header
|
||||
id="{{ titleId }}"
|
||||
class="tw-text-base tw-font-semibold"
|
||||
[ngClass]="_truncate ? 'tw-truncate' : ''"
|
||||
[appA11yTitle]="_truncate ? title : ''"
|
||||
>
|
||||
<header id="{{ titleId }}" class="tw-text-base tw-font-semibold">
|
||||
{{ title }}
|
||||
</header>
|
||||
}
|
||||
<div
|
||||
#content
|
||||
bitTypography="body2"
|
||||
[ngClass]="_truncate ? 'tw-truncate' : ''"
|
||||
[appA11yTitle]="_truncate ? contentText() : ''"
|
||||
>
|
||||
<div #content bitTypography="body2">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
AfterViewInit,
|
||||
Component,
|
||||
computed,
|
||||
ElementRef,
|
||||
input,
|
||||
signal,
|
||||
afterNextRender,
|
||||
viewChild,
|
||||
TemplateRef,
|
||||
} from "@angular/core";
|
||||
import { Component, computed, input } from "@angular/core";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
|
||||
@@ -46,7 +36,7 @@ let nextId = 0;
|
||||
templateUrl: "callout.component.html",
|
||||
imports: [A11yTitleDirective, SharedModule, TypographyModule],
|
||||
})
|
||||
export class CalloutComponent implements AfterViewInit {
|
||||
export class CalloutComponent {
|
||||
readonly type = input<CalloutTypes>("info");
|
||||
readonly icon = input<string>();
|
||||
readonly title = input<string>();
|
||||
@@ -70,19 +60,8 @@ export class CalloutComponent implements AfterViewInit {
|
||||
|
||||
protected readonly titleId = `bit-callout-title-${nextId++}`;
|
||||
|
||||
readonly content = viewChild(TemplateRef);
|
||||
private contentRef!: ElementRef<HTMLElement>;
|
||||
readonly contentText = signal("");
|
||||
|
||||
constructor(private i18nService: I18nService) {}
|
||||
|
||||
ngAfterViewInit() {
|
||||
// prevent "Expression has changed after it was checked" errors
|
||||
afterNextRender(() => {
|
||||
this.contentText.set(this.contentRef?.nativeElement?.textContent?.trim() ?? "");
|
||||
});
|
||||
}
|
||||
|
||||
protected readonly calloutClass = computed(() => {
|
||||
switch (this.type()) {
|
||||
case "danger":
|
||||
|
||||
Reference in New Issue
Block a user