import React, { useState } from "react"; import styles from "./NavView.module.scss"; import { utils } from "../../main"; import ScrollPane from "../scrollPane/ScrollPane"; import navigation16Regular from "@iconify/icons-fluent/navigation-16-regular"; import { Icon } from "@iconify/react"; interface Props { /** * View contents */ children: JSX.Element | JSX.Element[]; /** * Side bar contents */ sideBar?: { header?: any; body: { /** * Item label */ label: string; /** * Item action */ action: () => void; /** * Make this a divider instead of an item */ divider?: boolean; }[]; footer?: any; }; /** * Side rail contents */ sideRail?: { /** * The label for the icon */ label: string; /** * The route path the item should take you to */ routePath?: string; /** * The icon */ icon: JSX.Element; /** * If the icon is an image, should it fill up the entire space */ iconFillSpace?: boolean; }[]; } export interface RefInstance { } const NavView = React.forwardRef((props, ref) => { props = utils.mergeObject({ children: <>, sideBar: undefined, sideRail: undefined }, props); const [ sideBarOpen, setSideBarOpen ] = useState(props.sideBar?.body!.length! > 0 ? true : false); return (
{ props.sideRail?.map((item, index) => { return ( ) }) }
{ props.sideBar &&
{ props.sideBar.body!.map((item, index) => { return (
{ item.action(); }} key={ "sideBar-body-" + index }>
{item.label}
); }) }
}
{props.children}
); }); export default NavView;