Typescript refactor.
This commit is contained in:
1 parent
b578162cb6
commit
7c42f0da82
173 files changed
+968
-549
No files matched your search
@@ -0,0 +1,46 @@
|
||||
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?: boolean;
|
||||
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;
|
||||
Reference in new issue
Block a user