|
1 | | -import { Alert, SimpleGrid, Stack } from "@chakra-ui/react"; |
2 | | -import { useDuckDb } from "duckdb-wasm-kit"; |
| 1 | +import { DataList, SimpleGrid, Tabs, Text } from "@chakra-ui/react"; |
| 2 | +import { LuFolder, LuFolderMinus } from "react-icons/lu"; |
| 3 | +import type { StacGeoparquetMetadata } from "./stac-geoparquet/context"; |
3 | 4 | import { useStacGeoparquet } from "./stac-geoparquet/hooks"; |
4 | 5 |
|
| 6 | +function Info({ |
| 7 | + metadata, |
| 8 | + id, |
| 9 | +}: { |
| 10 | + metadata?: StacGeoparquetMetadata; |
| 11 | + id?: string; |
| 12 | +}) { |
| 13 | + if (metadata) { |
| 14 | + return ( |
| 15 | + <DataList.Root orientation={"horizontal"} size={"sm"}> |
| 16 | + <DataList.Item> |
| 17 | + <DataList.ItemLabel>Count</DataList.ItemLabel> |
| 18 | + <DataList.ItemValue>{metadata.count}</DataList.ItemValue> |
| 19 | + </DataList.Item> |
| 20 | + <DataList.Item> |
| 21 | + <DataList.ItemLabel>Active item</DataList.ItemLabel> |
| 22 | + <DataList.ItemValue>{id || "none"}</DataList.ItemValue> |
| 23 | + </DataList.Item> |
| 24 | + </DataList.Root> |
| 25 | + ); |
| 26 | + } else { |
| 27 | + return <Text>No file loaded...</Text>; |
| 28 | + } |
| 29 | +} |
| 30 | + |
5 | 31 | export default function Sidebar() { |
6 | | - const { loading, error } = useDuckDb(); |
7 | | - const { metadata } = useStacGeoparquet(); |
| 32 | + const { metadata, id } = useStacGeoparquet(); |
8 | 33 |
|
9 | 34 | return ( |
10 | | - <SimpleGrid columns={4} my={2}> |
11 | | - <Stack bg={"bg.muted"} px={4} py={2} fontSize={"sm"} rounded={"sm"}> |
12 | | - {(metadata && `${metadata.count} items`) || "No file loaded..."} |
13 | | - </Stack> |
14 | | - <Stack fontSize={"small"} mx={4} my={2}> |
15 | | - {loading && ( |
16 | | - <Alert.Root status={"info"}> |
17 | | - <Alert.Indicator></Alert.Indicator> |
18 | | - <Alert.Content>Loading DuckDB...</Alert.Content> |
19 | | - </Alert.Root> |
20 | | - )} |
21 | | - {error && ( |
22 | | - <Alert.Root status={"error"}> |
23 | | - <Alert.Indicator></Alert.Indicator> |
24 | | - <Alert.Content>DuckDB error: {error.toString()}</Alert.Content> |
25 | | - </Alert.Root> |
26 | | - )} |
27 | | - </Stack> |
| 35 | + <SimpleGrid columns={3} my={2} pointerEvents={"auto"}> |
| 36 | + <Tabs.Root |
| 37 | + bg={"bg.muted"} |
| 38 | + px={4} |
| 39 | + pt={2} |
| 40 | + pb={4} |
| 41 | + fontSize={"sm"} |
| 42 | + rounded={"sm"} |
| 43 | + defaultValue={"info"} |
| 44 | + > |
| 45 | + <Tabs.List> |
| 46 | + <Tabs.Trigger value="info"> |
| 47 | + {(metadata && <LuFolder></LuFolder>) || ( |
| 48 | + <LuFolderMinus></LuFolderMinus> |
| 49 | + )} |
| 50 | + </Tabs.Trigger> |
| 51 | + </Tabs.List> |
| 52 | + <Tabs.Content value="info"> |
| 53 | + <Info metadata={metadata} id={id}></Info> |
| 54 | + </Tabs.Content> |
| 55 | + </Tabs.Root> |
28 | 56 | </SimpleGrid> |
29 | 57 | ); |
30 | 58 | } |
0 commit comments