SidebarContents.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. import styles from './SidebarContents.module.scss';
  10. export const SidebarContents = memo(() => {
  11. const { data: currentSidebarContents } = useCurrentSidebarContents();
  12. let Contents;
  13. switch (currentSidebarContents) {
  14. case SidebarContentsType.RECENT:
  15. Contents = RecentChanges;
  16. break;
  17. case SidebarContentsType.CUSTOM:
  18. Contents = CustomSidebar;
  19. break;
  20. case SidebarContentsType.TAG:
  21. Contents = Tag;
  22. break;
  23. case SidebarContentsType.BOOKMARKS:
  24. Contents = Bookmarks;
  25. break;
  26. default:
  27. Contents = PageTree;
  28. }
  29. return (
  30. <div className={`grw-sidebar-contents ${styles['grw-sidebar-contents']}`}>
  31. <Contents />
  32. </div>
  33. );
  34. });
  35. SidebarContents.displayName = 'SidebarContents';