import { FunctionComponent, PropsWithChildren, useState } from "react"; import TabWidgetTabBar from "./TabWidgetTabBar"; type Props = { tabs: { label: string }[] width: number height: number } // needs to correspond to css (not best system) - see mountainview.css const tabBarHeight = 30 + 5 const TabWidget: FunctionComponent> = ({children, tabs, width, height}) => { const [currentTabIndex, setCurrentTabIndex] = useState(undefined) const children2 = children as React.ReactElement[] if ((children2 || []).length !== tabs.length) { throw Error('TabWidget: incorrect number of tabs') } const hMargin = 8 const vMargin = 8 const W = (width || 300) - hMargin * 2 const H = height - vMargin * 2 return (
{}} />
{ children2.map((c, i) => { const visible = i === currentTabIndex return (
) }) }
) } export default TabWidget