Skip to content

Instantly share code, notes, and snippets.

@werpu
Created April 24, 2020 21:27
Show Gist options
  • Save werpu/6d800b786b229d7540b3e3a4c701bcaf to your computer and use it in GitHub Desktop.
Save werpu/6d800b786b229d7540b3e3a4c701bcaf to your computer and use it in GitHub Desktop.
class ShiftKey extends HTMLElement {
observedAttrs = ["l1_code",
"l1_d_value",
"l2_code",
"l2_d_value",
"l3_code",
"l3_d_value",
"l4_code",
"l4_d_value",
"the_id"];
constructor() {
super();
this.innerHTML =
`<button class="level1" id="${this.the_id}" data-key-code="${data.l1_code}">${this.l1_d_value}</button>
<button class="level2 hidden" id="${this.the_id + '_l2'}" data-key-code="${data.l2_code || data.l1_code}">${this.l2_d_value || this.l1_d_value}</button>
<button class="level3 hidden" id="${this.the_id + '_l3'}" data-key-code="${data.l3_code || data.l1_code}">${this.l3_d_value || this.l1_d_value}</button>
<button class="level4 hidden" id="${this.the_id + '_l4'}" data-key-code="${data.l4_code || data.l1_code}">${this.l4_d_value || this.l1_d_value}</button>`;
}
}
TagBuilder.withTagName("x-key")
.withClass(ShiftKey)
.register();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment