From 2df908f7c4c4c065ba3205670b6aa8c31cf2ed7b Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Wed, 30 Sep 2026 16:28:55 -0500 Subject: [PATCH] Backdrop: four parallax layers, laid out per page, tones per top-level section Sixteen circles in four layers, big and slow at the back to small and quicker at the front, each rising by its share of the page's scroll (none at the page's own speed); how far is measured from the page's height, so the back layer visibly moves on a long page. Each path gets its own seeded arrangement. The tone moves on only when a new top-level section arrives, and eases over 2.4s. Dark shades are chosen so text passes 4.5:1 however many circles overlap. Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 2 +- src/components/Layout.tsx | 2 +- src/components/PageBackdrop.css | 105 +++++++++++------------ src/components/PageBackdrop.tsx | 143 +++++++++++++++++++++++--------- 4 files changed, 154 insertions(+), 98 deletions(-) diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 11cbc15..b278bf2 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -277,7 +277,7 @@ The numbers band's "Number Source" dropdown works the same way: | The site's colors, light and dark | the database over `src/index.css` | Admin → Panel → Site settings → Colors (superadmins): pick a color, set its light and/or dark value; saving refuses anything that makes text hard to read. The defaults are `THEME_DEFAULTS` in `server/src/themeDefaults.js` (the admin and the contrast check read it) and the same values as CSS in `src/index.css`; the build stops if the two differ. The admin's labels for them are `THEME_LABELS` in `src/lib/adminSchema/siteSettings.ts`. Change a token's value in both modes and every use follows. Use the token utilities (`text-muted`, `bg-surface`, `border-brand/20`) or `var(--color-…)`, not hex. A color that arrives as data (a page accent, an event's or region's color) goes through `src/lib/color.ts`: `withAlpha` for tints, `accentText` for text in it, `readableOn` for text on it. | | The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | | A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. | -| The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's circles and tones are in `src/components/PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | +| The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | | Timeline leaf colors (green now, autumn going back) | `leafColor` in `src/lib/color.ts` | The green, gold and autumn stops, and `LEAF_TURNED_BY` (2000), the year before which every leaf is fully turned. | | Privacy Policy and Terms wording | `src/pages/Privacy.tsx`, `src/pages/Terms.tsx` | The `PARTS` list, and `LAST_UPDATED` whenever the wording changes. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index f4c14ff..61fc5c9 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -163,7 +163,7 @@ export default function Layout() { // container, and then nothing inside it can be position: sticky // (a blog post's contents column scrolled away with the page).
{ + seed = (seed + 0x6d2b79f5) | 0 + let t = Math.imul(seed ^ (seed >>> 15), 1 | seed) + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t + return ((t ^ (t >>> 14)) >>> 0) / 4294967296 + } +} + +function arrange(path: string): Circle[] { + const random = seeded(path) + return LAYERS.flatMap((layer, index) => + Array.from({ length: layer.count }, (_, i) => ({ + layer: index, + size: layer.size[0] + random() * (layer.size[1] - layer.size[0]), + // Spread across the width, and down the layer's full travel: + // one slice of it per circle, placed somewhere in its slice. + left: -15 + random() * 100, + top: (i + random()) / layer.count, + shade: Math.floor(random() * SHADES), + speed: layer.speed, + })), + ) +} export default function PageBackdrop() { const ref = useRef(null) const { pathname } = useLocation() + const [tone, setTone] = useState(0) + const circles = useMemo(() => arrange(pathname), [pathname]) + // The page's scrollable height, for how far each layer travels. + useEffect(() => { + const backdrop = ref.current + if (!backdrop) return undefined + const measure = () => { + const scroll = Math.max(0, document.documentElement.scrollHeight - window.innerHeight) + backdrop.style.setProperty('--pb-scroll', `${scroll}px`) + } + measure() + const observer = new ResizeObserver(measure) + observer.observe(document.body) + return () => observer.disconnect() + }, []) + + // A new top-level section reaching the window's middle moves the tone on. useEffect(() => { const main = document.getElementById('main') - const backdrop = ref.current - if (!main || !backdrop) return undefined + if (!main) return undefined - backdrop.dataset.tone = '0' + setTone(0) let watched: Element[] = [] - // The band crossing the window's middle line sets the tone. const observer = new IntersectionObserver( (entries) => { for (const entry of entries) { if (!entry.isIntersecting) continue const index = watched.indexOf(entry.target) - if (index >= 0) backdrop.dataset.tone = String(index % TONES) + if (index >= 0) setTone(index % SHADES) } }, { rootMargin: '-50% 0px -50% 0px', threshold: 0 }, ) // Pages draw their sections as their data arrives, so the list - // is gathered again whenever main's content changes. + // is gathered again whenever main's content changes. Only the + // outermost: a timeline's decades are sections inside one. const collect = () => { observer.disconnect() - watched = Array.from(main.querySelectorAll('section')) + watched = Array.from(main.querySelectorAll('section')).filter( + (section) => !section.parentElement?.closest('section'), + ) watched.forEach((section) => observer.observe(section)) } collect() @@ -83,13 +141,20 @@ export default function PageBackdrop() { return ( )