DictGroupTitle.tsx 943 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Affix, Breadcrumb } from "antd";
  2. import { useState } from "react";
  3. interface IWidget {
  4. title: React.ReactNode;
  5. path: string[];
  6. }
  7. const DictGroupTitleWidget = ({ title, path }: IWidget) => {
  8. const [fixed, setFixed] = useState<boolean>();
  9. return (
  10. <Affix
  11. offsetTop={0}
  12. target={() =>
  13. document.getElementsByClassName("dict_component")[0] as HTMLElement
  14. }
  15. onChange={(affixed) => setFixed(affixed)}
  16. >
  17. {fixed ? (
  18. <Breadcrumb
  19. style={{
  20. backgroundColor: "white",
  21. padding: 4,
  22. borderBottom: "1px solid gray",
  23. }}
  24. >
  25. <Breadcrumb.Item key={"top"}>Top</Breadcrumb.Item>
  26. {path.map((item, index) => {
  27. return <Breadcrumb.Item key={index}>{item}</Breadcrumb.Item>;
  28. })}
  29. </Breadcrumb>
  30. ) : (
  31. title
  32. )}
  33. </Affix>
  34. );
  35. };
  36. export default DictGroupTitleWidget;