ShareButton.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { useState } from "react";
  2. import { Button, Dropdown, Space, Typography } from "antd";
  3. import { ShareAltOutlined, ExportOutlined } from "@ant-design/icons";
  4. import ExportModal from "./ExportModal";
  5. import type { ArticleType } from "../article/Article"
  6. const { Text } = Typography;
  7. interface IWidget {
  8. type?: ArticleType;
  9. articleId?: string;
  10. book?: string | null;
  11. para?: string | null;
  12. channelId?: string | null;
  13. anthologyId?: string | null;
  14. }
  15. const ShareButtonWidget = ({
  16. type,
  17. book,
  18. para,
  19. channelId,
  20. articleId,
  21. anthologyId,
  22. }: IWidget) => {
  23. const [exportOpen, setExportOpen] = useState(false);
  24. return (
  25. <>
  26. <Dropdown
  27. trigger={["click"]}
  28. menu={{
  29. items: [
  30. {
  31. label: (
  32. <Space>
  33. {"Export"}
  34. <Text type="secondary" style={{ fontSize: "80%" }}>
  35. {"PDF,Word,Html"}
  36. </Text>
  37. </Space>
  38. ),
  39. key: "export",
  40. icon: <ExportOutlined />,
  41. },
  42. ],
  43. onClick: ({ key }) => {
  44. switch (key) {
  45. case "export":
  46. setExportOpen(true);
  47. break;
  48. default:
  49. break;
  50. }
  51. },
  52. }}
  53. >
  54. <Button
  55. type="text"
  56. icon={
  57. <ShareAltOutlined style={{ color: "white", cursor: "pointer" }} />
  58. }
  59. />
  60. </Dropdown>
  61. <ExportModal
  62. type={type}
  63. articleId={articleId}
  64. book={book}
  65. para={para}
  66. channelId={channelId}
  67. anthologyId={anthologyId}
  68. open={exportOpen}
  69. onClose={() => setExportOpen(false)}
  70. />
  71. </>
  72. );
  73. };
  74. export default ShareButtonWidget;