Skip to content

Commit 1bdb200

Browse files
committed
Revert "Simplify nav transitions to a single CSS @view-transition rule"
This reverts commit f2003ff.
1 parent 5b08086 commit 1bdb200

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

site/src/components/Footer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import siteConfig from '../../site.config.json';
33
---
44

5-
<footer class="mt-16 border-t border-(--color-border-glass) bg-(--color-bg)">
5+
<footer class="mt-16 border-t border-(--color-border-glass) bg-(--color-bg)" transition:persist="site-footer">
66
<div
77
class="mx-auto flex max-w-7xl flex-col gap-6 px-4 py-8 text-sm text-(--color-fg-meta) sm:px-6 md:flex-row md:items-center md:justify-between"
88
>

site/src/components/PageBackground.astro

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ const continents = [
66
];
77
---
88

9-
<div class="page-bg" aria-hidden="true">
9+
<div class="page-bg" aria-hidden="true" transition:persist="page-bg">
1010
<div id="page-bg-image" class="page-bg-image"></div>
1111
<div class="page-bg-overlay"></div>
1212
</div>
1313

1414
<script is:inline define:vars={{ continents }}>
15-
/* Randomize the continent on each page load. No animation, no random
16-
offset — just one of three maps, centered. */
15+
/* Pick one of the three continent maps at random on the first page
16+
load. Once picked, stay on that map for the rest of the session:
17+
the bg element is persisted across view-transition navigations
18+
(transition:persist) so re-randomising on every doc click would
19+
cause a hard cut underneath an otherwise smooth nav transition. */
1720
(() => {
18-
const img = continents[Math.floor(Math.random() * continents.length)];
1921
const el = document.getElementById('page-bg-image');
20-
if (!el) return;
22+
if (!el || el.dataset.bgSet === '1') return;
23+
const img = continents[Math.floor(Math.random() * continents.length)];
2124
el.style.backgroundImage = `url('${img}')`;
2225
el.classList.add('is-ready');
26+
el.dataset.bgSet = '1';
2327
})();
2428
</script>
2529

site/src/layouts/Base.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import '../styles/global.css';
3+
import { ClientRouter } from 'astro:transitions';
34
import Header from '../components/Header.astro';
45
import Footer from '../components/Footer.astro';
56
import PageBackground from '../components/PageBackground.astro';
@@ -34,11 +35,12 @@ const release = await getLatestRelease();
3435
type="font/woff"
3536
crossorigin="anonymous"
3637
/>
38+
<ClientRouter />
3739
</head>
3840
<body class="min-h-screen flex flex-col">
3941
<PageBackground />
4042
<Header release={release} pathname={Astro.url.pathname} />
41-
<main class="flex-1">
43+
<main class="flex-1" transition:animate="fade">
4244
<slot />
4345
</main>
4446
<Footer />

site/src/styles/global.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
@import 'tailwindcss';
22
@plugin '@tailwindcss/typography';
33

4-
/* Opt into the browser's native cross-document view transitions for
5-
same-origin navigations. Supporting browsers (Chrome/Edge 126+,
6-
Safari 18+) apply a default crossfade between the outgoing and
7-
incoming page; everything else just navigates normally. No JS, no
8-
framework involvement. */
9-
@view-transition {
10-
navigation: auto;
11-
}
12-
134
/* Self-hosted display face — sourced from tolkano.com's font kit. */
145
@font-face {
156
font-family: 'Fremont';

0 commit comments

Comments
 (0)