"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _button = _interopRequireDefault(require("@alifd/next/lib/button"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
var PortalCard = function PortalCard(props) {
  var title = props.title,
    description = props.description,
    backgroundImage = props.backgroundImage,
    href = props.href,
    _props$style = props.style,
    propStyle = _props$style === void 0 ? {} : _props$style;
  var _React$useState = React.useState(propStyle),
    style = _React$useState[0],
    setStyle = _React$useState[1];
  var onClick = function onClick() {
    window.open(href);
  };
  var onMouseEnter = function onMouseEnter() {
    setStyle((0, _extends2["default"])({}, style, {
      background: "url(" + backgroundImage + ")"
    }));
  };
  var onMouseLeave = function onMouseLeave() {
    setStyle((0, _extends2["default"])({}, style, {
      background: null
    }));
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "portal-card",
    style: style,
    onMouseEnter: onMouseEnter,
    onMouseLeave: onMouseLeave
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
    className: "portal-title"
  }, title), /*#__PURE__*/React.createElement("div", {
    className: "portal-description"
  }, description)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_button["default"], {
    type: "normal",
    onClick: onClick
  }, "\u8BE6\u60C5")));
};
PortalCard.defaultProps = {
  title: 'Title',
  description: 'This is a description'
};
var _default = PortalCard;
exports["default"] = _default;