Add button to attach IK rig

This commit is contained in:
Danny McGee
2024-02-28 16:23:15 -05:00
parent f31cf35da1
commit 96f1f8ec39
5 changed files with 59 additions and 6 deletions
+12 -1
View File
@@ -1,5 +1,5 @@
import { on } from "@storyteller/framework";
import { LitElement, html, nothing, unsafeCSS } from "lit";
import { LitElement, type PropertyValues, html, nothing, unsafeCSS } from "lit";
import { customElement, property } from "lit/decorators.js";
import styles from "./button.element.scss?inline";
@@ -11,10 +11,21 @@ export class ButtonElement extends LitElement {
static override styles = unsafeCSS(styles);
@property() icon?: string;
@property({ type: Boolean }) disabled = false;
override role = "button";
override tabIndex = 0;
protected override willUpdate(changes: PropertyValues<this>): void {
if (changes.has("disabled")) {
this.ariaDisabled = this.disabled ? "true" : null;
this.tabIndex = this.disabled ? -1 : 0;
this.classList.toggle("disabled", this.disabled);
}
super.willUpdate(changes);
}
@on("keydown")
onKeyDown(event: KeyboardEvent) {
if (/^( |Enter)$/.test(event.key)) {