From 52c8f831d102eb2987705524bee6ef18b5747bde Mon Sep 17 00:00:00 2001 From: Felix Klement Date: Fri, 9 Oct 2026 12:35:09 +0200 Subject: [PATCH] test --- src/components/Header.astro | 9 +++++++++ src/layouts/Base.astro | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index dbc65ef..043df6a 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -250,6 +250,14 @@ const isCurrent = (href: string) => href.split('#')[0] === path && !href.include /* Tone: watch a one-pixel line through the middle of the bar and switch to night while a .night section crosses it. An IntersectionObserver, so nothing runs on scroll. */ const sections = document.querySelectorAll('.night'); + /* The browser chrome follows the bar: theme-color tints the strip around the iPhone's notch and + clock (and the toolbar in Chrome on Android), so it changes with the tone underneath. */ + const themeColor = document.querySelector('meta[name="theme-color"]'); + const tokens = getComputedStyle(document.documentElement); + const chrome = (tone: string) => { + const value = tokens.getPropertyValue(tone === 'night' ? '--night' : '--paper').trim(); + if (themeColor && value && themeColor.content !== value) themeColor.content = value; + }; // Transitions come back once the first tone is drawn (two frames, so it has been painted). const settle = () => requestAnimationFrame(() => requestAnimationFrame(() => header?.removeAttribute('data-tone-init'))); if (header && sections.length && 'IntersectionObserver' in window) { @@ -264,6 +272,7 @@ const isCurrent = (href: string) => href.split('#')[0] === path && !href.include if (entry.isIntersecting) under.add(entry.target); else under.delete(entry.target); } header.dataset.tone = under.size ? 'night' : 'paper'; + chrome(header.dataset.tone); if (header.hasAttribute('data-tone-init')) settle(); }, { rootMargin: `-${mid}px 0px -${window.innerHeight - mid - 1}px 0px` }); sections.forEach((section) => observer!.observe(section)); diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index ff81428..44dd173 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -34,7 +34,7 @@ const altDe = new URL(switchLang(Astro.url, 'de'), Astro.site); {noindex && } + --night for a dark hero, --paper otherwise. The header script updates it on scroll. -->