import { Box, Flex, Grid } from "@chakra-ui/react"; import { FunctionComponent, useEffect } from "react"; import { Route, Switch, useRouteMatch, useLocation, Redirect, } from "react-router-dom"; import { ChooseSubmodule } from "./ChooseSubmodule"; import { API_URL_RESOURCE, DOCS_CONTAINER_ID } from "./constants"; import { NavDrawer } from "./NavDrawer"; import { PackageReadme } from "./PackageReadme"; import { usePackageState } from "./PackageState"; import { PackageTypeDocs } from "./PackageTypeDocs"; import { PrimaryDocNavigation } from "./PrimaryDocNavigation"; import { SecondaryDocNavigation } from "./SecondaryDocNavigation"; import { StickyNavContainer } from "./StickyNavContainer"; // We want the nav to be sticky, but it should account for the sticky heading as well, which is 72px const TOP_OFFSET = "4.5rem"; const DOCS_ROOT_ID = "apidocs_header"; const SubmoduleSelector: FunctionComponent = () => { const { assembly: { data }, } = usePackageState(); return Object.keys(data?.submodules ?? {}).length > 0 ? ( ) : null; }; export const PackageDocs: FunctionComponent = () => { const { path } = useRouteMatch(); const { markdownDocs } = usePackageState(); const { hash, pathname, search } = useLocation(); useEffect(() => { window.requestAnimationFrame(() => { if (hash) { const target = document.querySelector( `[data-heading-id="${hash}"]` ) as HTMLElement; target?.scrollIntoView(true); } else { window.scrollTo(0, 0); } }); // Subscribe to doc loading state so that we run this effect after docs load as well }, [hash, pathname, markdownDocs.isLoading]); return ( {/* Primary Nav */} {/* Docs */} {/* Secondary Nav */} ); };