import { useSrefActive } from '@uirouter/react'; import classnames from 'classnames'; import React from 'react'; import './HorizontalTabs.less'; interface ITabProps { title: string; path: string; } export interface IHorizontalTabsProps { tabs: ITabProps[]; className?: string; onClick?: (props: ITabProps) => void; rightElement?: React.ReactElement; } export const HorizontalTabs = ({ tabs, className, onClick, rightElement }: IHorizontalTabsProps) => { return (
{tabs.map((tab) => ( ))} {rightElement &&
{rightElement}
}
); }; interface ITabTitleProps { data: ITabProps; onClick?: (props: ITabProps) => void; } const TabTitle = ({ data, onClick }: ITabTitleProps) => { const sRefProps = useSrefActive(data.path, {}, 'selected-tab'); return ( { sRefProps.onClick(e); onClick?.(data); }} > {data.title} ); };