SidebarContents.tsx 958 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React, { memo } from 'react';
  2. import { SidebarContentsType } from '~/interfaces/ui';
  3. import { useCurrentSidebarContents } from '~/stores/ui';
  4. import { Bookmarks } from './Bookmarks';
  5. import { CustomSidebar } from './Custom';
  6. import PageTree from './PageTree';
  7. import { RecentChanges } from './RecentChanges';
  8. import Tag from './Tag';
  9. export const SidebarContents = memo(() => {
  10. const { data: currentSidebarContents } = useCurrentSidebarContents();
  11. let Contents;
  12. switch (currentSidebarContents) {
  13. case SidebarContentsType.RECENT:
  14. Contents = RecentChanges;
  15. break;
  16. case SidebarContentsType.CUSTOM:
  17. Contents = CustomSidebar;
  18. break;
  19. case SidebarContentsType.TAG:
  20. Contents = Tag;
  21. break;
  22. case SidebarContentsType.BOOKMARKS:
  23. Contents = Bookmarks;
  24. break;
  25. default:
  26. Contents = PageTree;
  27. }
  28. return (
  29. <Contents />
  30. );
  31. });
  32. SidebarContents.displayName = 'SidebarContents';