@gpa-gemstone/react-interactive
Version:
Interactive UI Components for GPA products
112 lines (111 loc) • 5.15 kB
JavaScript
// ******************************************************************************************************
// SideBarContent.tsx - Gbtc
//
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
// file except in compliance with the License. You may obtain a copy of the License at:
//
// http://opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 02/13/2022 - C. Lackner
// Generated original version of source code.
//
// ******************************************************************************************************
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var Page_1 = __importDefault(require("../Page"));
var Section_1 = __importDefault(require("../Section"));
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
var SidebarNavStyle = {
position: 'fixed',
top: 0,
bottom: 0,
left: 0,
zIndex: 100,
padding: '48px 0 0',
boxShadow: 'inset -1px 0 0 rgba(0,0,0,.1)'
};
var SidebarBodyStyle = {
position: 'sticky',
height: 'calc( 100% - 35px)',
overflowY: 'auto',
overflowX: 'hidden'
};
var SideBarContent = function (props) {
var sideBarRef = React.useRef(null);
var width = (0, helper_functions_1.useGetContainerPosition)(sideBarRef).width;
var widthStyle = props.Collapsed ? 'auto' : 200;
React.useEffect(function () { return props.SetSideBarWidth(width); }, [width]);
return React.createElement(React.Fragment, null, props.HideSide ? null :
React.createElement("div", { className: "bg-light navbar-light navbar", style: __assign(__assign({}, SidebarNavStyle), { width: widthStyle }), ref: sideBarRef },
React.createElement("div", { style: SidebarBodyStyle },
React.createElement("ul", { className: "navbar-nav px-3" }, React.Children.map(props.children, function (e) {
if (!React.isValidElement(e))
return null;
if (e.type === Page_1.default)
return e;
return null;
})),
React.Children.map(props.children, function (e) {
if (!React.isValidElement(e))
return null;
if (e.type === Section_1.default)
return e;
return null;
})),
props.Version !== undefined && !props.Collapsed ?
React.createElement("div", { style: { width: '100%', textAlign: 'center', height: 35 } },
React.createElement("span", null,
"Version ",
props.Version),
React.createElement("br", null),
React.createElement("span", null)) : null));
};
exports.default = SideBarContent;
;