-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy-button.js
More file actions
36 lines (26 loc) · 903 Bytes
/
my-button.js
File metadata and controls
36 lines (26 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// (c) 2018-present, The Awesome Engineering Company, https://awesomeneg.com
/* eslint no-console: off */
import {ZephComponents} from "./Zeph.js";
import {html,css,attribute,property,bind,onCreate,onEvent} from "./Zeph.js";
ZephComponents.define("my-button",()=>{
html("./my-button.html");
css("./my-button.css");
attribute("icon","");
attribute("icon-placement","left");
attribute("disabled",undefined);
property("clickCount",0);
bind("@icon","button > img","@src");
bind("@disabled","button");
onCreate((element)=>{
console.log("Element '"+element.getAttribute("name")+"' created!",element);
});
onEvent("click",(event,element)=>{
if (element.hasAttribute("disabled")) {
event.stopPropagation();
event.preventDefault();
return;
}
element.clickCount += 1;
console.log("Button '"+element.getAttribute("name")+"' clicked "+element.clickCount+" times.");
});
});