1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.symbol");
|
4 |
|
5 | require("core-js/modules/es.symbol.description");
|
6 |
|
7 | require("core-js/modules/es.symbol.iterator");
|
8 |
|
9 | require("core-js/modules/es.array.concat");
|
10 |
|
11 | require("core-js/modules/es.array.iterator");
|
12 |
|
13 | require("core-js/modules/es.object.create");
|
14 |
|
15 | require("core-js/modules/es.object.define-property");
|
16 |
|
17 | require("core-js/modules/es.object.get-prototype-of");
|
18 |
|
19 | require("core-js/modules/es.object.set-prototype-of");
|
20 |
|
21 | require("core-js/modules/es.object.to-string");
|
22 |
|
23 | require("core-js/modules/es.string.iterator");
|
24 |
|
25 | require("core-js/modules/web.dom-collections.iterator");
|
26 |
|
27 | Object.defineProperty(exports, "__esModule", {
|
28 | value: true
|
29 | });
|
30 | exports["default"] = void 0;
|
31 |
|
32 | var _global = require("global");
|
33 |
|
34 | var _react = _interopRequireWildcard(require("react"));
|
35 |
|
36 | var _clientLogger = require("@storybook/client-logger");
|
37 |
|
38 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
39 |
|
40 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
41 |
|
42 | function _typeof(obj) { "@babel/helpers - typeof"; 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); }
|
43 |
|
44 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
45 |
|
46 | 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); } }
|
47 |
|
48 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
49 |
|
50 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
51 |
|
52 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
53 |
|
54 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
55 |
|
56 | 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); }
|
57 |
|
58 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
59 |
|
60 | var Giphy =
|
61 |
|
62 | function (_Component) {
|
63 | _inherits(Giphy, _Component);
|
64 |
|
65 | function Giphy() {
|
66 | var _getPrototypeOf2;
|
67 |
|
68 | var _this;
|
69 |
|
70 | _classCallCheck(this, Giphy);
|
71 |
|
72 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
73 | args[_key] = arguments[_key];
|
74 | }
|
75 |
|
76 | _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Giphy)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
77 | _this.state = {
|
78 | src: null
|
79 | };
|
80 | return _this;
|
81 | }
|
82 |
|
83 | _createClass(Giphy, [{
|
84 | key: "componentDidMount",
|
85 | value: function componentDidMount() {
|
86 | var _this2 = this;
|
87 |
|
88 | var query = this.props.query;
|
89 |
|
90 |
|
91 |
|
92 | (0, _global.fetch)("http://api.giphy.com/v1/gifs/search?limit=1&api_key=dc6zaTOxFJmzC&q=".concat(query)).then(function (response) {
|
93 | return response.ok && response.json();
|
94 | }).then(function (data) {
|
95 | _this2.setState({
|
96 | src: data.data[0].images.original.url
|
97 | });
|
98 | })["catch"](function (e) {
|
99 | return _clientLogger.logger.error(e);
|
100 | });
|
101 | }
|
102 | }, {
|
103 | key: "render",
|
104 | value: function render() {
|
105 | var src = this.state.src;
|
106 |
|
107 | return src ? _react["default"].createElement("img", {
|
108 | src: src,
|
109 | alt: ""
|
110 | }) : null;
|
111 | }
|
112 | }]);
|
113 |
|
114 | return Giphy;
|
115 | }(_react.Component);
|
116 |
|
117 | exports["default"] = Giphy; |
\ | No newline at end of file |