import { ForwardRefExoticComponent, MouseEventHandler, RefAttributes, } from 'react' import { Link, useLocation } from '@remix-run/react' import * as Toolbar from '@radix-ui/react-toolbar' import { IconProps } from 'phosphor-react' import { useIsDarkTheme } from '~/hooks/useIsDarkTheme' import { navAnchor, navIconLabel, navIconWrapper } from './NavButton.css' export interface NavigationButtonProps { title: string href: string Icon: ForwardRefExoticComponent> isExternal?: boolean showLabel?: boolean onClick?: MouseEventHandler } export const NavigationButton = ({ Icon, title, href, isExternal, showLabel = false, onClick, }: NavigationButtonProps) => { const { pathname } = useLocation() const isRoute = (href !== '/' && pathname.includes(href)) || pathname === href const handleClick: MouseEventHandler = e => { if (onClick) { onClick(e) } } const externalLinkProps = isExternal ? { rel: 'noopener noreferrer', target: '_blank', } : {} const isDarkMode = useIsDarkTheme() /** * TODO: refactor to use `Link` component */ return ( {showLabel ? {title} : null} ) }