PaliChapterCard.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { Row, Col, Space } from "antd";
  2. import { Typography } from "antd";
  3. import { TinyLine } from "@ant-design/plots";
  4. import TocPath from "./TocPath";
  5. const { Title, Text, Link } = Typography;
  6. export interface IPaliChapterData {
  7. Title: string;
  8. PaliTitle: string;
  9. level: number;
  10. Path: string;
  11. Book: number;
  12. Paragraph: number;
  13. chapterStrLen: number;
  14. paragraphCount: number;
  15. progressLine?: number[];
  16. }
  17. interface IWidget {
  18. data: IPaliChapterData;
  19. onTitleClick?: Function;
  20. }
  21. const PaliChapterCardWidget = ({ data, onTitleClick }: IWidget) => {
  22. const path = JSON.parse(data.Path);
  23. return (
  24. <>
  25. <Row>
  26. <Col span={3}></Col>
  27. <Col span={21}>
  28. <Row>
  29. <Col span={16}>
  30. <Row>
  31. <Col>
  32. <Title
  33. level={5}
  34. onClick={(e) => {
  35. if (typeof onTitleClick !== "undefined") {
  36. onTitleClick(e);
  37. }
  38. }}
  39. >
  40. <Link>{data.Title}</Link>
  41. </Title>
  42. </Col>
  43. </Row>
  44. <Row>
  45. <Col>{data.PaliTitle}</Col>
  46. </Row>
  47. <Row>
  48. <Col>
  49. <TocPath data={path} />
  50. </Col>
  51. </Row>
  52. </Col>
  53. <Col span={8}>
  54. {data.progressLine ? (
  55. <TinyLine
  56. height={60}
  57. width={200}
  58. autoFit={false}
  59. data={data.progressLine}
  60. smooth={true}
  61. />
  62. ) : (
  63. <></>
  64. )}
  65. </Col>
  66. </Row>
  67. <Row>
  68. <Col>
  69. <Text type="secondary">
  70. <Space>
  71. 字符数{data.chapterStrLen} | 段落数{data.paragraphCount}
  72. </Space>
  73. </Text>
  74. </Col>
  75. </Row>
  76. <Row>
  77. <Col span={16}></Col>
  78. </Row>
  79. </Col>
  80. </Row>
  81. </>
  82. );
  83. };
  84. export default PaliChapterCardWidget;