Skip to content

Commit e43e36a

Browse files
authored
refactor: component file structure (#171)
1 parent 30a3644 commit e43e36a

File tree

17 files changed

+78
-72
lines changed

17 files changed

+78
-72
lines changed

src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useEffect, useMemo, useState } from "react";
22
import { Box, Container, FileUpload, useFileUpload } from "@chakra-ui/react";
33
import type { StacCollection, StacItem } from "stac-ts";
4-
import Map from "./components/map";
5-
import Overlay from "./components/overlay";
64
import { Toaster } from "./components/ui/toaster";
75
import useStacChildren from "./hooks/stac-children";
86
import useStacValue from "./hooks/stac-value";
7+
import Map from "./layers/map";
8+
import Overlay from "./layers/overlay";
99
import type { BBox2D, Color } from "./types/map";
1010
import type { DatetimeBounds, StacValue } from "./types/stac";
1111
import {

src/components/catalogs.tsx renamed to src/components/cards/catalog.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,7 @@ import { MarkdownHooks } from "react-markdown";
22
import { Card, Link, Stack, Text } from "@chakra-ui/react";
33
import type { StacCatalog } from "stac-ts";
44

5-
export default function Catalogs({
6-
catalogs,
7-
setHref,
8-
}: {
9-
catalogs: StacCatalog[];
10-
setHref: (href: string | undefined) => void;
11-
}) {
12-
return (
13-
<Stack>
14-
{catalogs.map((catalog) => (
15-
<CatalogCard
16-
key={"catalog-" + catalog.id}
17-
catalog={catalog}
18-
setHref={setHref}
19-
/>
20-
))}
21-
</Stack>
22-
);
23-
}
24-
25-
export function CatalogCard({
5+
export default function CatalogCard({
266
catalog,
277
setHref,
288
}: {

src/components/collections.tsx renamed to src/components/cards/collection.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
import { MarkdownHooks } from "react-markdown";
22
import { Card, Link, Stack, Text } from "@chakra-ui/react";
33
import type { StacCollection } from "stac-ts";
4-
import { SpatialExtent, TemporalExtent } from "./extent";
4+
import { SpatialExtent, TemporalExtent } from "../extent";
55

6-
export default function Collections({
7-
collections,
8-
setHref,
9-
}: {
10-
collections: StacCollection[];
11-
setHref: (href: string | undefined) => void;
12-
}) {
13-
return (
14-
<Stack>
15-
{collections.map((collection) => (
16-
<CollectionCard
17-
key={"collection-" + collection.id}
18-
collection={collection}
19-
setHref={setHref}
20-
/>
21-
))}
22-
</Stack>
23-
);
24-
}
25-
26-
export function CollectionCard({
6+
export default function CollectionCard({
277
collection,
288
setHref,
299
footer,
File renamed without changes.

src/components/assets.tsx renamed to src/components/sections/assets.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
} from "@chakra-ui/react";
1414
import type { StacAsset } from "stac-ts";
1515
import Properties from "./properties";
16-
import type { StacAssets } from "../types/stac";
17-
import { isCog, isVisual } from "../utils/stac";
16+
import type { StacAssets } from "../../types/stac";
17+
import { isCog, isVisual } from "../../utils/stac";
1818

1919
export default function Assets({
2020
assets,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Stack } from "@chakra-ui/react";
2+
import type { StacCatalog } from "stac-ts";
3+
import CatalogCard from "../cards/catalog";
4+
5+
export default function Catalogs({
6+
catalogs,
7+
setHref,
8+
}: {
9+
catalogs: StacCatalog[];
10+
setHref: (href: string | undefined) => void;
11+
}) {
12+
return (
13+
<Stack>
14+
{catalogs.map((catalog) => (
15+
<CatalogCard
16+
key={"catalog-" + catalog.id}
17+
catalog={catalog}
18+
setHref={setHref}
19+
/>
20+
))}
21+
</Stack>
22+
);
23+
}

src/components/collection-search.tsx renamed to src/components/sections/collection-search.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
} from "@chakra-ui/react";
1616
import { useQuery } from "@tanstack/react-query";
1717
import type { StacCollection } from "stac-ts";
18-
import { CollectionCard } from "./collections";
19-
import type { NaturalLanguageCollectionSearchResult } from "../types/stac";
18+
import type { NaturalLanguageCollectionSearchResult } from "../../types/stac";
19+
import CollectionCard from "../cards/collection";
2020

2121
export default function CollectionSearch({
2222
collections,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Stack } from "@chakra-ui/react";
2+
import type { StacCollection } from "stac-ts";
3+
import CollectionCard from "../cards/collection";
4+
5+
export default function Collections({
6+
collections,
7+
setHref,
8+
}: {
9+
collections: StacCollection[];
10+
setHref: (href: string | undefined) => void;
11+
}) {
12+
return (
13+
<Stack>
14+
{collections.map((collection) => (
15+
<CollectionCard
16+
key={"collection-" + collection.id}
17+
collection={collection}
18+
setHref={setHref}
19+
/>
20+
))}
21+
</Stack>
22+
);
23+
}

src/components/filter.tsx renamed to src/components/sections/filter.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useEffect, useMemo, useState } from "react";
22
import { Checkbox, DataList, Slider, Stack, Text } from "@chakra-ui/react";
33
import type { StacCollection, StacItem } from "stac-ts";
4-
import { SpatialExtent } from "./extent";
5-
import type { BBox2D } from "../types/map";
6-
import type { DatetimeBounds, StacValue } from "../types/stac";
7-
import { getItemDatetimes } from "../utils/stac";
4+
import type { BBox2D } from "../../types/map";
5+
import type { DatetimeBounds, StacValue } from "../../types/stac";
6+
import { getItemDatetimes } from "../../utils/stac";
7+
import { SpatialExtent } from "../extent";
88

99
export default function Filter({
1010
filter,

src/components/item-search.tsx renamed to src/components/sections/item-search.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ import type {
3434
TemporalExtent,
3535
} from "stac-ts";
3636
import * as stac_wasm from "stac-wasm";
37-
import { SpatialExtent } from "./extent";
38-
import useStacSearch from "../hooks/stac-search";
39-
import type { BBox2D } from "../types/map";
40-
import type { StacSearch } from "../types/stac";
37+
import useStacSearch from "../../hooks/stac-search";
38+
import type { BBox2D } from "../../types/map";
39+
import type { StacSearch } from "../../types/stac";
40+
import { SpatialExtent } from "../extent";
4141

4242
export default function ItemSearch({
4343
search,

0 commit comments

Comments
 (0)