通用评论

AvatarHoverCard.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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: function onClick() {
  56. return _this2.props.userAvaClick(user_id);
  57. } },
  58. _react2.default.createElement(
  59. _row2.default,
  60. { type: "flex", className: "rowUser" },
  61. _react2.default.createElement("div", {
  62. className: "avatar",
  63. style: {
  64. backgroundImage: "url(" + image + ")"
  65. }
  66. }),
  67. _react2.default.createElement(
  68. "div",
  69. { className: "nickname" },
  70. userAvaHoverData[user_id] && userAvaHoverData[user_id].nickname
  71. )
  72. )
  73. ),
  74. _react2.default.createElement("div", { className: "divider" }),
  75. _react2.default.createElement(
  76. _row2.default,
  77. { type: "flex", className: "rowNum" },
  78. _react2.default.createElement(
  79. _col2.default,
  80. { className: "colFans" },
  81. _react2.default.createElement(
  82. "div",
  83. { className: "count" },
  84. userAvaHoverData[user_id] && userAvaHoverData[user_id].fans
  85. ),
  86. _react2.default.createElement(
  87. "div",
  88. { className: "text" },
  89. _reactIntlUniversal2.default.get("bilingually.fan", {
  90. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].fans > 1 ? "s" : ""
  91. })
  92. )
  93. ),
  94. _react2.default.createElement(_col2.default, { className: "hdivider" }),
  95. _react2.default.createElement(
  96. _col2.default,
  97. { className: "colFollow" },
  98. _react2.default.createElement(
  99. "div",
  100. { className: "count" },
  101. userAvaHoverData[user_id] && userAvaHoverData[user_id].followers
  102. ),
  103. _react2.default.createElement(
  104. "div",
  105. { className: "text" },
  106. _reactIntlUniversal2.default.get("bilingually.follow", {
  107. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].followers > 1 ? "s" : ""
  108. })
  109. )
  110. )
  111. ),
  112. currentUser.user_id !== user_id && _react2.default.createElement(
  113. _row2.default,
  114. { type: "flex", className: "rowBtn" },
  115. followed ? _react2.default.createElement(
  116. "div",
  117. {
  118. className: "unFollowBtn",
  119. onClick: function onClick(e) {
  120. e.stopPropagation();
  121. _this2.props.unFocus({
  122. id: user_id
  123. }).then(function () {
  124. _this2.props.getUserInfo({
  125. id: user_id
  126. });
  127. });
  128. }
  129. },
  130. _reactIntlUniversal2.default.get("bilingually.cancel_follow")
  131. ) : _react2.default.createElement(
  132. "div",
  133. {
  134. className: "followBtn",
  135. onClick: function onClick(e) {
  136. e.stopPropagation();
  137. _this2.props.focus({ id: user_id }).then(function () {
  138. _this2.props.getUserInfo({
  139. id: user_id
  140. });
  141. });
  142. }
  143. },
  144. _reactIntlUniversal2.default.get("bilingually.follow", { ext: "" })
  145. )
  146. )
  147. );
  148. }
  149. }]);
  150. return AvatarHoverCard;
  151. }(_react.Component);
  152. exports.default = AvatarHoverCard;
  153. //# sourceMappingURL=AvatarHoverCard.js.map