radh-ui
Version:
Stencil Component Starter
40 lines (39 loc) • 1.72 kB
JavaScript
import { r as registerInstance, c as createEvent, h } from './index-a9700b09.js';
var radhGithubSearchUserWidgetCss = "radh-github-search-user{margin:20px}";
var RadhGithubSearchUserWidget = /** @class */ (function () {
function RadhGithubSearchUserWidget(hostRef) {
registerInstance(this, hostRef);
this.userSearched = createEvent(this, "userSearched", 7);
}
RadhGithubSearchUserWidget.prototype.handleClick = function () {
var _this = this;
var username = this.value;
fetch("https://api.github.com/users/" + username)
.then(function (resp) { return resp.json(); })
.then(function (user) {
_this.user = JSON.stringify(user);
_this.userSearched.emit(user);
});
};
RadhGithubSearchUserWidget.prototype.handleChange = function (event) {
this.value = event.target.value;
};
RadhGithubSearchUserWidget.prototype.onchanged = function (ev) {
this.value = ev.detail;
};
RadhGithubSearchUserWidget.prototype.render = function () {
var _this = this;
var user = (function () {
if (_this.user) {
return (h("radh-user", { user: _this.user }));
}
else {
return (h("p", null, "No data"));
}
})();
return (h("div", null, h("radh-input-text", { label: "Username:", name: "username" }), h("radh-button", { onClick: function () { return _this.handleClick(); } }, "Search"), user));
};
return RadhGithubSearchUserWidget;
}());
RadhGithubSearchUserWidget.style = radhGithubSearchUserWidgetCss;
export { RadhGithubSearchUserWidget as radh_github_search_user_widget };