diff --git a/app/globals.css b/app/globals.css index c06ce22..cca177b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -63,9 +63,21 @@ for a single control's height would fork the scale to buy back 4px. */ --site-header-h: calc(var(--sp-3) * 2 + var(--sp-8) + 1px); /* 2×padding + content row ceiling + border */ --chrome-h: var(--site-header-h); + /* Where the hero's large lockup stands: this far under the header. The hero's + top padding and the lockup, which is the header's, both read it, so the two + cannot drift apart. */ + --hero-pad: clamp(var(--sp-6), (6vh / var(--page-zoom)), var(--sp-10)); + /* The large lockup's size. The slot, the lockup and its travel all read it. + On a phone it is 30% smaller, so the lockup does not outweigh the title. */ + --hero-lockup-fs: var(--fs-5xl); /* How large the page is drawn: 1, or 1.5 on a very wide screen (below). */ --page-zoom: 1; } +@media (max-width: 520px) { + :root { + --hero-lockup-fs: calc(var(--fs-5xl) * 0.7); + } +} /* A 27-inch monitor at 2560 wide leaves every page a narrow strip of small type. From 2200px the whole site is drawn at 150%: each route is laid out as @@ -141,20 +153,89 @@ body { .site-header .logo { font-size: var(--fs-lg); } -/* The lockup as a link home, off the homepage. It keeps the lockup's look: no - underline, and the colour the lockup sets itself. The focus ring is the - document's. */ +/* The header lockup, one object. It is the page's only lockup: large and + centred over the hero's slot at the top of the page, bar-sized at the left of + the bar once the reader has scrolled, and travelling between the two. + + It stands out of the row (position: absolute) so the large state never moves + the badge or the appearance control; the row keeps its width with a hidden + copy of the bar-sized lockup (.site-header-logo-slot), which is aria-hidden + and takes no focus. So the bar does not shift when the lockup docks. + + Two states, as a set of properties that interpolate: + docked — left of the bar, vertically centred in it, at --fs-lg. The default, + and the whole of every page but the homepage. + hero — centred on the bar's inner width, --hero-pad below the bar, at + --fs-5xl (the size of the hero's slot). + Where the browser has scroll-driven animations the travel is bound to the + scroll position and needs no script. Elsewhere HeaderLogo sets data-hero on + the header while the slot is on screen and the two states are joined by a + transition. Reduced motion has neither: the lockup is in one state or the + other. */ +.site-header-inner { position: relative; } +.site-header-logo-slot { + visibility: hidden; + display: inline-flex; + font-size: var(--fs-lg); +} .site-header-home { + position: absolute; + left: var(--sp-4); + top: 50%; + translate: 0 -50%; display: inline-flex; color: inherit; text-decoration: none; + font-size: var(--fs-lg); } -.site-header-domain { - font-family: var(--font-mono); - font-size: var(--fs-sm); - color: var(--fg-3); - margin-left: auto; +.site-header-home .logo { font-size: inherit; } +.site-header-home[data-hero] { + left: 50%; + top: calc(100% + var(--hero-pad)); + translate: -50% 0; + font-size: var(--hero-lockup-fs); +} +@media (prefers-reduced-motion: no-preference) { + .site-header-home { + transition: + left var(--dur-slow) var(--ease-soft), + top var(--dur-slow) var(--ease-soft), + translate var(--dur-slow) var(--ease-soft), + font-size var(--dur-slow) var(--ease-soft); + } +} +@keyframes lockup-travel { + from { + left: 50%; + top: calc(100% + var(--hero-pad)); + translate: -50% 0; + font-size: var(--hero-lockup-fs); + } + to { + left: var(--sp-4); + top: 50%; + translate: 0 -50%; + font-size: var(--fs-lg); + } } +/* The travel covers the scroll it takes the slot to leave the bar: the pad and + the slot's height. Bound to the page's scroll, so it is the reader's hand that + moves it, and it is the same object throughout. */ +@supports (animation-timeline: scroll()) { + @media (prefers-reduced-motion: no-preference) { + .site-header-home[data-travel] { + transition: none; + left: var(--sp-4); + top: 50%; + translate: 0 -50%; + font-size: var(--fs-lg); + animation: lockup-travel linear both; + animation-timeline: scroll(root block); + animation-range: 0 calc(var(--hero-pad) + var(--hero-lockup-fs)); + } + } +} + /* The appearance control. Only its place in the row is stated here; the trigger, the panel, and the panel's anchoring are all styled by @ekdotico/domico/styles/appearance.css, so this control reads and behaves @@ -173,6 +254,7 @@ body { flex: none; } .site-header-badge { + margin-left: auto; font-family: var(--font-sans); font-size: var(--fs-sm); /* 0.12em is --tr-label, which the package has stated all along and which @@ -243,33 +325,39 @@ body { this site ever wants a section break it should render from @ekdotico/domico/components rather than redraw one. */ -/* Hero. One screen: the header and the hero together are the viewport's height - wherever the text, the form and the picture fit in it, and the hero grows - rather than clips where they do not (a phone, a short window). +/* Hero. One centred column on the page colour: the lockup, the title, the + lede and the form, each a step of the spacing scale from the next. It is one + screen tall wherever the column fits, and grows where it does not. - The illustration lies along the hero's lower edge. The text never meets it: - the padding under the text is the picture's whole height, and from 1100px, - where the text stands in the picture's empty middle, the rule after - .hero-art says how. + The lockup in the column is a reserved gap (.hero-lockup-slot); the lockup + itself belongs to the header (HeaderLogo, below) and stands over the gap + until the reader scrolls. The column is therefore top-aligned: the lockup's + place is stated once, as --hero-pad under the header, and the slot, which + holds the lockup's space, and the lockup, which stands in it, both read it. - --hero-art-h is the picture's height: its own 2576 by 1104 shape at the - page's width. */ + The hero-pad figure is in the :root block above with the other chrome + geometry. */ .hero { - --hero-art-h: calc(var(--page-w) * 1104 / 2576); position: relative; width: 100%; min-height: calc((100dvh / var(--page-zoom)) - var(--chrome-h)); - padding: clamp(var(--sp-5), (3vh / var(--page-zoom)), var(--sp-9)) 0 calc(var(--hero-art-h) + var(--sp-5)); + padding: var(--hero-pad) 0 var(--sp-10); text-align: center; display: flex; flex-direction: column; align-items: center; - justify-content: center; box-sizing: border-box; } +/* The room the large lockup stands in. One em of its own size, which is the + lockup's tile, plus the tile's drop below the baseline. Not a lockup: a screen + reader and a keyboard meet nothing here. */ +.hero-lockup-slot { + font-size: var(--hero-lockup-fs); + height: 1.2em; + margin-bottom: var(--sp-7); + flex: none; +} .hero-body { - position: relative; - z-index: 1; width: min(var(--content-w), (var(--page-w) * 0.9)); padding: 0 var(--sp-4); flex-shrink: 0; @@ -283,78 +371,26 @@ body { font-size: var(--fs-display); line-height: var(--lh-tight); color: var(--fg-1); - margin: 0 0 clamp(var(--sp-3), (2vh / var(--page-zoom)), var(--sp-6)) 0; + margin: 0 0 var(--sp-5) 0; + text-wrap: balance; } .hero-lede { font-family: var(--font-sans); font-size: var(--fs-lede); line-height: var(--lh-prose); color: var(--fg-2); - margin: 0 auto; + margin: 0 auto var(--sp-7); max-width: var(--measure); /* Balance, not the package's pretty: pretty still left the last word of a centred lede on a line of its own. Balanced lines leave no short last line. */ text-wrap: balance; } - -/* The hero illustration: one picture for the light mode and one for the dark, - transparent, drawn straight on the page colour along the foot of the hero - with nothing over it. It is a background on one empty, aria-hidden element. - - The box's height is --hero-art-h, stated on .hero, so the space is reserved - before the file arrives and nothing moves when it does. - - Nothing here moves, so there is nothing to switch off for reduced motion. */ -.hero-art { - position: absolute; - inset: auto 0 0 0; - height: var(--hero-art-h); - background: var(--hero-art) center bottom / 100% auto no-repeat; -} -/* From 1100px the text stands in the picture's empty middle. Measured on the - picture (v3, 20 November 2026): between 32% and 70% of its width nothing - is drawn in its upper half (the terraces' last trees end at 32%, the houses - under the tower begin at 71%), so the column is 40% of the page (the owner - widened it from 36% on 19 November 2026; its text and form checked clear of - the drawing at 1100, 1440 and 2400 wide, in both modes) and ends at half the - picture's height. Below 1100px that column would be under 400px, and the base rule - keeps the text above the whole picture instead. */ @media (min-width: 1100px) { - .hero { padding-bottom: calc(var(--hero-art-h) * 0.5); } - .hero-body { width: min(var(--content-w), var(--page-w) * 0.4); } - /* The sizes the owner set, 19 November 2026: the title 3rem, and the lede - one step above a paragraph. Below 1100px the title keeps its fluid - token, where 3rem would run it to six lines. */ .hero-title { font-size: var(--fs-4xl); } .hero-lede { font-size: var(--fs-lg); } -} -/* The 2576-wide files, where the 1288-wide ones would be stretched. The same - query is HERO_ART_LARGE in lib/hero-art.ts, which preloads the picture. */ -@media (min-width: 1289px) or ((min-width: 644px) and (min-resolution: 1.5dppx)) { - .hero-art { background-image: var(--hero-art-lg); } -} -/* Which files, under the selectors tokens.css uses for the mode: light by - default, dark when chosen, and dark under the system's preference when the - reader has chosen neither. Only the mode chooses; every theme has both. */ -.hero { - --hero-art: url('/hero/hero-v3-light-1288.avif'); - --hero-art-lg: url('/hero/hero-v3-light.avif'); -} -[data-mode="dark"] .hero { - --hero-art: url('/hero/hero-v3-dark-1288.avif'); - --hero-art-lg: url('/hero/hero-v3-dark.avif'); -} -@media (prefers-color-scheme: dark) { - :root:not([data-mode]) .hero { - --hero-art: url('/hero/hero-v3-dark-1288.avif'); - --hero-art-lg: url('/hero/hero-v3-dark.avif'); - } -} -/* A picture on a page colour that forced colours has replaced, or on paper, - is noise. Both get the hero without it. */ -@media (forced-colors: active), print { - .hero { padding-bottom: var(--sp-6); } - .hero-art { display: none; } + .hero-lockup-slot { margin-bottom: var(--sp-8); } + .hero-title { margin-bottom: var(--sp-6); } + .hero-lede { margin-bottom: var(--sp-8); } } /* The release status (AlphaNotice): a bar along the foot of the window, in the @@ -584,22 +620,4 @@ html:has(.alpha-notice) { /* Field above button: side by side, the address would get a third of a phone's width. */ .waitlist-row { flex-direction: column; align-items: stretch; } - - /* Drop the domain label from the header row on phones. The appearance trigger - is a fixed 36px and does not shrink, so at 375px the row measured flush to - the viewport and the badge — the one item in it that can shrink — wrapped - "Pre-launch" onto a second line, taking the header from 61px to 67px. - - The domain is what goes, because it is the one thing in the row that is - said twice already: the wordmark beside it reads "Ekdotico" and the address - bar above it reads the domain. Nothing is lost at this width that the - reader cannot see without it. */ - .site-header-domain { display: none; } - - /* The auto margin that right-aligns the tail of the row lives on the domain, - and display: none takes an element out of layout margins and all — so - hiding it alone left the badge and the trigger sitting against the logo, - with the trigger 85px short of the right edge. The badge is the first item - of the tail at this width, so it inherits the job. */ - .site-header-badge { margin-left: auto; } } diff --git a/components/alpha/HeaderLogo.tsx b/components/alpha/HeaderLogo.tsx index 8e3cef5..99b8923 100644 --- a/components/alpha/HeaderLogo.tsx +++ b/components/alpha/HeaderLogo.tsx @@ -2,26 +2,61 @@ import Link from 'next/link'; import { usePathname } from 'next/navigation'; +import { useEffect, useState } from 'react'; import { Logo } from '@/components/Logo'; /* - * The header lockup, linked home on every page but the homepage. On the - * homepage a link would only point at the page the reader is already on, so - * the lockup stays plain there. + * The page's one lockup, linked to the top of the page. On the homepage it + * stands large over the hero's slot and travels into the bar as the reader + * scrolls (the rules are in globals.css, "The header lockup, one object"); on + * every other page it is simply in the bar. * - * A client component for usePathname alone: the (site) layout renders the - * header once for every page and is never told which page it is wrapping. + * Where the browser has scroll-driven animations, data-travel hands the travel + * to the stylesheet and nothing here runs after the first paint. Elsewhere an + * IntersectionObserver on the hero's slot sets data-hero while the slot is on + * screen, and the stylesheet joins the two states with a transition (or, under + * reduced motion, with none). The default is docked, so a page that never + * hydrates shows a bar-sized lockup in the bar, not a large one over the text. * - * The link is named outright rather than left to the lockup's visually hidden - * "Ekdotico": the name then says where it goes, and does not depend on how a - * given reader computes a name from clipped text. + * Exactly one lockup is exposed to a screen reader: this link carries the name + * outright, and the copy that holds the bar's width is aria-hidden. + * + * A client component for usePathname and the observer: the (site) layout + * renders the header once for every page and is never told which one it wraps. */ export function HeaderLogo() { - if (usePathname() === '/') return ; + const home = usePathname() === '/'; + const [heroVisible, setHeroVisible] = useState(false); + + useEffect(() => { + if (!home) return; + const slot = document.getElementById('hero-lockup-slot'); + if (!slot) return; + // The slot counts as on screen until it has scrolled up under the bar, so + // the observer's top edge is the bar's own measured bottom. + const bar = document.querySelector('.site-header')?.getBoundingClientRect().height ?? 0; + const observer = new IntersectionObserver(([entry]) => setHeroVisible(entry.isIntersecting), { + rootMargin: `-${bar}px 0px 0px 0px`, + }); + observer.observe(slot); + return () => observer.disconnect(); + }, [home]); + return ( - - - + <> + + + + + ); } diff --git a/components/alpha/Hero.tsx b/components/alpha/Hero.tsx index 652e109..4e50083 100644 --- a/components/alpha/Hero.tsx +++ b/components/alpha/Hero.tsx @@ -1,18 +1,12 @@ -import { appearanceState } from '@ekdotico/domico/theme/server'; -import { cookies } from 'next/headers'; import { WaitlistForm } from '@/components/alpha/WaitlistForm'; -import { heroArtPreloads } from '@/lib/hero-art'; - -export async function Hero() { - const preloads = heroArtPreloads(appearanceState(await cookies())); +export function Hero() { return (
- {/* React lifts these into the head. The illustration is a CSS background, - which the browser would otherwise find only after the stylesheet. */} - {preloads.map(({ href, media }) => ( - - ))} + {/* The room the large lockup stands in. The lockup itself is the header's + (HeaderLogo), which carries it from here into the bar as the page + scrolls; this is only the gap it leaves, and hidden from a screen reader. */} +
); } diff --git a/components/alpha/SiteHeader.tsx b/components/alpha/SiteHeader.tsx index 3d6064f..02119cb 100644 --- a/components/alpha/SiteHeader.tsx +++ b/components/alpha/SiteHeader.tsx @@ -1,25 +1,20 @@ import { AppearanceMenu } from '@ekdotico/domico/theme'; import { HeaderLogo } from '@/components/alpha/HeaderLogo'; -import { SITE_META } from '@/lib/site'; /* - * Sticky site header. Four pieces: wordmark (HeaderLogo, which links home off - * the homepage), domain label, status badge, - * and the appearance control at the far right. + * Sticky site header. Three pieces: the lockup (HeaderLogo, which on the + * homepage starts large in the hero and travels in as the page scrolls), the + * status badge, and the appearance control at the far right. * * The appearance control is one trigger disclosing the whole optionset, in the - * top-right corner, which is where docs and praktico put theirs. It used to sit - * in the footer here, laid out flat, on the reasoning that a marketing page with - * no sidebar has its footer where the other two surfaces have their sidebar - * foot. That reasoning treated position as the thing to match. What a reader - * actually carries between the three surfaces is the gesture — the same corner, - * the same button, the same panel — and a control laid out flat in a footer - * shares none of it. + * top-right corner, which is where docs and praktico put theirs. What a reader + * carries between the three surfaces is the gesture — the same corner, the same + * button, the same panel — so this site states only where the wrapper sits in + * the row. * * AppearanceMenu is a client component; importing it here does not make this - * header one. It also positions its own panel, off the .appearance-menu wrapper, - * so the only thing this site states is where the wrapper sits in the row. + * header one. It also positions its own panel, off the .appearance-menu wrapper. */ export function SiteHeader() { @@ -27,11 +22,6 @@ export function SiteHeader() {
- {/* From SITE_META, not a literal. lib/site.ts calls `domain` "the brand - string the header and footer print" — the footer reads it and the - header did not, so one of the two would have kept printing the old - value the day it changes. */} - {SITE_META.domain} Closed alpha
diff --git a/lib/hero-art.test.ts b/lib/hero-art.test.ts deleted file mode 100644 index 6f5fd1f..0000000 --- a/lib/hero-art.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { existsSync, readFileSync, readdirSync } from 'node:fs'; -import { describe, expect, it } from 'vitest'; -import { HERO_ART_LARGE, RENDERED_MODES, heroArtFile, heroArtPreloads } from './hero-art'; - -const css = readFileSync('app/globals.css', 'utf8'); -const rules = css.replace(/\/\*[\s\S]*?\*\//g, ''); -const painted = (file: string) => existsSync(`public${file}`) && css.includes(`url('${file}')`); - -describe('hero art', () => { - // The picture is chosen by mode alone and is transparent, so every theme has - // it. A rule here that names a theme would break that, and fails. - it.each(RENDERED_MODES)('%s has its picture in both sizes', (mode) => { - for (const large of [false, true]) { - expect(painted(heroArtFile(mode, large)), heroArtFile(mode, large)).toBe(true); - } - expect(css, 'no hero rule may depend on a theme').not.toMatch(/\[data-theme[^\]]*\][^{]*\.hero/); - }); - - it('keeps nothing of the landscape, its fog or its clouds', () => { - expect(readdirSync('public/hero').sort()).toEqual( - RENDERED_MODES.flatMap((mode) => [false, true].map((large) => heroArtFile(mode, large).split('/').pop())).sort(), - ); - expect(rules).not.toMatch(/hero-cloud|fog|parchment/); - }); - - // The text never meets the picture: under it the padding is the picture's - // whole height, and where the text stands in the picture's empty middle the - // column is 40% of the page and ends at half the picture's height. - it('keeps the text clear of the picture', () => { - expect(rules).toContain('--hero-art-h: calc(var(--page-w) * 1104 / 2576);'); - expect(rules).toMatch(/\.hero \{[^}]*padding: [^;]* calc\(var\(--hero-art-h\) \+ var\(--sp-5\)\);/); - const wide = rules.slice(rules.indexOf('@media (min-width: 1100px)')).split('@media')[1]; - expect(wide).toContain('.hero { padding-bottom: calc(var(--hero-art-h) * 0.5); }'); - expect(wide).toContain('.hero-body { width: min(var(--content-w), var(--page-w) * 0.4); }'); - }); - - // A transform or translate on the tooltip's wrapper makes a stacking context, - // and the panel's own layer then counts only inside it: the next positioned - // row paints over the open tooltip. - it('leaves the info marks out of a stacking context', () => { - const marks = [...rules.matchAll(/\.waitlist-info[^{]*\{([^}]*)\}/g)].map((m) => m[1]).join('\n'); - expect(marks).not.toMatch(/\b(translate|transform|z-index|opacity|filter|isolation)\s*:/); - }); - - it('swaps sizes at the same viewport as globals.css', () => { - expect(css).toContain(`@media ${HERO_ART_LARGE}`); - }); - - it('preloads one picture for an explicit mode and both for Auto', () => { - expect(heroArtPreloads({ mode: 'dark' }).map((p) => p.href)).toEqual([ - '/hero/hero-v3-dark-1288.avif', - '/hero/hero-v3-dark.avif', - ]); - expect(heroArtPreloads({ mode: 'auto' })).toHaveLength(4); - }); -}); diff --git a/lib/hero-art.ts b/lib/hero-art.ts deleted file mode 100644 index e434a3c..0000000 --- a/lib/hero-art.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { AppearanceState, RenderedMode } from '@ekdotico/domico/theme'; - -// The hero illustration: one transparent picture for the light mode and one -// for the dark, the same in every theme, drawn straight on the page colour. -// The files are in public/hero/ and are painted by the rules in -// app/globals.css, under the same [data-mode] selectors as the tokens, so the -// picture changes with the page. -// -// This module holds only what the server needs to preload the right file. A -// CSS background is found late, after the stylesheet, and the illustration is -// the largest paint on the first screen. - -export const RENDERED_MODES: readonly RenderedMode[] = ['light', 'dark']; - -// The viewport at which globals.css swaps the 1288-wide file for the 2576-wide -// one: wider than the small file, or a dense screen past phone width. -export const HERO_ART_LARGE = '(min-width: 1289px) or ((min-width: 644px) and (min-resolution: 1.5dppx))'; - -export function heroArtFile(mode: RenderedMode, large: boolean): string { - return `/hero/hero-v3-${mode}${large ? '' : '-1288'}.avif`; -} - -export interface HeroArtPreload { - href: string; - media: string; -} - -// One entry per file the browser might paint first. An explicit mode names one -// picture; Auto names both, each behind its own prefers-color-scheme query, so -// only the one that will be painted is fetched. -export function heroArtPreloads({ mode }: Pick): HeroArtPreload[] { - const modes = RENDERED_MODES.filter((m) => mode === 'auto' || m === mode); - return modes.flatMap((m) => { - const scheme = mode === 'auto' ? `(prefers-color-scheme: ${m}) and ` : ''; - return [ - { href: heroArtFile(m, false), media: `${scheme}(not (${HERO_ART_LARGE}))` }, - { href: heroArtFile(m, true), media: `${scheme}(${HERO_ART_LARGE})` }, - ]; - }); -} diff --git a/lib/hero-layout.test.ts b/lib/hero-layout.test.ts new file mode 100644 index 0000000..7fe7a6a --- /dev/null +++ b/lib/hero-layout.test.ts @@ -0,0 +1,26 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; + +const css = readFileSync('app/globals.css', 'utf8'); +const rules = css.replace(/\/\*[\s\S]*?\*\//g, ''); + +describe('hero', () => { + it('has no illustration left', () => { + expect(rules).not.toMatch(/hero-art|\/hero\//); + }); + + // The lockup's place is stated once; the slot, the hero and the lockup read it. + it('states the lockup place once, as --hero-pad', () => { + expect(rules.match(/--hero-pad:/g)).toHaveLength(1); + expect(rules).toMatch(/\.hero \{[^}]*padding: var\(--hero-pad\)/); + expect(rules).toMatch(/top: calc\(100% \+ var\(--hero-pad\)\)/); + }); + + // A transform or translate on the tooltip's wrapper makes a stacking context, + // and the panel's own layer then counts only inside it: the next positioned + // row paints over the open tooltip. + it('leaves the info marks out of a stacking context', () => { + const marks = [...rules.matchAll(/\.waitlist-info[^{]*\{([^}]*)\}/g)].map((m) => m[1]).join('\n'); + expect(marks).not.toMatch(/\b(translate|transform|z-index|opacity|filter|isolation)\s*:/); + }); +}); diff --git a/public/hero/hero-v3-dark-1288.avif b/public/hero/hero-v3-dark-1288.avif deleted file mode 100644 index ba1ef95..0000000 Binary files a/public/hero/hero-v3-dark-1288.avif and /dev/null differ diff --git a/public/hero/hero-v3-dark.avif b/public/hero/hero-v3-dark.avif deleted file mode 100644 index dc720ad..0000000 Binary files a/public/hero/hero-v3-dark.avif and /dev/null differ diff --git a/public/hero/hero-v3-light-1288.avif b/public/hero/hero-v3-light-1288.avif deleted file mode 100644 index 66526e0..0000000 Binary files a/public/hero/hero-v3-light-1288.avif and /dev/null differ diff --git a/public/hero/hero-v3-light.avif b/public/hero/hero-v3-light.avif deleted file mode 100644 index abb98b0..0000000 Binary files a/public/hero/hero-v3-light.avif and /dev/null differ