/* * Copyright (c) Facebook, Inc. and its affiliates. */ import * as React from 'react'; import cn from 'classnames'; import {SidebarContext} from 'components/Layout/useRouteMeta'; import {MenuContext} from 'components/useMenu'; import {useMediaQuery} from '../useMediaQuery'; import {SidebarRouteTree} from './SidebarRouteTree'; import {Search} from 'components/Search'; import {Button} from 'components/Button'; import {MobileNav} from '../Nav/MobileNav'; import {Feedback} from '../Feedback'; const SIDEBAR_BREAKPOINT = 1023; export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) { const {menuRef, isOpen} = React.useContext(MenuContext); const isMobileSidebar = useMediaQuery(SIDEBAR_BREAKPOINT); let routeTree = React.useContext(SidebarContext); const isHidden = isMobileSidebar ? !isOpen : false; // HACK. Fix up the data structures instead. if ((routeTree as any).routes.length === 1) { routeTree = (routeTree as any).routes[0]; } return ( ); }