Spaces:
Configuration error

File size: 1,038 Bytes
339aa1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import classNames from 'classnames';
import { Menu, Item } from 'react-basics';
import { usePathname } from 'next/navigation';
import Link from 'next/link';
import styles from './SideNav.module.css';

export interface SideNavProps {
  selectedKey: string;
  items: any[];
  shallow?: boolean;
  scroll?: boolean;
  className?: string;
  onSelect?: () => void;
}

export function SideNav({
  selectedKey,
  items,
  shallow = true,
  scroll = false,
  className,
  onSelect = () => {},
}: SideNavProps) {
  const pathname = usePathname();
  return (
    <Menu
      items={items}
      selectedKey={selectedKey}
      className={classNames(styles.menu, className)}
      onSelect={onSelect}
    >
      {({ key, label, url }) => (
        <Item
          key={key}
          className={classNames(styles.item, { [styles.selected]: pathname.startsWith(url) })}
        >
          <Link href={url} shallow={shallow} scroll={scroll}>
            {label}
          </Link>
        </Item>
      )}
    </Menu>
  );
}

export default SideNav;