UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

49 lines 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const react_router_1 = require("react-router"); const react_router_dom_1 = require("react-router-dom"); const lodash_1 = require("lodash"); const cosmoui_1 = require("cosmoui"); const cosmo_ui_auth_1 = require("@lml/cosmo-ui-auth"); const react_redux_1 = require("react-redux"); const styles = require('./sidebar.scss'); class SidebarComponent extends cosmoui_1.StylableComponent { constructor() { super(...arguments); this.linkGroupStyles = { fontWeight: 'bold', marginLeft: this.margin(300), marginTop: this.margin(300), marginBottom: this.margin(300), minHeight: 'maxContent', }; this.linkStyles = { minHeight: 'maxContent', marginLeft: this.margin(), marginBottom: this.margin(300), }; this.renderLink = (link, styles) => { const { url } = this.props.match; return (React.createElement(cosmoui_1.Column, { key: link.path }, React.createElement(cosmoui_1.Row, { style: styles }, React.createElement(cosmoui_1.Icon, { primary: this.isActive(link.path), icon: link.icon, size: 20 }), React.createElement(react_router_dom_1.Link, { id: link.id, to: `${url}/${link.path}`, style: { paddingLeft: this.padding(200) }, className: styles.listitem }, React.createElement(cosmoui_1.Text, { size: 'sm', primary: this.isActive(link.path), marginless: true }, link.label))), link.sublinks.map(l => ((!l.requireSuperUser || cosmo_ui_auth_1.isSuperuser) && this.renderLink(l, this.linkStyles))))); }; this.isActive = (path) => lodash_1.includes(this.props.location.pathname, path); } render() { const { links, isSuperuser } = this.props; return (React.createElement(cosmoui_1.Column, { fullHeight: true, className: styles.sidebar }, React.createElement(cosmoui_1.Paper, { style: { height: '100%', backgroundColor: 'white' } }, (links || []).map(l => ((!l.requireSuperUser || isSuperuser) && this.renderLink(l, this.linkGroupStyles)))))); } } const mapStateToProps = (state, ownProps) => ({ isSuperuser: cosmo_ui_auth_1.isSuperuser(state), }); const mapActionsToProps = {}; exports.Sidebar = react_router_1.withRouter(react_redux_1.connect(mapStateToProps, mapActionsToProps)(SidebarComponent)); //# sourceMappingURL=sidebar.js.map