freshened up some ui, added styled buttons

This commit is contained in:
Daniel Ledda
2021-12-04 20:16:20 +01:00
parent 1579dd3b42
commit 866b3af879
9 changed files with 112 additions and 25 deletions

View File

@@ -0,0 +1,39 @@
import "./ActionButton.css";
import UINode, {UINodeOptions} from "../../UINode";
export type ActionButtonUINodeOptions = UINodeOptions & {
label: string,
type?: "primary" | "secondary",
onClick?: (isChecked: boolean) => void,
};
export default class ActionButtonView extends UINode {
private label: string | null;
private buttonElement!: HTMLButtonElement;
private onClick: (isChecked: boolean) => void;
private type: "primary" | "secondary";
constructor(options: ActionButtonUINodeOptions) {
super(options);
this.label = options.label ?? "";
this.type = options.type ?? "primary";
this.onClick = options.onClick ?? (() => { /* dummy */ });
}
setLabel(newLabel: string | null): void {
if (newLabel !== null) {
this.buttonElement.innerText = newLabel;
} else {
this.buttonElement.innerText = "";
}
}
rebuild(): HTMLButtonElement {
this.buttonElement = UINode.make("button", {
classes: ["action-button", `action-button-${this.type}`],
innerText: this.label ?? "",
onclick: this.onClick,
});
return this.buttonElement;
}
}