import React from 'react';
import { Nav, MenuContent, MenuItem, MenuList, DrilldownMenu, Menu } from '@breakaway/preact-core';
interface MenuHeights {
[menuId: string]: number;
}
const subMenuTwo: JSX.Element = (
);
const subMenuOne: JSX.Element = (
);
export const NavigationDrilldown: React.FunctionComponent = () => {
const [menuDrilledIn, setMenuDrilledIn] = React.useState([]);
const [drilldownPath, setDrilldownPath] = React.useState([]);
const [menuHeights, setMenuHeights] = React.useState({});
const [activeMenu, setActiveMenu] = React.useState('nav-drilldown-rootMenu');
const onDrillIn = (
_event: React.KeyboardEvent | React.MouseEvent,
fromItemId: string,
toItemId: string,
itemId: string
) => {
setMenuDrilledIn((prevMenuDrilledIn) => [...prevMenuDrilledIn, fromItemId]);
setDrilldownPath((prevDrilldownPath) => [...prevDrilldownPath, itemId]);
setActiveMenu(toItemId);
};
const onDrillOut = (_event: React.KeyboardEvent | React.MouseEvent, toItemId: string, _itemId: string) => {
setMenuDrilledIn((prevMenuDrilledIn) => prevMenuDrilledIn.slice(0, prevMenuDrilledIn.length - 1));
setDrilldownPath((prevDrilldownPath) => prevDrilldownPath.slice(0, prevDrilldownPath.length - 1));
setActiveMenu(toItemId);
};
const onGetMenuHeight = (menuId: string, height: number) => {
if (
(menuHeights[menuId] !== height && menuId !== 'nav-drilldown-rootMenu') ||
(!menuHeights[menuId] && menuId === 'nav-drilldown-rootMenu')
) {
setMenuHeights((prevMenuHeights) => ({ ...prevMenuHeights, [menuId]: height }));
}
};
return (
);
};