radh-ui
Version:
Stencil Component Starter
132 lines (131 loc) • 3.83 kB
JavaScript
import { Component, Event, h, Listen, Method, Prop, State, Watch } from "@stencil/core";
export class RadhUser {
click() {
this.selected.emit(this.innerUser);
}
parseUserProp(newValue) {
if (newValue)
this.innerUser = JSON.parse(newValue);
}
async setUser(user) {
this.innerUser = user;
}
componentWillLoad() {
this.parseUserProp(this.user);
}
render() {
const avatar = (() => {
if (this.avatar) {
return (h("blaze-avatar", { size: "super", alt: "placeholder", src: this.innerUser.avatar_url }));
}
else {
return h("img", { src: this.innerUser.avatar_url });
}
})();
if (this.innerUser) {
return (h("blaze-card", null,
h("blaze-card-body", null, avatar),
h("blaze-card-footer", null,
h("h4", { class: "login" }, this.innerUser.login),
h("p", { class: "name" }, this.innerUser.name))));
}
}
static get is() { return "radh-user"; }
static get originalStyleUrls() { return {
"$": ["radh-user.css"]
}; }
static get styleUrls() { return {
"$": ["radh-user.css"]
}; }
static get properties() { return {
"user": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": ""
},
"attribute": "user",
"reflect": true
},
"avatar": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": ""
},
"attribute": "avatar",
"reflect": false
}
}; }
static get states() { return {
"innerUser": {}
}; }
static get events() { return [{
"method": "selected",
"name": "selected",
"bubbles": true,
"cancelable": true,
"composed": true,
"docs": {
"tags": [],
"text": ""
},
"complexType": {
"original": "any",
"resolved": "any",
"references": {}
}
}]; }
static get methods() { return {
"setUser": {
"complexType": {
"signature": "(user: User) => Promise<void>",
"parameters": [{
"tags": [],
"text": ""
}],
"references": {
"Promise": {
"location": "global"
},
"User": {
"location": "import",
"path": "./model"
}
},
"return": "Promise<void>"
},
"docs": {
"text": "",
"tags": []
}
}
}; }
static get watchers() { return [{
"propName": "user",
"methodName": "parseUserProp"
}]; }
static get listeners() { return [{
"name": "click",
"method": "click",
"target": undefined,
"capture": false,
"passive": false
}]; }
}