TopArticleCard.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Link } from "react-router";
  2. import { Card } from "antd";
  3. import {
  4. AppstoreOutlined,
  5. LikeOutlined,
  6. FieldTimeOutlined,
  7. } from "@ant-design/icons";
  8. import { Space } from "antd";
  9. interface IIconParamListData {
  10. label: React.ReactNode;
  11. key: string;
  12. icon: React.ReactNode;
  13. }
  14. interface IWidgetIconParamList {
  15. data: IIconParamListData[];
  16. }
  17. const IconParamList = (prop: IWidgetIconParamList) => {
  18. return (
  19. <>
  20. <Space>
  21. {prop.data.map((item, id) => {
  22. return (
  23. <Space key={id}>
  24. {item.icon} {item.label}
  25. </Space>
  26. );
  27. })}
  28. </Space>
  29. </>
  30. );
  31. };
  32. export interface ITopArticleCardData {
  33. title: string;
  34. link: string;
  35. like: number;
  36. hit: number;
  37. updatedAt: string;
  38. }
  39. interface IWidgetTopArticleCard {
  40. data: ITopArticleCardData;
  41. }
  42. const TopArticleCardWidget = (prop: IWidgetTopArticleCard) => {
  43. const items: IIconParamListData[] = [
  44. {
  45. label: "经藏",
  46. key: "sutta",
  47. icon: <AppstoreOutlined />,
  48. },
  49. {
  50. label: prop.data.like,
  51. key: "like",
  52. icon: <LikeOutlined />,
  53. },
  54. {
  55. label: prop.data.updatedAt,
  56. key: "updated",
  57. icon: <FieldTimeOutlined />,
  58. },
  59. ];
  60. return (
  61. <>
  62. <Card>
  63. <h4>
  64. <Link to={prop.data.link}>{prop.data.title}</Link>
  65. </h4>
  66. <div>
  67. <IconParamList data={items} />
  68. </div>
  69. </Card>
  70. </>
  71. );
  72. };
  73. export default TopArticleCardWidget;