通用评论

AvatarHoverCard.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _col = require("antd/es/col");
  6. var _col2 = _interopRequireDefault(_col);
  7. var _row = require("antd/es/row");
  8. var _row2 = _interopRequireDefault(_row);
  9. 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; }; }();
  10. require("antd/es/col/style/css");
  11. require("antd/es/row/style/css");
  12. var _react = require("react");
  13. var _react2 = _interopRequireDefault(_react);
  14. var _reactIntlUniversal = require("react-intl-universal");
  15. var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
  16. require("./AvatarHoverCard.less");
  17. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  20. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  21. var AvatarHoverCard = function (_Component) {
  22. _inherits(AvatarHoverCard, _Component);
  23. function AvatarHoverCard(props) {
  24. _classCallCheck(this, AvatarHoverCard);
  25. var _this = _possibleConstructorReturn(this, (AvatarHoverCard.__proto__ || Object.getPrototypeOf(AvatarHoverCard)).call(this, props));
  26. _this.state = {
  27. showModal: false
  28. };
  29. return _this;
  30. }
  31. _createClass(AvatarHoverCard, [{
  32. key: "componentDidMount",
  33. value: function componentDidMount() {
  34. this.props.getUserInfo({
  35. id: this.props.user_id
  36. });
  37. }
  38. }, {
  39. key: "render",
  40. value: function render() {
  41. var _this2 = this;
  42. var _props = this.props,
  43. image = _props.image,
  44. user_id = _props.user_id,
  45. currentUser = _props.currentUser,
  46. userAvaHoverData = _props.userAvaHoverData;
  47. var followed = userAvaHoverData[user_id] && userAvaHoverData[user_id].isFollowed;
  48. return _react2.default.createElement(
  49. "div",
  50. { className: "AvatarHoverCard", onClick: function onClick(e) {
  51. return e.stopPropagation();
  52. } },
  53. _react2.default.createElement(
  54. "div",
  55. { onClick: this.props.userAvaClick },
  56. _react2.default.createElement(
  57. _row2.default,
  58. { type: "flex", className: "rowUser" },
  59. _react2.default.createElement("div", {
  60. className: "avatar",
  61. style: {
  62. backgroundImage: "url(" + image + ")"
  63. }
  64. }),
  65. _react2.default.createElement(
  66. "div",
  67. { className: "nickname" },
  68. userAvaHoverData[user_id] && userAvaHoverData[user_id].nickname
  69. )
  70. )
  71. ),
  72. _react2.default.createElement("div", { className: "divider" }),
  73. _react2.default.createElement(
  74. _row2.default,
  75. { type: "flex", className: "rowNum" },
  76. _react2.default.createElement(
  77. _col2.default,
  78. { className: "colFans" },
  79. _react2.default.createElement(
  80. "div",
  81. { className: "count" },
  82. userAvaHoverData[user_id] && userAvaHoverData[user_id].fans
  83. ),
  84. _react2.default.createElement(
  85. "div",
  86. { className: "text" },
  87. _reactIntlUniversal2.default.get("bilingually.fan", {
  88. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].fans > 1 ? "s" : ""
  89. })
  90. )
  91. ),
  92. _react2.default.createElement(_col2.default, { className: "hdivider" }),
  93. _react2.default.createElement(
  94. _col2.default,
  95. { className: "colFollow" },
  96. _react2.default.createElement(
  97. "div",
  98. { className: "count" },
  99. userAvaHoverData[user_id] && userAvaHoverData[user_id].followers
  100. ),
  101. _react2.default.createElement(
  102. "div",
  103. { className: "text" },
  104. _reactIntlUniversal2.default.get("bilingually.follow", {
  105. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].followers > 1 ? "s" : ""
  106. })
  107. )
  108. )
  109. ),
  110. currentUser.user_id !== user_id && _react2.default.createElement(
  111. _row2.default,
  112. { type: "flex", className: "rowBtn" },
  113. followed ? _react2.default.createElement(
  114. "div",
  115. {
  116. className: "unFollowBtn",
  117. onClick: function onClick(e) {
  118. e.stopPropagation();
  119. _this2.props.unFocus({
  120. id: user_id
  121. }).then(function () {
  122. _this2.props.getUserInfo({
  123. id: user_id
  124. });
  125. });
  126. }
  127. },
  128. _reactIntlUniversal2.default.get("bilingually.cancel_follow")
  129. ) : _react2.default.createElement(
  130. "div",
  131. {
  132. className: "followBtn",
  133. onClick: function onClick(e) {
  134. e.stopPropagation();
  135. _this2.props.focus({ id: user_id }).then(function () {
  136. _this2.props.getUserInfo({
  137. id: user_id
  138. });
  139. });
  140. }
  141. },
  142. _reactIntlUniversal2.default.get("bilingually.follow", { ext: "" })
  143. )
  144. )
  145. );
  146. }
  147. }]);
  148. return AvatarHoverCard;
  149. }(_react.Component);
  150. exports.default = AvatarHoverCard;
  151. //# sourceMappingURL=AvatarHoverCard.js.map