UNPKG

optimizely-oui

Version:

Optimizely's Component Library.

49 lines (38 loc) 2.53 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from "react"; import PropTypes from "prop-types"; import classNames from "classnames"; var NavList = function NavList(_ref) { var children = _ref.children, className = _ref.className, label = _ref.label, popover = _ref.popover, rightLabel = _ref.rightLabel, testSection = _ref.testSection, props = _objectWithoutProperties(_ref, ["children", "className", "label", "popover", "rightLabel", "testSection"]); return React.createElement("nav", _extends({ className: classNames("sidenav__section", className), "data-test-section": testSection }, props), (label || rightLabel) && React.createElement("div", { className: "sidenav__section__title muted" }, React.createElement("h5", null, label), rightLabel && React.createElement("h6", null, rightLabel), popover), React.createElement("ul", { className: "nav-list" }, children)); }; NavList.propTypes = { /** Content to render within the list */ children: PropTypes.node, /** CSS class names. */ className: PropTypes.string, /** Label to use for this section */ label: PropTypes.string, /** Popover to display next to the label */ popover: PropTypes.bool, /** Optional text to display to the right of the label */ rightLabel: PropTypes.bool, /** Value used for testing via data-test-section attribute */ testSection: PropTypes.bool }; export default NavList;