2023-04-17 05:46:38 +02:00
|
|
|
import classNames from 'classnames';
|
2023-03-23 19:46:49 +01:00
|
|
|
import { Menu, Item } from 'react-basics';
|
2023-04-17 05:46:38 +02:00
|
|
|
import { useRouter } from 'next/router';
|
2023-03-23 19:46:49 +01:00
|
|
|
import Link from 'next/link';
|
|
|
|
import styles from './SideNav.module.css';
|
|
|
|
|
2023-04-21 17:00:42 +02:00
|
|
|
export function SideNav({ selectedKey, items, shallow, onSelect = () => {} }) {
|
2023-04-17 05:46:38 +02:00
|
|
|
const { asPath } = useRouter();
|
2023-03-23 19:46:49 +01:00
|
|
|
return (
|
2023-03-24 00:33:10 +01:00
|
|
|
<Menu items={items} selectedKey={selectedKey} className={styles.menu} onSelect={onSelect}>
|
2023-03-23 19:46:49 +01:00
|
|
|
{({ key, label, url }) => (
|
2023-04-17 05:46:38 +02:00
|
|
|
<Item
|
|
|
|
key={key}
|
|
|
|
className={classNames(styles.item, { [styles.selected]: asPath.startsWith(url) })}
|
|
|
|
>
|
2023-03-23 19:46:49 +01:00
|
|
|
<Link href={url} shallow={shallow}>
|
|
|
|
{label}
|
|
|
|
</Link>
|
|
|
|
</Item>
|
|
|
|
)}
|
|
|
|
</Menu>
|
|
|
|
);
|
|
|
|
}
|
2023-04-21 17:00:42 +02:00
|
|
|
|
|
|
|
export default SideNav;
|