import { SelectDropdown } from '@automattic/components'; import { Button } from '@wordpress/components'; import { useViewportMatch } from '@wordpress/compose'; import clsx from 'clsx'; import { Children, isValidElement } from 'react'; import { navigate } from 'calypso/lib/navigate'; import type { ReactNode, ReactElement } from 'react'; import './style.scss'; export function SidebarItem( { enabled = true, href, children, }: { enabled?: boolean; href: string; children: ReactNode; } ) { const isActive = window.location.pathname.startsWith( href ); if ( ! enabled && ! isActive ) { return null; } return (
  • ); } export function Sidebar( { children }: { children: ReactNode } ) { const isDesktop = useViewportMatch( 'small', '>=' ); const activeElement = Children.toArray( children ).find( ( child ) => isValidElement( child ) && window.location.pathname.startsWith( child.props.href ) ) as ReactElement; if ( isDesktop ) { return ; } return ( { Children.toArray( children ) .filter( ( child ) => child && isValidElement( child ) ) .map( ( child, index ) => { const { href, ...childProps } = ( child as ReactElement ).props; return ( navigate( href ) } /> ); } ) } ); } export function PanelWithSidebar( { children }: { children: ReactNode } ) { return
    { children }
    ; }