1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-20 02:03:50 +00:00

Tweak component library slightly (#715)

This commit is contained in:
Oscar Hinton
2022-03-11 21:00:24 +01:00
committed by GitHub
parent 3f20122e5b
commit 41b199ab83
7 changed files with 90 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import { Input, HostBinding, OnChanges, Directive } from "@angular/core";
import { Input, HostBinding, OnChanges, Directive, OnInit } from "@angular/core";
export type ButtonTypes = "primary" | "secondary" | "danger";
@@ -18,10 +18,10 @@ const buttonStyles: Record<ButtonTypes, string> = {
"!tw-text-muted",
"hover:tw-bg-secondary-500",
"hover:tw-border-secondary-500",
"hover:tw-text-contrast",
"hover:!tw-text-contrast",
"focus:tw-bg-secondary-500",
"focus:tw-border-secondary-500",
"focus:tw-text-contrast",
"focus:!tw-text-contrast",
].join(" "),
danger: [
"tw-bg-transparent",
@@ -29,18 +29,18 @@ const buttonStyles: Record<ButtonTypes, string> = {
"!tw-text-danger",
"hover:tw-bg-danger-500",
"hover:tw-border-danger-500",
"hover:tw-text-contrast",
"hover:!tw-text-contrast",
"focus:tw-bg-danger-500",
"focus:tw-border-danger-500",
"focus:tw-text-contrast",
"focus:!tw-text-contrast",
].join(" "),
};
@Directive({
selector: "button[bit-button], a[bit-button]",
})
export class ButtonComponent implements OnChanges {
@HostBinding("class") @Input("class") classList = "";
export class ButtonComponent implements OnInit, OnChanges {
@HostBinding("class") @Input() classList = "";
@Input()
buttonType: ButtonTypes = "secondary";
@@ -48,10 +48,14 @@ export class ButtonComponent implements OnChanges {
@Input()
block = false;
ngOnChanges() {
ngOnInit(): void {
this.classList = this.classes.join(" ");
}
ngOnChanges() {
this.ngOnInit();
}
get classes(): string[] {
return [
"tw-font-semibold",