import { ReactNode } from "react"; import { Link } from "react-router-dom"; import classNames from "classnames"; import { I18nText, ThemeColor, useC } from "../common"; import "./TabBar.css"; export interface Tab { name: string; text: I18nText; link?: string; onClick?: () => void; } export interface TabsProps { activeTabName?: string; tabs: Tab[]; color?: ThemeColor; actions?: ReactNode; dense?: boolean; className?: string; } export default function TabBar(props: TabsProps) { const { tabs, color, activeTabName, className, dense, actions } = props; const c = useC(); return (
{tabs.map((tab) => { const { name, text, link, onClick } = tab; const active = activeTabName === name; const className = classNames("cru-tab-bar-item", active && "active"); if (link != null) { return ( {c(text)} ); } else { return ( {c(text)} ); } })}
{actions}
); }