From 8cf61ad32e48643bc0c4737efa2fbeb45448764e Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Tue, 9 Sep 2025 21:10:41 -0700 Subject: [PATCH] fix: collection search for collections too --- src/components/catalog.tsx | 61 ++--------------------------- src/components/children.tsx | 74 +++++++++++++++++++++++++++++------ src/components/collection.tsx | 5 ++- 3 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/components/catalog.tsx b/src/components/catalog.tsx index bc9bf59..9a7780c 100644 --- a/src/components/catalog.tsx +++ b/src/components/catalog.tsx @@ -1,68 +1,13 @@ -import { HStack, Icon, Stack } from "@chakra-ui/react"; -import { LuFolderPlus, LuFolderSearch } from "react-icons/lu"; +import { Stack } from "@chakra-ui/react"; import type { StacCatalog } from "stac-ts"; -import useStacMap from "../hooks/stac-map"; -import { ChildCard } from "./children"; -import { CollectionSearch } from "./search/collection"; -import Section from "./section"; +import { Children } from "./children"; import Value from "./value"; export function Catalog({ catalog }: { catalog: StacCatalog }) { - const { catalogs, collections } = useStacMap(); - const selfHref = catalog.links?.find((link) => link.rel === "self")?.href; return ( - {collections && collections?.length > 0 && ( -
- - - {" "} - Collection search - - } - > - -
- )} - {catalogs && catalogs.length > 0 && ( -
- - {catalogs.map((catalog) => ( - - ))} - -
- )} - {collections && collections.length > 0 && ( -
- - - {" "} - Collections ({collections.length}) - - } - > - - {collections.map((collection) => ( - - ))} - -
- )} +
); } diff --git a/src/components/children.tsx b/src/components/children.tsx index cf4148a..e75a5e7 100644 --- a/src/components/children.tsx +++ b/src/components/children.tsx @@ -1,21 +1,71 @@ -import { Card, Heading, Link, Stack, Text } from "@chakra-ui/react"; +import { Card, HStack, Icon, Link, Stack, Text } from "@chakra-ui/react"; import type { ReactNode } from "react"; +import { LuFolderPlus, LuFolderSearch } from "react-icons/lu"; import { MarkdownHooks } from "react-markdown"; import type { StacCatalog, StacCollection } from "stac-ts"; import useStacMap from "../hooks/stac-map"; +import { CollectionSearch } from "./search/collection"; +import Section from "./section"; + +export function Children({ value }: { value: StacCatalog | StacCollection }) { + const { catalogs, collections } = useStacMap(); + const selfHref = value?.links?.find((link) => link.rel === "self")?.href; -export function Children({ - heading, - children, -}: { - heading: string; - children: ReactNode; -}) { return ( - - {heading} - {children} - + <> + {collections && collections?.length > 0 && ( +
+ + + {" "} + Collection search + + } + > + +
+ )} + + {catalogs && catalogs.length > 0 && ( +
+ + {catalogs.map((catalog) => ( + + ))} + +
+ )} + + {collections && collections.length > 0 && ( +
+ + + {" "} + Collections ({collections.length}) + + } + > + + {collections.map((collection) => ( + + ))} + +
+ )} + ); } diff --git a/src/components/collection.tsx b/src/components/collection.tsx index a627945..d934528 100644 --- a/src/components/collection.tsx +++ b/src/components/collection.tsx @@ -6,7 +6,7 @@ import type { TemporalExtent as StacTemporalExtent, } from "stac-ts"; import useStacMap from "../hooks/stac-map"; -import { ChildCard } from "./children"; +import { ChildCard, Children } from "./children"; import ItemSearch from "./search/item"; import Section from "./section"; import Value from "./value"; @@ -15,6 +15,7 @@ export function Collection({ collection }: { collection: StacCollection }) { const { root } = useStacMap(); const searchLinks = (root && root.links?.filter((link) => link.rel == "search")) || []; + return ( @@ -35,6 +36,8 @@ export function Collection({ collection }: { collection: StacCollection }) { )} + + ); }