Skip to content

Commit

Permalink
fix demo links
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Aug 28, 2024
1 parent 9ae9a51 commit 23809f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
35 changes: 10 additions & 25 deletions src/components/DemoLink.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@ export interface Props {
id: string;
href: string;
}
const {id, href } = Astro.props;
const { id, href } = Astro.props;
---

<a data-vtbag-demo-link {id} {href}><slot /></a>
<script>
import { navigate } from "astro:transitions/client";
// @ts-ignore
const supportsViewTransitions = document.startViewTransition
? "true"
: "false";
document.addEventListener("astro:page-load", () => {
document.querySelectorAll("a[data-vtbag-demo-link]").forEach((a) =>
a.addEventListener("click", (e) => {
e.preventDefault();
sessionStorage.setItem("vtbag-ui-standby", supportsViewTransitions);
sessionStorage.setItem(
"vtbag-ui-reopener-position",
JSON.stringify({
reopenerLeft: "16px",
reopenerTop: "16px",
})
);
navigate((e.target as HTMLElement).getAttribute("href")!);
})
);
});
</script>
<a class="demolink" {id} {href}><slot /></a>

<style is:global>
.demolink:focus-visible {
color: var(--color-primary);
text-decoration: none;
outline: none
}
</style>
10 changes: 10 additions & 0 deletions src/pages/chamber.js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ export async function GET() {
: '<p style="padding:10px;background-color: #996">Cross-document view transitions are not supported in this browser.</p>');
}
}));
if (!sessionStorage.getItem('vtbag-ui-reopener-position')) {
sessionStorage.setItem("vtbag-ui-standby", "true");
sessionStorage.setItem(
"vtbag-ui-reopener-position",
JSON.stringify({
reopenerLeft: "16px",
reopenerTop: "16px",
})
);
}
if (level > 0) {${inspectionChamber}};`,
{
status: 200,
Expand Down

0 comments on commit 23809f8

Please sign in to comment.