import React, { ReactNode } from "react"; import cn from "classnames"; import { Link, useRouteMatch } from "react-router-dom"; import { Dropdown } from "../Dropdown"; export interface NavigationMenuItemProps { /** * Additional Class */ className?: string; /** * An Icon to be displayed on the right hand side of the Alert */ icon?: ReactNode; /** * Title of the Item */ title: string; /** * Href if this is navigating somewhere */ href?: string; /** * target property, only used when href is set */ target?: string; /** * Router Link to if using react-router-dom */ to?: any; /** * Router Link property if using react-router-dom */ activeOnlyWhenExact?: boolean; /** * On click handler */ onClick?: React.MouseEventHandler; /** * Provide dropdown items if this is to be a dropdown menu */ dropdownItems?: ReactNode[]; /** * State of the dropdown being shown */ dropdownShow?: boolean; /** * Applies dark theme to dropdown */ darkDropdown?: boolean; /** * Shows this item as being active */ active?: boolean; /** * Disables the menu item */ disabled?: boolean; /** * Badge if you want to show one */ badge?: ReactNode; } export const NavigationMenuItem: React.FC = ({ className, icon, title, href, target, to, activeOnlyWhenExact, onClick, dropdownItems, dropdownShow, darkDropdown, active, disabled, badge, }) => { const match = useRouteMatch({ path: to, exact: activeOnlyWhenExact, }); return (
  • {icon && ( {icon} )} {title} {badge} {dropdownItems ? ( {dropdownItems} ) : null}
  • ); };