UNPKG

@nu-art/thunder

Version:

Thunder - React & Typescript based frontend framework

83 lines 3.16 kB
"use strict"; /* * Thunder is a typescript & react frontend foundation that natively * runs on firebase function and is a part of the Thunderstorm larger project * * Copyright (C) 2018 Adam van der Kruk aka TacB0sS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var react_router_dom_1 = require("react-router-dom"); var __1 = require("../.."); var RoutePath = /** @class */ (function () { function RoutePath(key, route, component) { var _this = this; this.exact = false; this.visible = function () { return !!_this.label; }; this.key = key; this.path = route; this.component = component; } RoutePath.prototype.setLogMessage = function (logMessage) { // @ts-ignore this.logMessage = logMessage; return this; }; RoutePath.prototype.setLabel = function (label) { // @ts-ignore this.label = label; return this; }; RoutePath.prototype.setVisible = function (visible) { // @ts-ignore this.visible = visible; return this; }; RoutePath.prototype.setEnabled = function (enabled) { // @ts-ignore this.enabled = enabled; return this; }; RoutePath.prototype.setExact = function (exact) { // @ts-ignore this.exact = exact; return this; }; RoutePath.prototype.compose = function (params) { var paramsAsString = ""; if (params) paramsAsString = Object.keys(params).reduce(function (toRet, key) { var param = params[key]; if (typeof param === "function") param = param(); return toRet + "&" + key + "=" + param; }, paramsAsString); if (paramsAsString.length > 0) paramsAsString = "?" + paramsAsString.substring(1); return this.path + paramsAsString; }; return RoutePath; }()); exports.RoutePath = RoutePath; var activeStyle = { color: 'blue' }; exports.defaultNavLinkNode = function (route) { return React.createElement(react_router_dom_1.NavLink, { key: route.key, to: route.path, activeStyle: activeStyle }, route.label); }; exports.defaultRouteNode = function (route) { if (typeof route.component === "string") return React.createElement(__1.ReactEntryComponentInjector, { src: route.component }); return React.createElement(react_router_dom_1.Route, { exact: route.exact, key: route.key, path: route.path, component: route.component }); }; //# sourceMappingURL=route.js.map