通用评论

Emoji.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _carousel = require("antd/es/carousel");
  6. var _carousel2 = _interopRequireDefault(_carousel);
  7. 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; }; }();
  8. require("antd/es/carousel/style/css");
  9. var _react = require("react");
  10. var _react2 = _interopRequireDefault(_react);
  11. var _emoji = require("../../emoji");
  12. var _emoji2 = _interopRequireDefault(_emoji);
  13. require("./Emoji.css");
  14. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16. 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; }
  17. 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; }
  18. // 每页 20 5*4
  19. // 共 20 * 3 = 60 (实际是 54)
  20. // class Emoji
  21. var Emoji = function (_React$Component) {
  22. _inherits(Emoji, _React$Component);
  23. function Emoji() {
  24. _classCallCheck(this, Emoji);
  25. return _possibleConstructorReturn(this, (Emoji.__proto__ || Object.getPrototypeOf(Emoji)).apply(this, arguments));
  26. }
  27. _createClass(Emoji, [{
  28. key: "next",
  29. value: function next() {
  30. if (this.carousel) {
  31. this.carousel.next();
  32. }
  33. }
  34. }, {
  35. key: "prev",
  36. value: function prev() {
  37. if (this.carousel) {
  38. this.carousel.prev();
  39. }
  40. }
  41. }, {
  42. key: "render",
  43. value: function render() {
  44. var _this2 = this;
  45. var _onClick = this.props.onClick;
  46. var content = [];
  47. var curPage = [];
  48. for (var i = 0; i < 115; i++) {
  49. if (curPage.length < 30) {
  50. curPage.push(_emoji2.default[i]);
  51. } else {
  52. content.push(curPage);
  53. curPage = [];
  54. }
  55. }
  56. if (curPage.length > 0) {
  57. content.push(curPage);
  58. }
  59. return _react2.default.createElement(
  60. _carousel2.default,
  61. {
  62. ref: function ref(node) {
  63. _this2.carousel = node;
  64. }
  65. },
  66. content.map(function (page, index) {
  67. return _react2.default.createElement(
  68. "div",
  69. { key: index, className: "emoji" },
  70. page.map(function (item, index) {
  71. return _react2.default.createElement(
  72. "div",
  73. { className: "item", key: item.value },
  74. _react2.default.createElement("span", { className: "helper" }),
  75. _react2.default.createElement("img", {
  76. src: "" + _emoji.prefixUrl + item.value + "." + item.ext,
  77. alt: item.title,
  78. style: { display: "inline-block" },
  79. onClick: function onClick() {
  80. return _onClick(item.title);
  81. }
  82. })
  83. );
  84. })
  85. );
  86. })
  87. );
  88. }
  89. }]);
  90. return Emoji;
  91. }(_react2.default.Component);
  92. exports.default = Emoji;
  93. //# sourceMappingURL=Emoji.js.map