import { useState, useEffect } from "react";
import { PMTiles } from "../../js/index";
import { styled } from "./stitches.config";
import Inspector from "./Inspector";
import MaplibreMap from "./MaplibreMap";
import Metadata from "./Metadata";
import { MagnifyingGlassIcon, ImageIcon } from "@radix-ui/react-icons";
import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
const StyledToolbar = styled(ToolbarPrimitive.Root, {
display: "flex",
height: "$4",
width: "100%",
boxSizing: "border-box",
minWidth: "max-content",
backgroundColor: "white",
boxShadow: `0 2px 10px "black"`,
});
const itemStyles = {
all: "unset",
flex: "0 0 auto",
color: "$black",
display: "inline-flex",
padding: "0 $1 0 $1",
fontSize: "$2",
alignItems: "center",
"&:hover": { backgroundColor: "$hover", color: "$white" },
"&:focus": { position: "relative", boxShadow: `0 0 0 2px blue` },
};
const StyledLink = styled(
ToolbarPrimitive.Link,
{
...itemStyles,
backgroundColor: "transparent",
color: "black",
display: "inline-flex",
justifyContent: "center",
alignItems: "center",
},
{
"&:hover": {
backgroundColor: "$hover",
color: "$white",
cursor: "pointer",
},
}
);
const StyledToggleGroup = styled(ToolbarPrimitive.ToggleGroup, {
display: "inline-flex",
borderRadius: 4,
});
const StyledToggleItem = styled(ToolbarPrimitive.ToggleItem, {
...itemStyles,
boxShadow: 0,
backgroundColor: "white",
marginLeft: 2,
cursor: "pointer",
"&:first-child": { marginLeft: 0 },
"&[data-state=on]": { backgroundColor: "$primary", color: "$primaryText" },
});
const Toolbar = StyledToolbar;
const ToolbarLink = StyledLink;
const ToolbarToggleGroup = StyledToggleGroup;
const ToolbarToggleItem = StyledToggleItem;
function Loader(props: { file: PMTiles; mapHashPassed: boolean }) {
let [tab, setTab] = useState("maplibre");
let view;
if (tab === "maplibre") {
view = (
);
} else if (tab === "inspector") {
view = ;
} else {
view = ;
}
return (
<>
Map View
Tile Inspector
Metadata
{props.file.source.getKey()}
{view}
>
);
}
export default Loader;