mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
[CL-707] Migrate CL codebase to signals (#15340)
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
ElementRef,
|
||||
HostBinding,
|
||||
inject,
|
||||
Input,
|
||||
input,
|
||||
model,
|
||||
Signal,
|
||||
} from "@angular/core";
|
||||
@@ -177,11 +177,11 @@ const sizes: Record<IconButtonSize, string[]> = {
|
||||
},
|
||||
})
|
||||
export class BitIconButtonComponent implements ButtonLikeAbstraction, FocusableElement {
|
||||
@Input("bitIconButton") icon: string;
|
||||
readonly icon = model<string>(undefined, { alias: "bitIconButton" });
|
||||
|
||||
@Input() buttonType: IconButtonType = "main";
|
||||
readonly buttonType = input<IconButtonType>("main");
|
||||
|
||||
@Input() size: IconButtonSize = "default";
|
||||
readonly size = model<IconButtonSize>("default");
|
||||
|
||||
@HostBinding("class") get classList() {
|
||||
return [
|
||||
@@ -193,13 +193,15 @@ export class BitIconButtonComponent implements ButtonLikeAbstraction, FocusableE
|
||||
"hover:tw-no-underline",
|
||||
"focus:tw-outline-none",
|
||||
]
|
||||
.concat(styles[this.buttonType])
|
||||
.concat(sizes[this.size])
|
||||
.concat(this.showDisabledStyles() || this.disabled() ? disabledStyles[this.buttonType] : []);
|
||||
.concat(styles[this.buttonType()])
|
||||
.concat(sizes[this.size()])
|
||||
.concat(
|
||||
this.showDisabledStyles() || this.disabled() ? disabledStyles[this.buttonType()] : [],
|
||||
);
|
||||
}
|
||||
|
||||
get iconClass() {
|
||||
return [this.icon, "!tw-m-0"];
|
||||
return [this.icon(), "!tw-m-0"];
|
||||
}
|
||||
|
||||
protected disabledAttr = computed(() => {
|
||||
@@ -219,7 +221,7 @@ export class BitIconButtonComponent implements ButtonLikeAbstraction, FocusableE
|
||||
return this.showLoadingStyle() || (this.disabledAttr() && this.loading() === false);
|
||||
});
|
||||
|
||||
loading = model(false);
|
||||
readonly loading = model(false);
|
||||
|
||||
/**
|
||||
* Determine whether it is appropriate to display a loading spinner. We only want to show
|
||||
@@ -237,7 +239,7 @@ export class BitIconButtonComponent implements ButtonLikeAbstraction, FocusableE
|
||||
toObservable(this.loading).pipe(debounce((isLoading) => interval(isLoading ? 75 : 0))),
|
||||
);
|
||||
|
||||
disabled = model<boolean>(false);
|
||||
readonly disabled = model<boolean>(false);
|
||||
|
||||
getFocusTarget() {
|
||||
return this.elementRef.nativeElement;
|
||||
|
||||
Reference in New Issue
Block a user