improved settings layout and UX, added bake button, fixed icons, added icon colours, improved BoolBox appearance, added snowflake icon, removed unused BeatLikeLoopSettings, added disabled buttons
This commit is contained in:
@@ -4,7 +4,9 @@ import IconView, {IconName} from "@/ui/Widgets/Icon/IconView";
|
||||
|
||||
export type ActionButtonUINodeOptions = UINodeOptions & {
|
||||
type?: "primary" | "secondary",
|
||||
onClick?: (isChecked: boolean) => void,
|
||||
onClick?: (event: MouseEvent) => void,
|
||||
alt?: string,
|
||||
disabled?: boolean,
|
||||
} & ({
|
||||
icon: IconName,
|
||||
label?: never,
|
||||
@@ -17,8 +19,10 @@ export default class ActionButtonView extends UINode {
|
||||
private label: string | null = null;
|
||||
private icon: IconName | null = null;
|
||||
private buttonElement!: HTMLButtonElement;
|
||||
private onClick: (isChecked: boolean) => void;
|
||||
private onClick: (event: MouseEvent) => void;
|
||||
private type: "primary" | "secondary";
|
||||
private alt: string | null;
|
||||
private disabled: boolean;
|
||||
|
||||
constructor(options: ActionButtonUINodeOptions) {
|
||||
super(options);
|
||||
@@ -27,22 +31,41 @@ export default class ActionButtonView extends UINode {
|
||||
} else if (typeof options.label !== "undefined") {
|
||||
this.label = options.label;
|
||||
}
|
||||
this.disabled = options.disabled ?? false;
|
||||
this.alt = options.alt ?? null;
|
||||
this.type = options.type ?? "primary";
|
||||
this.onClick = options.onClick ?? (() => { /* dummy */ });
|
||||
}
|
||||
|
||||
setDisabled(isDisabled: boolean): void {
|
||||
this.disabled = isDisabled;
|
||||
this.buttonElement.disabled = this.disabled;
|
||||
if (isDisabled) {
|
||||
this.buttonElement.classList.add("disabled");
|
||||
} else {
|
||||
this.buttonElement.classList.remove("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
protected build(): HTMLButtonElement {
|
||||
this.buttonElement = UINode.make("button", {
|
||||
classes: ["action-button", `action-button-${this.type}`],
|
||||
onclick: this.onClick,
|
||||
onclick: (event: MouseEvent) => this.disabled || this.onClick(event),
|
||||
subs: [
|
||||
this.icon !== null ? new IconView({
|
||||
iconName: this.icon
|
||||
iconName: this.icon,
|
||||
color: "var(--color-p-light)",
|
||||
}).render() : UINode.make("span", {
|
||||
innerText: this.label ?? ""
|
||||
}),
|
||||
],
|
||||
});
|
||||
if (this.alt) {
|
||||
this.buttonElement.title = this.alt;
|
||||
}
|
||||
if (this.disabled) {
|
||||
this.buttonElement.classList.add("disabled");
|
||||
}
|
||||
return this.buttonElement;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user