import React from 'react' import classnames from 'classnames' import { type TitleBlockVariant } from '../types' import { NON_REVERSED_VARIANTS } from '../utils' import styles from './NavigationTabs.module.scss' export type CustomNavigationTabProps = Omit & { className: string } export type NavigationTabProps = { text: string href: string active?: boolean handleClick?: (event: React.MouseEvent) => void variant?: TitleBlockVariant id?: string automationId?: string /** * Custom render for the tab. Commonly used to replace the link with a router link component. * Props given to the NavigationTab component will be passed back, along with a decorated className. * It is up to you to reapply them to your custom component. */ render?: (props: CustomNavigationTabProps) => JSX.Element } const isLight = (variant: TitleBlockVariant | undefined): boolean => variant !== undefined && NON_REVERSED_VARIANTS.includes(variant) export const NavigationTab = (props: NavigationTabProps): JSX.Element => { const className = classnames( styles.linkAnchor, isLight(props.variant) && styles.lightBackground, props.active && styles.active, ) if (props.render) { const { render: Component, ...otherProps } = props return } return ( {props.text} ) } NavigationTab.displayName = 'NavigationTab'