通用评论

Emoji.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. require("antd/es/carousel/style/css");
  8. var _react = require("react");
  9. var _react2 = _interopRequireDefault(_react);
  10. var _emoji = require("../../emoji");
  11. var _emoji2 = _interopRequireDefault(_emoji);
  12. require("./Emoji.css");
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. // 每页 20 5*4
  15. // 共 20 * 3 = 60 (实际是 54)
  16. // class Emoji
  17. var Emoji = function Emoji(_ref) {
  18. var _onClick = _ref.onClick;
  19. var content = [];
  20. var curPage = [];
  21. for (var i = 0; i < 115; i++) {
  22. if (curPage.length < 20) {
  23. curPage.push(_emoji2.default[i]);
  24. } else {
  25. content.push(curPage);
  26. curPage = [];
  27. }
  28. }
  29. if (curPage.length > 0) {
  30. content.push(curPage);
  31. }
  32. return _react2.default.createElement(
  33. _carousel2.default,
  34. null,
  35. content.map(function (page, index) {
  36. return _react2.default.createElement(
  37. "div",
  38. { key: index, className: "emoji" },
  39. page.map(function (item, index) {
  40. return _react2.default.createElement(
  41. "div",
  42. { className: "item", key: item.value },
  43. _react2.default.createElement("span", { className: "helper" }),
  44. _react2.default.createElement("img", {
  45. src: "" + _emoji.prefixUrl + item.value + "." + item.ext,
  46. alt: item.title,
  47. style: { display: "inline-block" },
  48. onClick: function onClick() {
  49. return _onClick(item.title);
  50. }
  51. })
  52. );
  53. })
  54. );
  55. })
  56. );
  57. };
  58. exports.default = Emoji;
  59. //# sourceMappingURL=Emoji.js.map