Card.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. require("./Card.css");
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. 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); }
  12. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13. 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); } }
  14. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18. 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); }
  19. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  20. var Module = _modularityFront.default.Module;
  21. var CardModule =
  22. /*#__PURE__*/
  23. function (_Modularity$Module) {
  24. _inherits(CardModule, _Modularity$Module);
  25. function CardModule(props) {
  26. _classCallCheck(this, CardModule);
  27. return _possibleConstructorReturn(this, _getPrototypeOf(CardModule).call(this, props));
  28. }
  29. _createClass(CardModule, [{
  30. key: "addProd",
  31. value: function addProd(e) {
  32. e.preventDefault();
  33. var prod = {
  34. id: this.props.id,
  35. name: this.CardTitle.value,
  36. price: this.Price.value,
  37. image: this.CardImage.value,
  38. quantity: 1
  39. };
  40. this.product.set(prod);
  41. e.stopPropagation();
  42. }
  43. }, {
  44. key: "render",
  45. value: function render() {
  46. var _this = this;
  47. var CardButton = this.CardButton.value;
  48. return _react.default.createElement("div", {
  49. className: "custom_card " + this.props.className
  50. }, _react.default.createElement(_reactMaterialize.Card, {
  51. className: "hoverable",
  52. header: _react.default.createElement(_reactMaterialize.CardTitle, {
  53. reveal: true,
  54. className: "card_image cursor",
  55. onClick: function onClick() {
  56. return _this.props.onClick && _this.props.onClick();
  57. },
  58. image: this.CardImage.value,
  59. waves: "light"
  60. }),
  61. title: this.CardTitle.value,
  62. reveal: this.CardBody.value,
  63. actions: [CardButton ? _react.default.createElement("div", {
  64. key: this.getId(),
  65. className: "bottom_card"
  66. }, _react.default.createElement("small", {
  67. className: "pricenovat"
  68. }, "\u03C7\u03C9\u03C1\u03AF\u03C2 \u03A6\u03A0\u0391 ", (this.Price.value * 0.76).toFixed(2), " \u20AC"), _react.default.createElement("div", {
  69. className: "price"
  70. }, _react.default.createElement("div", null, this.Price.value, " \u20AC")), _react.default.createElement("div", null, _react.default.createElement(_reactMaterialize.Button, {
  71. onClick: function onClick(e) {
  72. return _this.addProd(e);
  73. },
  74. floating: true,
  75. small: true,
  76. className: "red",
  77. waves: "light",
  78. icon: "add"
  79. }))) : _react.default.createElement("label", null, "Price here")]
  80. }));
  81. }
  82. }]);
  83. return CardModule;
  84. }(_modularityFront.default.Module);
  85. CardModule.Inputs = {
  86. CardTitle: {
  87. type: Module.Types.Text
  88. },
  89. CardBody: {
  90. type: Module.Types.Text,
  91. defaultValue: "I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively."
  92. },
  93. CardImage: {
  94. type: Module.Types.Text
  95. },
  96. Price: {
  97. type: Module.Types.Real,
  98. defaultValue: null
  99. },
  100. CardButton: {
  101. //should be boolean if we have just add
  102. type: Module.Types.Text,
  103. defaultValue: true
  104. }
  105. };
  106. CardModule.Outputs = {
  107. product: {}
  108. };
  109. CardModule.Category = "sxoinas";
  110. var _default = CardModule;
  111. exports.default = _default;