@5calls/react-components
Version:
React component library for 5 Calls webapp
66 lines (65 loc) • 2.92 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var react_router_dom_1 = require("react-router-dom");
var LoginUi = /** @class */ (function (_super) {
__extends(LoginUi, _super);
function LoginUi(props) {
var _this = _super.call(this, props) || this;
_this.toggleMenu = function () {
_this.setState({ userMenuHidden: !_this.state.userMenuHidden });
};
_this.loginClick = function () {
if (_this.props.profile) {
_this.toggleMenu();
}
else {
_this.props.login();
}
};
_this.logout = function () {
_this.props.logout();
_this.toggleMenu();
};
_this.state = {
userMenuHidden: true,
};
return _this;
}
LoginUi.prototype.render = function () {
return (React.createElement("div", { className: "userHeader" },
React.createElement("a", { onClick: this.loginClick },
React.createElement("img", { className: "stars", src: this.props.profile ? this.props.profile.picture : '/img/5calls-stars.png', alt: "Make your voice heard" })),
React.createElement("p", null,
React.createElement("a", { onClick: this.loginClick }, this.props.profile ? this.props.profile.name : 'Login')),
!this.state.userMenuHidden &&
React.createElement("div", { className: "userHeader__menu" },
React.createElement("ul", null,
React.createElement("li", null,
React.createElement(react_router_dom_1.Link, { to: "/impact" }, "My Impact")),
React.createElement("li", { className: "line" }),
React.createElement("li", null,
React.createElement("a", { href: "#", onClick: this.logout },
React.createElement("strong", null, "Log out")))))));
};
;
return LoginUi;
}(React.Component));
exports.LoginUi = LoginUi;