NavbarModule.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  8. var _reactMaterialize = require("react-materialize");
  9. var _SideNav = _interopRequireDefault(require("./SideNav"));
  10. var _AppBar = _interopRequireDefault(require("@material-ui/core/AppBar"));
  11. var _Toolbar = _interopRequireDefault(require("@material-ui/core/Toolbar"));
  12. var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
  13. var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
  14. var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
  15. var _Menu = _interopRequireDefault(require("@material-ui/icons/Menu"));
  16. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  19. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  20. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  21. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  22. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23. 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); } }
  24. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  25. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  26. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  27. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  28. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  29. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  30. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  31. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  32. var Module = _modularityFront.default.Module;
  33. var Link = _modularityFront.default.Modules.Link;
  34. var NavbarModule =
  35. /*#__PURE__*/
  36. function (_Modularity$Module) {
  37. _inherits(NavbarModule, _Modularity$Module);
  38. function NavbarModule(props) {
  39. var _this;
  40. _classCallCheck(this, NavbarModule);
  41. _this = _possibleConstructorReturn(this, _getPrototypeOf(NavbarModule).call(this, props));
  42. _this.state = {};
  43. return _this;
  44. }
  45. _createClass(NavbarModule, [{
  46. key: "render",
  47. value: function render() {
  48. var _this2 = this;
  49. var Img = _react.default.createElement("img", {
  50. src: this.logo.value,
  51. style: {
  52. height: 50
  53. }
  54. }); // return <Navbar className={this.class.value} brand={Img}
  55. // alignLinks={this.position.value}>
  56. // {this.props.children}
  57. // {(this.headers.value || []).map((item,index) =>
  58. // <Link link={this.links.value[index]} key={index}>{item}</Link>
  59. // )}
  60. // </Navbar>
  61. // ;
  62. var navItems = _toConsumableArray((this.headers.value || []).map(function (item, index) {
  63. return {
  64. content: item,
  65. link: _this2.links.value[index]
  66. };
  67. }));
  68. return _react.default.createElement("div", {
  69. style: {
  70. flexGrow: 1
  71. }
  72. }, _react.default.createElement(_AppBar.default, {
  73. position: "static",
  74. className: "Navbar " + this.class.value
  75. }, _react.default.createElement(_Toolbar.default, null, _react.default.createElement("div", {
  76. className: 'hide-on-large-only'
  77. }, _react.default.createElement(_SideNav.default, {
  78. trigger: _react.default.createElement(_IconButton.default, {
  79. color: "inherit",
  80. "aria-label": "Menu",
  81. style: {
  82. marginLeft: -12,
  83. marginRight: 20
  84. }
  85. }, _react.default.createElement(_Menu.default, null)),
  86. SideNavItems: navItems
  87. })), _react.default.createElement(Link, {
  88. link: "home"
  89. }, Img), _react.default.createElement(_Typography.default, {
  90. variant: "h6",
  91. color: "inherit",
  92. style: {
  93. flexGrow: 1
  94. }
  95. }, this.brand.value), _react.default.createElement("span", {
  96. style: {
  97. padding: "0 10px",
  98. display: 'none'
  99. },
  100. className: 'nav-text show-on-large'
  101. }, (this.headers.value || []).map(function (item, index) {
  102. return _react.default.createElement(Link, {
  103. link: _this2.links.value[index],
  104. key: index
  105. }, _react.default.createElement(_Button.default, {
  106. key: index
  107. }, item));
  108. })), this.props.children.map(function (item, index) {
  109. return _react.default.createElement("span", {
  110. key: index,
  111. className: "nav-text"
  112. }, item);
  113. }), _get(_getPrototypeOf(NavbarModule.prototype), "render", this).call(this, false))));
  114. }
  115. }]);
  116. return NavbarModule;
  117. }(_modularityFront.default.Module);
  118. NavbarModule.EditPosition = "top-right";
  119. NavbarModule.Inputs = {
  120. logo: {
  121. type: Module.Types.Text,
  122. defaultValue: 'favicon.ico'
  123. },
  124. brand: {
  125. type: Module.Types.Text,
  126. defaultValue: 'Bootstrap'
  127. },
  128. headers: {
  129. type: Module.Types.Array,
  130. defaultValue: ['Home', 'Test', 'Contact'],
  131. arrType: Module.Types.Text
  132. },
  133. links: {
  134. type: Module.Types.Array,
  135. defaultValue: ['home', 'test', 'contact'],
  136. arrType: Module.Types.Text
  137. },
  138. class: {
  139. type: Module.Types.Text,
  140. defaultValue: "blue-grey lighten-4"
  141. },
  142. position: {
  143. type: Module.Types.Text,
  144. defaultValue: "right"
  145. }
  146. };
  147. NavbarModule.Category = "sxoinas";
  148. var _default = NavbarModule;
  149. exports.default = _default;