PaliChapterCard.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { Row, Col } from "antd";
  2. import { Typography } from "antd";
  3. import { TinyLine } from "@ant-design/plots";
  4. import TocPath from "./TocPath";
  5. const { Title, 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. progressLine?: number[];
  14. }
  15. interface IWidget {
  16. data: IPaliChapterData;
  17. onTitleClick?: Function;
  18. }
  19. const Widget = ({ data, onTitleClick }: IWidget) => {
  20. const path = JSON.parse(data.Path);
  21. return (
  22. <>
  23. <Row>
  24. <Col span={3}></Col>
  25. <Col span={21}>
  26. <Row>
  27. <Col span={16}>
  28. <Row>
  29. <Col>
  30. <Title
  31. level={5}
  32. onClick={(e) => {
  33. if (typeof onTitleClick !== "undefined") {
  34. onTitleClick(e);
  35. }
  36. }}
  37. >
  38. <Link>{data.Title}</Link>
  39. </Title>
  40. </Col>
  41. </Row>
  42. <Row>
  43. <Col>{data.PaliTitle}</Col>
  44. </Row>
  45. <Row>
  46. <Col>
  47. <TocPath data={path} />
  48. </Col>
  49. </Row>
  50. </Col>
  51. <Col span={8}>
  52. {data.progressLine ? (
  53. <TinyLine
  54. height={60}
  55. width={200}
  56. autoFit={false}
  57. data={data.progressLine}
  58. smooth={true}
  59. />
  60. ) : (
  61. <></>
  62. )}
  63. </Col>
  64. </Row>
  65. <Row>
  66. <Col></Col>
  67. </Row>
  68. <Row>
  69. <Col span={16}></Col>
  70. </Row>
  71. </Col>
  72. </Row>
  73. </>
  74. );
  75. };
  76. export default Widget;