forge
Explore
Log in

Don't you dare go Hollow

Make page changes visible

Browse files at this commit

c5e62e3cf598d52b81f32bb6922ddebf0aae34eeBurak BoduroğluParent: b07fd42
  • fix
    • make page changes visible
Show full message
fix(nav): make page changes visible

A route's code loads on demand and the router keeps the old page on screen
until it lands, so a click looked like it did nothing. A thin brand bar now
runs along the top while the next page loads, and the new page fades in.

The header also kept marking a home-page band as current on the diagram and
form pages; bands are now only current on home, and the observer is rebuilt
on every page change so arriving home from another page still tracks them.
README.mdmodified+1 -0
@@ -130,6 +130,7 @@ Form teslimi için `CONTACT_WEBHOOK_URL` ortam değişkeni gereklidir.
130 ## Hareket130 ## Hareket
131 131
132 Animasyonlar bilgi taşıdığı yerde kullanılır: hero tek kısa jestle açılır,132 Animasyonlar bilgi taşıdığı yerde kullanılır: hero tek kısa jestle açılır,
133+sayfa değişirken üstte ince bir yükleme çizgisi akar ve yeni sayfa hafifçe belirir,
133 bölümler görüş alanına girdiğinde bir kez yükselir, şemada noktalar bir134 bölümler görüş alanına girdiğinde bir kez yükselir, şemada noktalar bir
134 aşamadan diğerine geçer ve her aşamanın çizimi o aşamanın yaptığı işi135 aşamadan diğerine geçer ve her aşamanın çizimi o aşamanın yaptığı işi
135 canlandırır. Tümü CSS keyframe'leridir ve `prefers-reduced-motion` tek kuralla136 canlandırır. Tümü CSS keyframe'leridir ve `prefers-reduced-motion` tek kuralla
src/app.cssmodified+40 -0
@@ -1420,6 +1420,44 @@
1420 }1420 }
1421 }1421 }
1422 1422
1423+/* ---- Page change ------------------------------------------------------------
1424+ While the next page's code loads, a hairline in brand runs along the top of
1425+ the viewport; once it lands, the page settles in with a short rise. The bar
1426+ waits 120ms before showing, so a page that is already cached never flashes
1427+ it. */
1428+.hz-route-progress {
1429+ position: fixed;
1430+ inset: 0 0 auto;
1431+ z-index: 60;
1432+ height: 2px;
1433+ background: var(--brand);
1434+ transform: scaleX(0);
1435+ transform-origin: left;
1436+ opacity: 0;
1437+ pointer-events: none;
1438+}
1439+.hz-route-progress.is-active {
1440+ opacity: 1;
1441+ animation: hz-progress 2.4s cubic-bezier(0.1, 0.7, 0.2, 1) 120ms forwards;
1442+}
1443+@keyframes hz-progress {
1444+ from {
1445+ transform: scaleX(0);
1446+ }
1447+ to {
1448+ transform: scaleX(0.85);
1449+ }
1450+}
1451+.hz-page-in {
1452+ animation: hz-page-in 0.42s var(--ease);
1453+}
1454+@keyframes hz-page-in {
1455+ from {
1456+ opacity: 0;
1457+ transform: translateY(10px);
1458+ }
1459+}
1460+
1423 /* ---- Scroll-triggered entrance --------------------------------------------1461 /* ---- Scroll-triggered entrance --------------------------------------------
1424 Blocks rise once on entry with a per-card stagger. `is-armed` is only ever1462 Blocks rise once on entry with a per-card stagger. `is-armed` is only ever
1425 set on the client, so server markup is never hidden by a script that has1463 set on the client, so server markup is never hidden by a script that has
@@ -1452,6 +1490,8 @@
1452 /* The diagram still reads as a diagram with every stage at rest. */1490 /* The diagram still reads as a diagram with every stage at rest. */
1453 .hz-hero-copy > *,1491 .hz-hero-copy > *,
1454 .hz-art-card,1492 .hz-art-card,
1493+ .hz-page-in,
1494+ .hz-route-progress,
1455 .hz-flow-dot,1495 .hz-flow-dot,
1456 .hz-flow-bar,1496 .hz-flow-bar,
1457 .hz-flow-mark,1497 .hz-flow-mark,
src/app.tsxmodified+39 -5
@@ -1,13 +1,49 @@
1 import { MetaProvider } from "@solidjs/meta";1 import { MetaProvider } from "@solidjs/meta";
2-import { Router } from "@solidjs/router";2+import { Router, useIsRouting, useLocation } from "@solidjs/router";
3 import { FileRoutes } from "@solidjs/start/router";3 import { FileRoutes } from "@solidjs/start/router";
4-import { Suspense } from "solid-js";4+import { createEffect, on, Suspense, type JSX } from "solid-js";
5 import Header from "~/components/Header";5 import Header from "~/components/Header";
6 import Footer from "~/components/Footer";6 import Footer from "~/components/Footer";
7 import "@fontsource-variable/inter";7 import "@fontsource-variable/inter";
8 import "@fontsource-variable/jetbrains-mono";8 import "@fontsource-variable/jetbrains-mono";
9 import "./app.css";9 import "./app.css";
10 10
11+/**
12+ * The routed part of the page. A route's code arrives on demand, and until it
13+ * does the router keeps the old page on screen — correct, but with nothing
14+ * moving a click reads as a click that did nothing. So a bar runs along the
15+ * top while the next page loads, and the new page fades in once it lands.
16+ * Hash changes on the same page are scrolling, not navigation, and get
17+ * neither.
18+ */
19+function Shell(props: { children: JSX.Element }) {
20+ const location = useLocation();
21+ const routing = useIsRouting();
22+ let main!: HTMLElement;
23+
24+ createEffect(
25+ on(
26+ () => location.pathname,
27+ () => {
28+ // Restart the animation: drop the class, force a style flush, re-add.
29+ main.classList.remove("hz-page-in");
30+ void main.offsetWidth;
31+ main.classList.add("hz-page-in");
32+ },
33+ { defer: true },
34+ ),
35+ );
36+
37+ return (
38+ <>
39+ <div class="hz-route-progress" classList={{ "is-active": routing() }} aria-hidden="true" />
40+ <main ref={main} id="main" class="flex-1">
41+ <Suspense>{props.children}</Suspense>
42+ </main>
43+ </>
44+ );
45+}
46+
11 export default function App() {47 export default function App() {
12 return (48 return (
13 <Router49 <Router
@@ -21,9 +57,7 @@ export default function App() {
21 İçeriğe geç57 İçeriğe geç
22 </a>58 </a>
23 <Header />59 <Header />
24- <main id="main" class="flex-1">60+ <Shell>{props.children}</Shell>
25- <Suspense>{props.children}</Suspense>
26- </main>
27 <Footer />61 <Footer />
28 </div>62 </div>
29 </MetaProvider>63 </MetaProvider>
src/components/Header.tsxmodified+33 -20
@@ -1,5 +1,5 @@
1 import { A, useLocation } from "@solidjs/router";1 import { A, useLocation } from "@solidjs/router";
2-import { createSignal, For, onCleanup, onMount, Show } from "solid-js";2+import { createEffect, createSignal, For, on, onCleanup, Show } from "solid-js";
3 import Logo from "./Logo";3 import Logo from "./Logo";
4 import { PixelClose, PixelMenu } from "./icons/pixel";4 import { PixelClose, PixelMenu } from "./icons/pixel";
5 import { anchors, routes, site } from "~/config";5 import { anchors, routes, site } from "~/config";
@@ -39,8 +39,12 @@ export default function Header() {
39 39
40 /** Anchors carry a fragment; the two standing pages do not. */40 /** Anchors carry a fragment; the two standing pages do not. */
41 const id = (href: string) => href.split("#")[1] ?? "";41 const id = (href: string) => href.split("#")[1] ?? "";
42+ /* A band is only current on the page it lives on: on the diagram or the form
43+ page, a stale "Ürünler" mark would say the click never left home. */
42 const isCurrent = (href: string) =>44 const isCurrent = (href: string) =>
43- href.includes("#") ? active() === id(href) : location.pathname === href;45+ href.includes("#")
46+ ? location.pathname === routes.home && active() === id(href)
47+ : location.pathname === href;
44 48
45 /**49 /**
46 * Which band is current. The observer's top margin is the header's own50 * Which band is current. The observer's top margin is the header's own
@@ -48,27 +52,36 @@ export default function Header() {
48 * screen, and the bottom margin keeps a band that is only just visible from52 * screen, and the bottom margin keeps a band that is only just visible from
49 * taking the mark from the one filling the viewport.53 * taking the mark from the one filling the viewport.
50 */54 */
51- onMount(() => {55+ createEffect(
52- if (!("IntersectionObserver" in window)) return;56+ on(
57+ () => location.pathname,
58+ pathname => {
59+ setActive(null);
60+ // The header outlives the page under it, so the bands are looked up
61+ // again on every page change: arriving home from the form page has to
62+ // find sections that did not exist when the header mounted.
63+ if (pathname !== routes.home || !("IntersectionObserver" in window)) return;
53 64
54- const sections = all65+ const sections = all
55- .filter(item => item.href.includes("#"))66+ .filter(item => item.href.includes("#"))
56- .map(item => document.getElementById(id(item.href)))67+ .map(item => document.getElementById(id(item.href)))
57- .filter((node): node is HTMLElement => node !== null);68+ .filter((node): node is HTMLElement => node !== null);
58 69
59- const observer = new IntersectionObserver(70+ const observer = new IntersectionObserver(
60- entries => {71+ entries => {
61- const visible = entries72+ const visible = entries
62- .filter(entry => entry.isIntersecting)73+ .filter(entry => entry.isIntersecting)
63- .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);74+ .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
64- if (visible.length > 0) setActive(visible[0]!.target.id);75+ if (visible.length > 0) setActive(visible[0]!.target.id);
65- },76+ },
66- { rootMargin: "-72px 0px -55% 0px", threshold: 0 },77+ { rootMargin: "-72px 0px -55% 0px", threshold: 0 },
67- );78+ );
68 79
69- sections.forEach(section => observer.observe(section));80+ sections.forEach(section => observer.observe(section));
70- onCleanup(() => observer.disconnect());81+ onCleanup(() => observer.disconnect());
71- });82+ },
83+ ),
84+ );
72 85
73 return (86 return (
74 <header class="hz-header">87 <header class="hz-header">