Skip to content

Commit 6e52fc5

Browse files
committed
feat: add TiTiler link for items
1 parent 46cd096 commit 6e52fc5

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/components/value.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,46 @@ export default function Value({
3939

4040
{children}
4141

42-
{selfHref && <SelfHrefButtons href={selfHref}></SelfHrefButtons>}
42+
{selfHref && (
43+
<SelfHrefButtons
44+
href={selfHref}
45+
isItem={value.type === "Feature"}
46+
></SelfHrefButtons>
47+
)}
4348
</Stack>
4449
</Section>
4550
);
4651
}
4752

48-
function SelfHrefButtons({ href: selfHref }: { href: string }) {
53+
function SelfHrefButtons({ href, isItem }: { href: string; isItem: boolean }) {
4954
return (
5055
<ButtonGroup size={"xs"} variant={"outline"} py={4}>
5156
<Button asChild>
52-
<a href={selfHref} target="_blank">
57+
<a href={href} target="_blank">
5358
<LuExternalLink></LuExternalLink> Source
5459
</a>
5560
</Button>
5661
<Button asChild>
5762
<a
5863
href={
5964
"https://radiantearth.github.io/stac-browser/#/external/" +
60-
selfHref.replace(/^(https?:\/\/)/, "")
65+
href.replace(/^(https?:\/\/)/, "")
6166
}
6267
target="_blank"
6368
>
6469
<LuExternalLink></LuExternalLink> STAC Browser
6570
</a>
6671
</Button>
72+
{isItem && (
73+
<Button asChild>
74+
<a
75+
href={"https://titiler.xyz/stac/viewer?url=" + href}
76+
target="_blank"
77+
>
78+
<LuExternalLink></LuExternalLink> TiTiler
79+
</a>
80+
</Button>
81+
)}
6782
</ButtonGroup>
6883
);
6984
}

tests/panel.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ describe("loading", () => {
3333
.element(app.getByRole("heading", { name: "Planet" }))
3434
.toBeVisible();
3535
});
36+
37+
test("Item has TiTiler link", async () => {
38+
const app = renderApp(
39+
"?href=https://raw.githubusercontent.com/radiantearth/stac-spec/refs/heads/master/examples/simple-item.json",
40+
);
41+
await expect
42+
.element(app.getByRole("link", { name: "TiTiler" }))
43+
.toBeVisible();
44+
});
3645
});

0 commit comments

Comments
 (0)