Browse Source

add simplebar-react for sidebar

reiji-h 1 year ago
parent
commit
c814e30a7d
1 changed files with 17 additions and 3 deletions
  1. 17 3
      apps/app/src/client/components/Sidebar/Sidebar.tsx

+ 17 - 3
apps/app/src/client/components/Sidebar/Sidebar.tsx

@@ -6,6 +6,7 @@ import {
 
 
 import withLoadingProps from 'next-dynamic-loading-props';
 import withLoadingProps from 'next-dynamic-loading-props';
 import dynamic from 'next/dynamic';
 import dynamic from 'next/dynamic';
+import SimpleBar from 'simplebar-react';
 import { useIsomorphicLayoutEffect } from 'usehooks-ts';
 import { useIsomorphicLayoutEffect } from 'usehooks-ts';
 
 
 import { SidebarMode } from '~/interfaces/ui';
 import { SidebarMode } from '~/interfaces/ui';
@@ -28,6 +29,7 @@ import { SidebarHead } from './SidebarHead';
 import { SidebarNav, type SidebarNavProps } from './SidebarNav';
 import { SidebarNav, type SidebarNavProps } from './SidebarNav';
 
 
 import styles from './Sidebar.module.scss';
 import styles from './Sidebar.module.scss';
+import 'simplebar-react/dist/simplebar.min.css';
 
 
 
 
 const SidebarContents = dynamic(() => import('./SidebarContents').then(mod => mod.SidebarContents), { ssr: false });
 const SidebarContents = dynamic(() => import('./SidebarContents').then(mod => mod.SidebarContents), { ssr: false });
@@ -172,12 +174,24 @@ const CollapsibleContainer = memo((props: CollapsibleContainerProps): JSX.Elemen
   return (
   return (
     <div className={`flex-expand-horiz ${className}`} onMouseLeave={mouseLeaveHandler}>
     <div className={`flex-expand-horiz ${className}`} onMouseLeave={mouseLeaveHandler}>
       <Nav onPrimaryItemHover={primaryItemHoverHandler} />
       <Nav onPrimaryItemHover={primaryItemHoverHandler} />
-      <div
-        ref={sidebarScrollerRef}
-        className={`sidebar-contents-container flex-grow-1 overflow-y-auto overflow-x-hidden ${closedClass} ${openedClass}`}
+      {/* <SimpleBar
+        className={`sidebar-contents-container flex-grow-1 ${closedClass} ${openedClass}`}
         style={{ width: collapsibleContentsWidth }}
         style={{ width: collapsibleContentsWidth }}
+        ref={simpleBarRef}
       >
       >
         {children}
         {children}
+      </SimpleBar> */}
+      <div
+        className={`sidebar-contents-container flex-grow-1 overflow-hidden ${closedClass} ${openedClass}`}
+        ref={sidebarScrollerRef}
+      >
+        <SimpleBar
+          className=""
+          style={{ width: collapsibleContentsWidth }}
+          autoHide={false}
+        >
+          {children}
+        </SimpleBar>
       </div>
       </div>
     </div>
     </div>
   );
   );