mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[CL-707] Migrate CL codebase to signals (#15340)
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
<span [ngClass]="{ 'tw-truncate tw-block': truncate }">
|
||||
<span [ngClass]="{ 'tw-truncate tw-block': truncate() }">
|
||||
<ng-content></ng-content>
|
||||
</span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, ElementRef, HostBinding, Input } from "@angular/core";
|
||||
import { Component, ElementRef, HostBinding, input } from "@angular/core";
|
||||
|
||||
import { FocusableElement } from "../shared/focusable-element";
|
||||
|
||||
@@ -89,33 +89,34 @@ export class BadgeComponent implements FocusableElement {
|
||||
"disabled:hover:!tw-text-muted",
|
||||
"disabled:tw-cursor-not-allowed",
|
||||
]
|
||||
.concat(styles[this.variant])
|
||||
.concat(this.hasHoverEffects ? [...hoverStyles[this.variant], "tw-min-w-10"] : [])
|
||||
.concat(this.truncate ? this.maxWidthClass : []);
|
||||
.concat(styles[this.variant()])
|
||||
.concat(this.hasHoverEffects ? [...hoverStyles[this.variant()], "tw-min-w-10"] : [])
|
||||
.concat(this.truncate() ? this.maxWidthClass() : []);
|
||||
}
|
||||
@HostBinding("attr.title") get titleAttr() {
|
||||
if (this.title !== undefined) {
|
||||
return this.title;
|
||||
const title = this.title();
|
||||
if (title !== undefined) {
|
||||
return title;
|
||||
}
|
||||
return this.truncate ? this?.el?.nativeElement?.textContent?.trim() : null;
|
||||
return this.truncate() ? this?.el?.nativeElement?.textContent?.trim() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional override for the automatic badge title when truncating.
|
||||
*/
|
||||
@Input() title?: string;
|
||||
readonly title = input<string>();
|
||||
|
||||
/**
|
||||
* Variant, sets the background color of the badge.
|
||||
*/
|
||||
@Input() variant: BadgeVariant = "primary";
|
||||
readonly variant = input<BadgeVariant>("primary");
|
||||
|
||||
/**
|
||||
* Truncate long text
|
||||
*/
|
||||
@Input() truncate = true;
|
||||
readonly truncate = input(true);
|
||||
|
||||
@Input() maxWidthClass: `tw-max-w-${string}` = "tw-max-w-40";
|
||||
readonly maxWidthClass = input<`tw-max-w-${string}`>("tw-max-w-40");
|
||||
|
||||
getFocusTarget() {
|
||||
return this.el.nativeElement;
|
||||
|
||||
Reference in New Issue
Block a user