UNPKG

sws-frontend

Version:

sws frontend project

82 lines 4.66 kB
"use strict"; 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 __assign = (this && this.__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; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var react_scroll_1 = require("react-scroll"); require("./sectionsnavigator.scss"); var SectionsNavigator = (function (_super) { __extends(SectionsNavigator, _super); function SectionsNavigator(props) { var _this = _super.call(this, props) || this; _this.state = { navigating: false }; return _this; } SectionsNavigator.prototype.render = function () { var _this = this; var _a = this.props, children = _a.children, containerId = _a.containerId, offset = _a.offset; var navigating = this.state.navigating; var properties = React.Children.toArray(children).map(function (c) { return c.props; }); var renderChildrens = function (child, p) { var properties = child.map(function (c) { return c.props; }); var containerId = p.containerId, offset = p.offset; return (React.createElement("ul", null, properties.map(function (s) { if (s && s.title) { var linkProp = { onSetActive: function () { return _this.setState({ navigating: true }); }, activeClass: "active", to: (s.title.replace(/ /g, '')) + (s.uid ? '-' + s.uid : ''), spy: true, smooth: true, offset: offset && offset, isDynamic: true, duration: 500 }; if (containerId) { linkProp['containerId'] = containerId; } var children_1 = React.Children.toArray(s.children).filter(function (c) { return c.props && c.props.role && c.props.role == 'section'; }); return (React.createElement("li", { key: s.uid ? s.uid : s.title, className: s.className }, React.createElement(react_scroll_1.Link, __assign({}, linkProp), s.title), false && children_1 && children_1.length > 0 && renderChildrens(children_1, p))); } }))); }; return (React.createElement("div", { className: "sections-navigator" }, React.createElement("div", { className: "sections-nav " + (!navigating && "unactive") }, renderChildrens(React.Children.toArray(children), this.props)), React.createElement("div", { className: "sections" }, children))); }; return SectionsNavigator; }(React.Component)); exports.SectionsNavigator = SectionsNavigator; exports.Section = function (p) { var title = p.title, description = p.description, children = p.children, sectionDescriptionInline = p.sectionDescriptionInline, className = p.className, uid = p.uid, disabled = p.disabled; return (React.createElement(react_scroll_1.Element, { name: title.replace(/ /g, '') + (uid ? '-' + uid : ''), id: title.replace(/ /g, '') + (uid ? '-' + uid : ''), className: "element" }, React.createElement("div", { className: (className ? className : '') + " " + (disabled ? 'disabled' : '') + " section" }, React.createElement("div", { className: "section-wrapper" }, React.createElement("div", { className: "section-title" }, React.createElement("h3", null, title)), description && sectionDescriptionInline && React.createElement("div", { className: "section-description" }, description), React.createElement("div", { className: "section-content" }, children)), description && !sectionDescriptionInline && React.createElement("div", { className: "section-description" }, description)))); }; //# sourceMappingURL=sectionsnavigator.js.map