[feature-136] init show local models

This commit is contained in:
MathieuG-P
2023-05-01 23:00:13 +02:00
parent bdbdcfb1b4
commit ab798437d5
36 changed files with 456 additions and 64 deletions
@@ -0,0 +1,31 @@
import { DetailedHTMLProps, Fragment } from "react";
type Props<T> = {
className?: string;
tabIndex: number;
tabs: BsContentNavBarTab<T>[];
renderTab: (props: DetailedHTMLProps<React.HTMLAttributes<any>, any>, tab?: BsContentNavBarTab<T>, activeTab?: BsContentNavBarTab<T>) => JSX.Element;
onTabChange?: (index: number, tab?: BsContentNavBarTab<T>) => void;
}
export type BsContentNavBarTab<T = unknown> = {
text: string;
extra?: T
}
export function BsContentNavBar<T>({className, tabIndex, tabs, renderTab, onTabChange}: Props<T>) {
const handleTabClick = (index: number) => {
onTabChange?.(index, tabs[index]);
}
return (
<nav className={`h-full grid grid-flow-row ${className ?? ""}`}>
{tabs.map((tab, i) => (
<Fragment key={i}>
{ renderTab({onClick: () => handleTabClick(i)}, tab, tabs[tabIndex]) }
</Fragment>
))}
</nav>
)
}