import { useEffect, useRef } from 'react'; import DSSideNavigation from '@scottish-government/design-system/dist/scripts/components/side-navigation/side-navigation'; import { SideNavigationItemProps, SideNavigationListProps, SideNavigationProps } from './types'; import clsx from 'clsx'; const SideNavigationList = function ({ children, isRoot }: SideNavigationListProps) { return ( ); }; const SideNavigationItem = function ({ children, href, isCurrent = false, linkComponent, title }: SideNavigationItemProps) { const LINK_CLASS = 'ds_side-navigation__link'; return (
  • {isCurrent ? {title} : linkComponent ? linkComponent({ className: LINK_CLASS, href, children: title }) : {title} } {children}
  • ); }; const SideNavigation = function ({ ariaLabel = 'Sections', children, className, ...props }: SideNavigationProps) { const ref = useRef(null); useEffect(() => { /* istanbul ignore else */ if (ref.current) { if (children) { new DSSideNavigation(ref.current).init(); } } }, [ref]); return ( ); }; SideNavigation.displayName = 'SideNavigation'; SideNavigationItem.displayName = 'SideNavigation.Item'; SideNavigationList.displayName = 'SideNavigation.List'; SideNavigation.Item = SideNavigationItem; SideNavigation.List = SideNavigationList; export default SideNavigation;