import { TransitionOptions, useCurrentStateAndParams, useSrefActive as useUiRouterSrefActive, } from '@uirouter/react'; import clsx from 'clsx'; import { ComponentProps } from 'react'; import ReactTooltip from 'react-tooltip'; import { AutomationTestingProps } from '@/types'; import { Link } from '@@/Link'; import { IconProps, Icon } from '@@/Icon'; import { useSidebarState } from '../useSidebarState'; interface Props extends IconProps, ComponentProps, AutomationTestingProps { label: string; ignorePaths?: string[]; } export function Head({ to, options, params = {}, label, icon, ignorePaths = [], 'data-cy': dataCy, }: Props) { const { isOpen } = useSidebarState(); const anchorProps = useSrefActive( to, 'bg-blue-8 be:bg-gray-8 th-dark:bg-gray-true-8', params, options, ignorePaths ); return ( {!!icon && ( svg]:w-4')} /> )} {isOpen && {label}} ); } function useSrefActive( to: string, activeClassName: string, params: Partial> = {}, options: TransitionOptions = {}, ignorePaths: string[] = [] ) { const { state: { name: stateName = '' } = {} } = useCurrentStateAndParams(); const anchorProps = useUiRouterSrefActive( to, params || {}, activeClassName, options ); const className = ignorePaths.some((path) => stateName.includes(path)) ? '' : anchorProps.className; return { ...anchorProps, className, }; }