/** * @flow * @file Preview sidebar nav button component * @author Box */ import * as React from 'react'; import { Route } from 'react-router-dom'; import noop from 'lodash/noop'; import NavButton from '../common/nav-button'; import Tooltip from '../../components/tooltip/Tooltip'; import './SidebarNavButton.scss'; type Props = { 'data-resin-target'?: string, 'data-testid'?: string, children: React.Node, elementId?: string, isOpen?: boolean, onClick?: (sidebarView: string) => void, sidebarView: string, tooltip: React.Node, }; const SidebarNavButton = React.forwardRef>((props: Props, ref: React.Ref) => { const { 'data-resin-target': dataResinTarget, 'data-testid': dataTestId, children, elementId = '', isOpen, onClick = noop, sidebarView, tooltip, } = props; const sidebarPath = `/${sidebarView}`; const handleNavButtonClick = () => { onClick(sidebarView); }; return ( {({ match }) => { const isMatch = !!match; const isActive = () => isMatch && !!isOpen; const isActiveValue = isActive(); const isExactMatch = isMatch && match.isExact; const id = `${elementId}${elementId === '' ? '' : '_'}${sidebarView}`; return ( {children} ); }} ); }); export default SidebarNavButton;