UNPKG

react-kube

Version:

Kube CSS in React Components

97 lines (77 loc) 4.77 kB
"use strict"; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } var _react = require("react"); var _react2 = _interopRequireDefault(_react); var _Dropdown = require("./Dropdown"); var _Dropdown2 = _interopRequireDefault(_Dropdown); var SubNavigation = (function (_React$Component) { function SubNavigation(props) { _classCallCheck(this, SubNavigation); _get(Object.getPrototypeOf(SubNavigation.prototype), "constructor", this).call(this, props); this.state = { show: false }; } _inherits(SubNavigation, _React$Component); _createClass(SubNavigation, [{ key: "handleClick", value: function handleClick() { this.props.onItemClick ? this.props.onItemClick(this.props.index) : null; //eslint-disable-line this.props.onClick ? this.props.onClick() : null; //eslint-disable-line } }, { key: "render", value: function render() { var _this = this; // let iconStyles = this.props.icon ? "fa " + "fa-" + this.props.icon : ""; //icons disabled for now in sub navigation < todo var children = []; this.props.children.map(function (child) { children.push(_react2["default"].createElement( "div", { onClick: _this.handleClick.bind(_this), style: { color: _this.props.color, cursor: "pointer", width: "100%" }, target: child.props.target, url: child.props.url }, child.props.children )); }); return _react2["default"].createElement( _Dropdown2["default"], { active: this.props.active, background: this.props.background, data: children, top: this.props.top }, _react2["default"].createElement( "li", { className: this.props.className, id: this.props.id, index: this.props.index, onClick: this.handleClick.bind(this), style: this.props.style }, _react2["default"].createElement( "a", { style: { color: this.props.color, cursor: "pointer" } }, _react2["default"].createElement( "div", { style: { cursor: "pointer", display: "inline-block" } }, this.props.title ), _react2["default"].createElement("b", { className: "caret" }) ) ) ); } }]); return SubNavigation; })(_react2["default"].Component); SubNavigation.propTypes = { active: _react2["default"].PropTypes.bool, background: _react2["default"].PropTypes.string, children: _react2["default"].PropTypes.node, className: _react2["default"].PropTypes.string, color: _react2["default"].PropTypes.string, hover: _react2["default"].PropTypes.bool, icon: _react2["default"].PropTypes.string, id: _react2["default"].PropTypes.string.isRequired, index: _react2["default"].PropTypes.number, onItemClick: _react2["default"].PropTypes.func, style: _react2["default"].PropTypes.object, target: _react2["default"].PropTypes.string, title: _react2["default"].PropTypes.string, top: _react2["default"].PropTypes.number, url: _react2["default"].PropTypes.string }; SubNavigation.defaultProps = { icon: null }; module.exports = SubNavigation;