sd-sidebar.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { IconButton } from "@/app/components/button";
  2. import GithubIcon from "@/app/icons/github.svg";
  3. import SDIcon from "@/app/icons/sd.svg";
  4. import ReturnIcon from "@/app/icons/return.svg";
  5. import Locale from "@/app/locales";
  6. import { Path, REPO_URL } from "@/app/constant";
  7. import { useNavigate } from "react-router-dom";
  8. import dynamic from "next/dynamic";
  9. import {
  10. SideBarContainer,
  11. SideBarBody,
  12. SideBarHeader,
  13. SideBarTail,
  14. useDragSideBar,
  15. useHotKey,
  16. } from "@/app/components/sidebar";
  17. const SdPanel = dynamic(
  18. async () => (await import("@/app/components/sd")).SdPanel,
  19. {
  20. loading: () => null,
  21. },
  22. );
  23. export function SideBar(props: { className?: string }) {
  24. useHotKey();
  25. const { onDragStart, shouldNarrow } = useDragSideBar();
  26. const navigate = useNavigate();
  27. return (
  28. <SideBarContainer
  29. onDragStart={onDragStart}
  30. shouldNarrow={shouldNarrow}
  31. {...props}
  32. >
  33. <SideBarHeader
  34. title={
  35. <IconButton
  36. icon={<ReturnIcon />}
  37. bordered
  38. title={Locale.Sd.Actions.ReturnHome}
  39. onClick={() => navigate(Path.Home)}
  40. />
  41. }
  42. logo={<SDIcon width={38} height={38} />}
  43. ></SideBarHeader>
  44. <SideBarBody>
  45. <SdPanel />
  46. </SideBarBody>
  47. <SideBarTail
  48. primaryAction={
  49. <a href={REPO_URL} target="_blank" rel="noopener noreferrer">
  50. <IconButton icon={<GithubIcon />} shadow />
  51. </a>
  52. }
  53. />
  54. </SideBarContainer>
  55. );
  56. }