From 1d21be428510a3abb295af09beccf508c5790864 Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 17:38:42 +0000 Subject: [PATCH] site: no sideways scroll at 450-1020 px (hero clips the demo glow), overflow test for 320-1440 px light and dark, css ?v bump --- site/index.html | 2 +- site/style.css | 4 ++- tests/site-overflow.test.ts | 51 +++++++++++++++++++++++++++++++++++++ tools/ci.ts | 3 ++- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tests/site-overflow.test.ts diff --git a/site/index.html b/site/index.html index 9aee2a76..df0e88b5 100644 --- a/site/index.html +++ b/site/index.html @@ -25,7 +25,7 @@ - + diff --git a/site/style.css b/site/style.css index 2caf0f2f..486bbcc1 100644 --- a/site/style.css +++ b/site/style.css @@ -290,7 +290,9 @@ a:hover .ext{opacity:1} /* ---------- hero ---------- */ .fine { font-size: 13.5px; color: var(--muted); margin-top: 14px; } .fine a { color: inherit; } -.hero { position: relative; isolation: isolate; padding: 48px 0 0; +/* overflow-x: clip keeps the demo glow (.demo::before reaches 4% past the window and blurs) from widening the page + at 450-1020px, where the gutter is narrower than that; it clips at the viewport edge, where body already did */ +.hero { position: relative; isolation: isolate; padding: 48px 0 0; overflow-x: clip; background: radial-gradient(55% 60% at 78% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%); } .hero-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); diff --git a/tests/site-overflow.test.ts b/tests/site-overflow.test.ts new file mode 100644 index 00000000..a2dc1398 --- /dev/null +++ b/tests/site-overflow.test.ts @@ -0,0 +1,51 @@ +// The site (site/index.html) never scrolls sideways: at every viewport width from 320 to 1440 px (10 px steps), in the +// light and the dark theme, document.documentElement.scrollWidth stays within innerWidth. On a failure it names the +// elements whose right edge passes the viewport outside any scroll container (pseudo-elements show as their owner). +// Uses the bundled playwright-core with its Chromium (or Google Chrome); skips when neither can launch. +import { afterAll, describe, expect, test } from 'bun:test'; +import { join } from 'node:path'; + +const page = 'file://' + join(import.meta.dir, '..', 'site', 'index.html'); + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +let browser: any = null; +let skipWhy = ''; +try { + const { chromium } = await import('playwright-core'); + try { browser = await chromium.launch({ headless: true }); } catch { browser = await chromium.launch({ headless: true, channel: 'chrome' }); } +} catch (e) { skipWhy = (e as Error).message.split('\n')[0]!; } +if (!browser) console.warn(`site overflow test skipped: no Chromium could launch (${skipWhy}). Run \`bunx playwright install chromium\`.`); + +afterAll(async () => { await browser?.close(); }); + +describe.skipIf(!browser)('site: no horizontal overflow', () => { + for (const scheme of ['light', 'dark'] as const) { + test(`320-1440 px, ${scheme}`, async () => { + const ctx = await browser.newContext({ colorScheme: scheme, viewport: { width: 1440, height: 900 } }); + const p = await ctx.newPage(); + await p.goto(page, { waitUntil: 'load' }); + const bad: string[] = []; + for (let w = 320; w <= 1440; w += 10) { + await p.setViewportSize({ width: w, height: 900 }); + const r = await p.evaluate(() => { + const iw = innerWidth, sw = document.documentElement.scrollWidth; + if (sw <= iw) return null; + const els: string[] = []; + for (const el of document.querySelectorAll('body *')) { + const rc = el.getBoundingClientRect(); + if (rc.width === 0 || rc.right <= iw + 0.5) continue; + let clipped = false; + for (let a = el.parentElement; a && a !== document.body; a = a.parentElement) { + if (getComputedStyle(a).overflowX !== 'visible') { clipped = true; break; } + } + if (!clipped) els.push(`${el.tagName.toLowerCase()}${el.id ? '#' + el.id : ''}${[...el.classList].map(c => '.' + c).join('')} right=${Math.round(rc.right)}`); + } + return `${iw}px: page ${sw - iw}px too wide${els.length ? ' (' + els.slice(0, 5).join(', ') + ')' : ' (a pseudo-element or transform)'}`; + }); + if (r) bad.push(r); + } + await ctx.close(); + expect(bad).toEqual([]); + }, 120_000); + } +}); diff --git a/tools/ci.ts b/tools/ci.ts index b2e8a4a1..46f21ed7 100644 --- a/tools/ci.ts +++ b/tools/ci.ts @@ -2,7 +2,8 @@ // Everything CI runs, in order; stops at the first failure. bun run ci // `bun test` covers the CLI and the desktop webview (apps/desktop/tests: model, i18n, theme contrast, webview rules), // the desktop boot check (tools/desktop-boot-check.ts: the built window in headless Chromium, needs playwright's -// browser or Google Chrome), and the no-hand-written-SVG guard (tests/no-handmade-svg.test.ts: visx charts, Phosphor icons, simple-icons store marks, Mermaid diagrams). +// browser or Google Chrome), the site overflow check (tests/site-overflow.test.ts: no sideways scroll at 320-1440 px, +// light and dark; skips without Chromium), and the no-hand-written-SVG guard (tests/no-handmade-svg.test.ts: visx charts, Phosphor icons, simple-icons store marks, Mermaid diagrams). // The desktop Rust host (cargo test, clippy // with warnings as errors) runs when cargo is installed; set STOREBOUND_CI_RUST=0 to skip it on a machine without Rust. import { join } from 'node:path';