mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
[CL-707] Migrate CL codebase to signals (#15340)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
||||
import { NgClass } from "@angular/common";
|
||||
import {
|
||||
Input,
|
||||
HostBinding,
|
||||
Component,
|
||||
model,
|
||||
@@ -10,6 +8,7 @@ import {
|
||||
ElementRef,
|
||||
inject,
|
||||
Signal,
|
||||
booleanAttribute,
|
||||
} from "@angular/core";
|
||||
import { toObservable, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { debounce, interval } from "rxjs";
|
||||
@@ -79,7 +78,7 @@ export class ButtonComponent implements ButtonLikeAbstraction {
|
||||
"hover:tw-no-underline",
|
||||
"focus:tw-outline-none",
|
||||
]
|
||||
.concat(this.block ? ["tw-w-full", "tw-block"] : ["tw-inline-block"])
|
||||
.concat(this.block() ? ["tw-w-full", "tw-block"] : ["tw-inline-block"])
|
||||
.concat(
|
||||
this.showDisabledStyles() || this.disabled()
|
||||
? [
|
||||
@@ -95,7 +94,7 @@ export class ButtonComponent implements ButtonLikeAbstraction {
|
||||
]
|
||||
: [],
|
||||
)
|
||||
.concat(buttonStyles[this.buttonType ?? "secondary"])
|
||||
.concat(buttonStyles[this.buttonType() ?? "secondary"])
|
||||
.concat(buttonSizeStyles[this.size() || "default"]);
|
||||
}
|
||||
|
||||
@@ -116,22 +115,13 @@ export class ButtonComponent implements ButtonLikeAbstraction {
|
||||
return this.showLoadingStyle() || (this.disabledAttr() && this.loading() === false);
|
||||
});
|
||||
|
||||
@Input() buttonType: ButtonType = "secondary";
|
||||
readonly buttonType = input<ButtonType>("secondary");
|
||||
|
||||
size = input<ButtonSize>("default");
|
||||
readonly size = input<ButtonSize>("default");
|
||||
|
||||
private _block = false;
|
||||
readonly block = input(false, { transform: booleanAttribute });
|
||||
|
||||
@Input()
|
||||
get block(): boolean {
|
||||
return this._block;
|
||||
}
|
||||
|
||||
set block(value: boolean | "") {
|
||||
this._block = coerceBooleanProperty(value);
|
||||
}
|
||||
|
||||
loading = model<boolean>(false);
|
||||
readonly loading = model<boolean>(false);
|
||||
|
||||
/**
|
||||
* Determine whether it is appropriate to display a loading spinner. We only want to show
|
||||
@@ -149,7 +139,7 @@ export class ButtonComponent implements ButtonLikeAbstraction {
|
||||
toObservable(this.loading).pipe(debounce((isLoading) => interval(isLoading ? 75 : 0))),
|
||||
);
|
||||
|
||||
disabled = model<boolean>(false);
|
||||
readonly disabled = model<boolean>(false);
|
||||
private el = inject(ElementRef<HTMLButtonElement>);
|
||||
|
||||
constructor() {
|
||||
|
||||
Reference in New Issue
Block a user