From c5e62e3cf598d52b81f32bb6922ddebf0aae34ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Tue, 15 Sep 2026 18:26:13 +0300 Subject: [PATCH] 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.md | 1 + src/app.css | 40 +++++++++++++++++++++++++++++ src/app.tsx | 44 ++++++++++++++++++++++++++++---- src/components/Header.tsx | 53 ++++++++++++++++++++++++--------------- 4 files changed, 113 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 938b467..0320d91 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Form teslimi için `CONTACT_WEBHOOK_URL` ortam değişkeni gereklidir. ## Hareket Animasyonlar bilgi taşıdığı yerde kullanılır: hero tek kısa jestle açılır, +sayfa değişirken üstte ince bir yükleme çizgisi akar ve yeni sayfa hafifçe belirir, bölümler görüş alanına girdiğinde bir kez yükselir, şemada noktalar bir aşamadan diğerine geçer ve her aşamanın çizimi o aşamanın yaptığı işi canlandırır. Tümü CSS keyframe'leridir ve `prefers-reduced-motion` tek kuralla diff --git a/src/app.css b/src/app.css index 1eaba7b..80d1ac0 100644 --- a/src/app.css +++ b/src/app.css @@ -1420,6 +1420,44 @@ } } +/* ---- Page change ------------------------------------------------------------ + While the next page's code loads, a hairline in brand runs along the top of + the viewport; once it lands, the page settles in with a short rise. The bar + waits 120ms before showing, so a page that is already cached never flashes + it. */ +.hz-route-progress { + position: fixed; + inset: 0 0 auto; + z-index: 60; + height: 2px; + background: var(--brand); + transform: scaleX(0); + transform-origin: left; + opacity: 0; + pointer-events: none; +} +.hz-route-progress.is-active { + opacity: 1; + animation: hz-progress 2.4s cubic-bezier(0.1, 0.7, 0.2, 1) 120ms forwards; +} +@keyframes hz-progress { + from { + transform: scaleX(0); + } + to { + transform: scaleX(0.85); + } +} +.hz-page-in { + animation: hz-page-in 0.42s var(--ease); +} +@keyframes hz-page-in { + from { + opacity: 0; + transform: translateY(10px); + } +} + /* ---- Scroll-triggered entrance -------------------------------------------- Blocks rise once on entry with a per-card stagger. `is-armed` is only ever set on the client, so server markup is never hidden by a script that has @@ -1452,6 +1490,8 @@ /* The diagram still reads as a diagram with every stage at rest. */ .hz-hero-copy > *, .hz-art-card, + .hz-page-in, + .hz-route-progress, .hz-flow-dot, .hz-flow-bar, .hz-flow-mark, diff --git a/src/app.tsx b/src/app.tsx index 4a8007c..df65e3f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,13 +1,49 @@ import { MetaProvider } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; +import { Router, useIsRouting, useLocation } from "@solidjs/router"; import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; +import { createEffect, on, Suspense, type JSX } from "solid-js"; import Header from "~/components/Header"; import Footer from "~/components/Footer"; import "@fontsource-variable/inter"; import "@fontsource-variable/jetbrains-mono"; import "./app.css"; +/** + * The routed part of the page. A route's code arrives on demand, and until it + * does the router keeps the old page on screen — correct, but with nothing + * moving a click reads as a click that did nothing. So a bar runs along the + * top while the next page loads, and the new page fades in once it lands. + * Hash changes on the same page are scrolling, not navigation, and get + * neither. + */ +function Shell(props: { children: JSX.Element }) { + const location = useLocation(); + const routing = useIsRouting(); + let main!: HTMLElement; + + createEffect( + on( + () => location.pathname, + () => { + // Restart the animation: drop the class, force a style flush, re-add. + main.classList.remove("hz-page-in"); + void main.offsetWidth; + main.classList.add("hz-page-in"); + }, + { defer: true }, + ), + ); + + return ( + <> + diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 415b613..42c1eda 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,5 +1,5 @@ import { A, useLocation } from "@solidjs/router"; -import { createSignal, For, onCleanup, onMount, Show } from "solid-js"; +import { createEffect, createSignal, For, on, onCleanup, Show } from "solid-js"; import Logo from "./Logo"; import { PixelClose, PixelMenu } from "./icons/pixel"; import { anchors, routes, site } from "~/config"; @@ -39,8 +39,12 @@ export default function Header() { /** Anchors carry a fragment; the two standing pages do not. */ const id = (href: string) => href.split("#")[1] ?? ""; + /* A band is only current on the page it lives on: on the diagram or the form + page, a stale "Ürünler" mark would say the click never left home. */ const isCurrent = (href: string) => - href.includes("#") ? active() === id(href) : location.pathname === href; + href.includes("#") + ? location.pathname === routes.home && active() === id(href) + : location.pathname === href; /** * Which band is current. The observer's top margin is the header's own @@ -48,27 +52,36 @@ export default function Header() { * screen, and the bottom margin keeps a band that is only just visible from * taking the mark from the one filling the viewport. */ - onMount(() => { - if (!("IntersectionObserver" in window)) return; + createEffect( + on( + () => location.pathname, + pathname => { + setActive(null); + // The header outlives the page under it, so the bands are looked up + // again on every page change: arriving home from the form page has to + // find sections that did not exist when the header mounted. + if (pathname !== routes.home || !("IntersectionObserver" in window)) return; - const sections = all - .filter(item => item.href.includes("#")) - .map(item => document.getElementById(id(item.href))) - .filter((node): node is HTMLElement => node !== null); + const sections = all + .filter(item => item.href.includes("#")) + .map(item => document.getElementById(id(item.href))) + .filter((node): node is HTMLElement => node !== null); - const observer = new IntersectionObserver( - entries => { - const visible = entries - .filter(entry => entry.isIntersecting) - .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top); - if (visible.length > 0) setActive(visible[0]!.target.id); - }, - { rootMargin: "-72px 0px -55% 0px", threshold: 0 }, - ); + const observer = new IntersectionObserver( + entries => { + const visible = entries + .filter(entry => entry.isIntersecting) + .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top); + if (visible.length > 0) setActive(visible[0]!.target.id); + }, + { rootMargin: "-72px 0px -55% 0px", threshold: 0 }, + ); - sections.forEach(section => observer.observe(section)); - onCleanup(() => observer.disconnect()); - }); + sections.forEach(section => observer.observe(section)); + onCleanup(() => observer.disconnect()); + }, + ), + ); return (