import { Button, Flex, forwardRef, Heading, Tab, TabList, TabPanelProps, TabPanel, TabPanels, Tabs, Text, } from "@chakra-ui/react"; import type { FunctionComponent } from "react"; import { HOME_ANALYTICS, SECTION_PADDING } from "./constants"; import { PackageGrid } from "./PackageGrid"; import testIds from "./testIds"; import { CatalogSearchSort } from "../../api/catalog-search/constants"; import { NavLink } from "../../components/NavLink"; import { ROUTES } from "../../constants/url"; import { eventName } from "../../contexts/Analytics"; import { useCatalogResults } from "../../hooks/useCatalogResults"; import { useHistoryState } from "../../hooks/useHistoryState"; import { getSearchPath } from "../../util/url"; interface PackageTabProps { "data-event": string; data: ReturnType; label: string; } interface PackageTabPanelProps extends PackageTabProps, TabPanelProps { tag: string; } const tabs = { community: { "data-event": HOME_ANALYTICS.PUBLISHER.eventName("Community"), label: "Community", tag: "community", }, aws: { "data-event": HOME_ANALYTICS.PUBLISHER.eventName("AWS"), label: "AWS", tag: "aws-published", }, hashicorp: { "data-event": HOME_ANALYTICS.PUBLISHER.eventName("HashiCorp"), label: "HashiCorp", tag: "hashicorp-published", }, }; const PackageTab: FunctionComponent = ({ "data-event": dataEvent, data, label, }) => { return ( {label} ); }; const PackageTabPanel = forwardRef( ({ "data-event": dataEvent, label, data, tag, ...props }, ref) => { return ( ); } ); export const CDKTypeTabs: FunctionComponent = () => { const community = useCatalogResults({ tags: [tabs.community.tag], limit: 4, sort: CatalogSearchSort.DownloadsDesc, }); const aws = useCatalogResults({ tags: [tabs.aws.tag], limit: 4, sort: CatalogSearchSort.DownloadsDesc, }); const hashicorp = useCatalogResults({ tags: [tabs.hashicorp.tag], limit: 4, sort: CatalogSearchSort.DownloadsDesc, }); const [tabIndex, setTabIndex] = useHistoryState("cdkTypeTab", 0); return ( Search by publisher Find constructs published by the open-source community, AWS, and cloud technology providers in one location. You can also include your own construct libraries on Construct Hub by publishing them on npm registry. More concrete guidance can be found in the{" "} Contribute {" "} page. setTabIndex(index)} variant="line" > ); };