通用评论 vedio

Emoji.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from "react";
  2. import { Carousel } from "antd";
  3. import emoji, { prefixUrl } from "../../emoji";
  4. import "./Emoji.css";
  5. // 每页 20 5*4
  6. // 共 20 * 3 = 60 (实际是 54)
  7. // class Emoji
  8. class Emoji extends React.Component {
  9. next() {
  10. if (this.carousel) {
  11. this.carousel.next();
  12. }
  13. }
  14. prev() {
  15. if (this.carousel) {
  16. this.carousel.prev();
  17. }
  18. }
  19. render() {
  20. const { onClick } = this.props;
  21. const content = [];
  22. let curPage = [];
  23. for (let i = 0; i < 115; i++) {
  24. if (curPage.length < 30) {
  25. curPage.push(emoji[i]);
  26. } else {
  27. content.push(curPage);
  28. curPage = [];
  29. }
  30. }
  31. if (curPage.length > 0) {
  32. content.push(curPage);
  33. }
  34. return (
  35. <Carousel
  36. ref={node => {
  37. this.carousel = node;
  38. }}
  39. >
  40. {content.map((page, index) => (
  41. <div key={index} className="emoji">
  42. {page.map((item, index) => (
  43. <div className="item" key={item.value}>
  44. <span className="helper" />
  45. <img
  46. src={`${prefixUrl}${item.value}.${item.ext}`}
  47. alt={item.title}
  48. style={{ display: "inline-block" }}
  49. onClick={() => onClick(item.title)}
  50. />
  51. </div>
  52. ))}
  53. </div>
  54. ))}
  55. </Carousel>
  56. );
  57. }
  58. }
  59. export default Emoji;