mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
app visual cleanup
This commit is contained in:
@@ -25,7 +25,7 @@ const Pane = styled("div", {
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
backgroundSize: "20px 20px",
|
backgroundSize: "20px 20px",
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
"linear-gradient(to right, #222 1px, transparent 1px),linear-gradient(to bottom, #222 1px, transparent 1px);",
|
"linear-gradient(to right, #111 1px, transparent 1px),linear-gradient(to bottom, #111 1px, transparent 1px);",
|
||||||
});
|
});
|
||||||
|
|
||||||
const TableRow = styled(
|
const TableRow = styled(
|
||||||
@@ -141,7 +141,8 @@ const StyledFeatureProperties = styled("div", {
|
|||||||
position: "absolute",
|
position: "absolute",
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
backgroundColor: "red",
|
backgroundColor: "$black",
|
||||||
|
padding: "$1"
|
||||||
});
|
});
|
||||||
|
|
||||||
const FeatureProperties = (props: { feature: Feature }) => {
|
const FeatureProperties = (props: { feature: Feature }) => {
|
||||||
@@ -302,6 +303,7 @@ function Inspector(props: { file: PMTiles }) {
|
|||||||
<th>y</th>
|
<th>y</th>
|
||||||
<th>offset</th>
|
<th>offset</th>
|
||||||
<th>length</th>
|
<th>length</th>
|
||||||
|
<th>is directory</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>{rows}</tbody>
|
<tbody>{rows}</tbody>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const StyledLink = styled(
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
{ "&:hover": { backgroundColor: "transparent", cursor: "pointer" } }
|
{ "&:hover": { backgroundColor: "$hover", color:"$white", cursor: "pointer" } }
|
||||||
);
|
);
|
||||||
|
|
||||||
const StyledToggleGroup = styled(ToolbarPrimitive.ToggleGroup, {
|
const StyledToggleGroup = styled(ToolbarPrimitive.ToggleGroup, {
|
||||||
@@ -63,10 +63,18 @@ const StyledToggleItem = styled(ToolbarPrimitive.ToggleItem, {
|
|||||||
boxShadow: 0,
|
boxShadow: 0,
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
marginLeft: 2,
|
marginLeft: 2,
|
||||||
|
cursor: "pointer",
|
||||||
"&:first-child": { marginLeft: 0 },
|
"&:first-child": { marginLeft: 0 },
|
||||||
"&[data-state=on]": { backgroundColor: "$primary", color: "white" },
|
"&[data-state=on]": { backgroundColor: "$primary", color: "$primaryText" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const MetadataButton = styled(DialogPrimitive.Trigger, {
|
||||||
|
backgroundColor:"$primary",
|
||||||
|
color:"$primaryText",
|
||||||
|
padding:"$1",
|
||||||
|
cursor: "pointer"
|
||||||
|
})
|
||||||
|
|
||||||
const StyledOverlay = styled(DialogPrimitive.Overlay, {
|
const StyledOverlay = styled(DialogPrimitive.Overlay, {
|
||||||
backgroundColor: "black",
|
backgroundColor: "black",
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
@@ -76,18 +84,36 @@ const StyledOverlay = styled(DialogPrimitive.Overlay, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const StyledContent = styled(DialogPrimitive.Content, {
|
const StyledContent = styled(DialogPrimitive.Content, {
|
||||||
backgroundColor: "$black",
|
backgroundColor: "#222",
|
||||||
|
padding:"$1",
|
||||||
borderRadius: 6,
|
borderRadius: 6,
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
top: "50%",
|
top: "50%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translate(-50%, -50%)",
|
transform: "translate(-50%, -50%)",
|
||||||
width: "90vw",
|
width: "90vw",
|
||||||
maxWidth: "80vh",
|
|
||||||
zIndex: 4,
|
zIndex: 4,
|
||||||
"&:focus": { outline: "none" },
|
"&:focus": { outline: "none" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const MetadataTable = styled("table", {
|
||||||
|
tableLayout:"fixed",
|
||||||
|
width:"100%"
|
||||||
|
});
|
||||||
|
|
||||||
|
const MetadataKey = styled("td", {
|
||||||
|
padding: "0 $1"
|
||||||
|
});
|
||||||
|
|
||||||
|
const MetadataValue = styled("td", {
|
||||||
|
fontFamily:"monospace",
|
||||||
|
});
|
||||||
|
|
||||||
|
const JsonValue = styled(MetadataValue, {
|
||||||
|
overflowX:"scroll"
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
export const introspectTileType = async (file: PMTiles): Promise<TileType> => {
|
export const introspectTileType = async (file: PMTiles): Promise<TileType> => {
|
||||||
let magic = await file.source.getBytes(512000, 4);
|
let magic = await file.source.getBytes(512000, 4);
|
||||||
let b0 = magic.getUint8(0);
|
let b0 = magic.getUint8(0);
|
||||||
@@ -139,12 +165,13 @@ function Loader(props: { file: PMTiles }) {
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, [props.file]);
|
}, [props.file]);
|
||||||
|
|
||||||
const metadataRows = metadata.map((d, i) => (
|
const metadataRows = metadata.map((d, i) => {
|
||||||
<tr key={i}>
|
let Cls = (d[0] === 'json') ? JsonValue : MetadataValue
|
||||||
<td>{d[0]}</td>
|
return <tr key={i}>
|
||||||
<td>{d[1]}</td>
|
<MetadataKey>{d[0]}</MetadataKey>
|
||||||
|
<Cls>{d[1]}</Cls>
|
||||||
</tr>
|
</tr>
|
||||||
));
|
});
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
@@ -174,9 +201,9 @@ function Loader(props: { file: PMTiles }) {
|
|||||||
{props.file.source.getKey()}
|
{props.file.source.getKey()}
|
||||||
</ToolbarLink>
|
</ToolbarLink>
|
||||||
<DialogPrimitive.Root open={modalOpen}>
|
<DialogPrimitive.Root open={modalOpen}>
|
||||||
<DialogPrimitive.Trigger onClick={() => setModalOpen(true)}>
|
<MetadataButton onClick={() => setModalOpen(true)}>
|
||||||
Metadata
|
Metadata
|
||||||
</DialogPrimitive.Trigger>
|
</MetadataButton>
|
||||||
<DialogPrimitive.Portal>
|
<DialogPrimitive.Portal>
|
||||||
<StyledOverlay />
|
<StyledOverlay />
|
||||||
<StyledContent
|
<StyledContent
|
||||||
@@ -185,7 +212,7 @@ function Loader(props: { file: PMTiles }) {
|
|||||||
>
|
>
|
||||||
<DialogPrimitive.Title />
|
<DialogPrimitive.Title />
|
||||||
<DialogPrimitive.Description />
|
<DialogPrimitive.Description />
|
||||||
<table>
|
<MetadataTable>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>key</th>
|
<th>key</th>
|
||||||
@@ -193,7 +220,7 @@ function Loader(props: { file: PMTiles }) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>{metadataRows}</tbody>
|
<tbody>{metadataRows}</tbody>
|
||||||
</table>
|
</MetadataTable>
|
||||||
<DialogPrimitive.Close />
|
<DialogPrimitive.Close />
|
||||||
</StyledContent>
|
</StyledContent>
|
||||||
</DialogPrimitive.Portal>
|
</DialogPrimitive.Portal>
|
||||||
|
|||||||
@@ -115,6 +115,12 @@ function MaplibreMap(props: { file: PMTiles }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let initStyle = async () => {
|
let initStyle = async () => {
|
||||||
if (map) {
|
if (map) {
|
||||||
|
let metadata = await props.file.metadata();
|
||||||
|
let bounds = metadata.bounds.split(',');
|
||||||
|
map.fitBounds([
|
||||||
|
[+bounds[0], +bounds[1]],
|
||||||
|
[+bounds[2], +bounds[3]],
|
||||||
|
]);
|
||||||
let tileType = await introspectTileType(props.file);
|
let tileType = await introspectTileType(props.file);
|
||||||
let style: any; // TODO maplibre types (not any)
|
let style: any; // TODO maplibre types (not any)
|
||||||
if (tileType === TileType.PNG || tileType == TileType.JPG) {
|
if (tileType === TileType.PNG || tileType == TileType.JPG) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const Container = styled("div", {
|
|||||||
|
|
||||||
const Button = styled("button", {
|
const Button = styled("button", {
|
||||||
padding: "$1 $2",
|
padding: "$1 $2",
|
||||||
|
marginBottom:"$1",
|
||||||
borderRadius: "$2",
|
borderRadius: "$2",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
variants: {
|
variants: {
|
||||||
@@ -79,7 +80,7 @@ const Example = styled("div", {
|
|||||||
borderBottom: "1px solid $white",
|
borderBottom: "1px solid $white",
|
||||||
},
|
},
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: "$white",
|
backgroundColor: "$hover",
|
||||||
},
|
},
|
||||||
variants: {
|
variants: {
|
||||||
selected: {
|
selected: {
|
||||||
@@ -142,7 +143,7 @@ function Start(props: {
|
|||||||
onChange={onRemoteUrlChangeHandler}
|
onChange={onRemoteUrlChangeHandler}
|
||||||
></Input>
|
></Input>
|
||||||
<Button color="gray" onClick={onSubmit}>
|
<Button color="gray" onClick={onSubmit}>
|
||||||
Load
|
Load URL
|
||||||
</Button>
|
</Button>
|
||||||
<Label htmlFor="localFile">Select a local file</Label>
|
<Label htmlFor="localFile">Select a local file</Label>
|
||||||
<Dropzone {...getRootProps()}>
|
<Dropzone {...getRootProps()}>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const { styled } = createStitches({
|
|||||||
white: "rgba(236, 237, 238)",
|
white: "rgba(236, 237, 238)",
|
||||||
hover: "#7180B9",
|
hover: "#7180B9",
|
||||||
primary: "#3423A6",
|
primary: "#3423A6",
|
||||||
|
primaryText: "white"
|
||||||
},
|
},
|
||||||
fonts: {
|
fonts: {
|
||||||
sans: "Inter, sans-serif",
|
sans: "Inter, sans-serif",
|
||||||
|
|||||||
Reference in New Issue
Block a user