@anjuna/docs
Version:
Anjuna Documentation Web Components
66 lines (65 loc) • 1.89 kB
JavaScript
export class Button {
constructor() {
this.context = 'primary';
this.size = 'default';
this.type = 'button';
}
btnClasses() {
return ['ad-button', `ad-button-${this.context}`, `ad-button-${this.size}`].join(' ');
}
onBlur() {
this.adBlur.emit();
}
onFocus() {
this.adFocus.emit();
}
render() {
if (this.href) {
return (h("a", { href: this.href, class: this.btnClasses(), onFocus: () => this.onFocus(), onBlur: () => this.onBlur() },
h("slot", null)));
}
else {
return (h("button", { type: this.type, class: this.btnClasses(), onFocus: () => this.onFocus(), onBlur: () => this.onBlur() },
h("slot", null)));
}
}
static get is() { return "ad-button"; }
static get properties() { return {
"context": {
"type": String,
"attr": "context"
},
"disabled": {
"type": Boolean,
"attr": "disabled",
"reflectToAttr": true
},
"href": {
"type": String,
"attr": "href"
},
"size": {
"type": String,
"attr": "size",
"reflectToAttr": true
},
"type": {
"type": String,
"attr": "type"
}
}; }
static get events() { return [{
"name": "adBlur",
"method": "adBlur",
"bubbles": true,
"cancelable": true,
"composed": true
}, {
"name": "adFocus",
"method": "adFocus",
"bubbles": true,
"cancelable": true,
"composed": true
}]; }
static get style() { return "/**style-placeholder:ad-button:**/"; }
}