Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 3 additions & 58 deletions src/components/catalog.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Stack>
<Value value={catalog}></Value>
{collections && collections?.length > 0 && (
<Section
title={
<HStack>
<Icon>
<LuFolderSearch></LuFolderSearch>
</Icon>{" "}
Collection search
</HStack>
}
>
<CollectionSearch
href={selfHref}
collections={collections}
></CollectionSearch>
</Section>
)}
{catalogs && catalogs.length > 0 && (
<Section title="Catalogs">
<Stack>
{catalogs.map((catalog) => (
<ChildCard
child={catalog}
key={"catalog-" + catalog.id}
></ChildCard>
))}
</Stack>
</Section>
)}
{collections && collections.length > 0 && (
<Section
title={
<HStack>
<Icon>
<LuFolderPlus></LuFolderPlus>
</Icon>{" "}
Collections ({collections.length})
</HStack>
}
>
<Stack>
{collections.map((collection) => (
<ChildCard
child={collection}
key={"collection-" + collection.id}
></ChildCard>
))}
</Stack>
</Section>
)}
<Children value={catalog}></Children>
</Stack>
);
}
74 changes: 62 additions & 12 deletions src/components/children.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Stack>
<Heading size={"md"}>{heading}</Heading>
{children}
</Stack>
<>
{collections && collections?.length > 0 && (
<Section
title={
<HStack>
<Icon>
<LuFolderSearch></LuFolderSearch>
</Icon>{" "}
Collection search
</HStack>
}
>
<CollectionSearch
href={selfHref}
collections={collections}
></CollectionSearch>
</Section>
)}

{catalogs && catalogs.length > 0 && (
<Section title="Catalogs">
<Stack>
{catalogs.map((catalog) => (
<ChildCard
child={catalog}
key={"catalog-" + catalog.id}
></ChildCard>
))}
</Stack>
</Section>
)}

{collections && collections.length > 0 && (
<Section
title={
<HStack>
<Icon>
<LuFolderPlus></LuFolderPlus>
</Icon>{" "}
Collections ({collections.length})
</HStack>
}
>
<Stack>
{collections.map((collection) => (
<ChildCard
child={collection}
key={"collection-" + collection.id}
></ChildCard>
))}
</Stack>
</Section>
)}
</>
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -15,6 +15,7 @@ export function Collection({ collection }: { collection: StacCollection }) {
const { root } = useStacMap();
const searchLinks =
(root && root.links?.filter((link) => link.rel == "search")) || [];

return (
<Stack>
<Value value={collection}>
Expand All @@ -35,6 +36,8 @@ export function Collection({ collection }: { collection: StacCollection }) {
<ItemSearch collection={collection} links={searchLinks}></ItemSearch>
</Section>
)}

<Children value={collection}></Children>
</Stack>
);
}
Expand Down