From 0759cbaa25b0570f76ab353a986734355e05288e Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sat, 28 Nov 2026 18:08:13 -0700 Subject: [PATCH] just shots: screenshots of the whole page at the 3, 2 and 1 column widths Co-Authored-By: Claude Fable 5.2 --- justfile | 4 ++++ scripts/shots.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 scripts/shots.js diff --git a/justfile b/justfile index 2c57a22..a7c7761 100644 --- a/justfile +++ b/justfile @@ -8,3 +8,7 @@ test: run: cargo run -p sccache-dash + +# Screenshots of the whole page at the 3, 2 and 1 column widths; read them before merging a page change. +shots url="http://127.0.0.1:8226/" out="target/shots": + prlimit --core=1:1 -- node scripts/shots.js {{url}} {{out}} diff --git a/scripts/shots.js b/scripts/shots.js new file mode 100644 index 0000000..a4fa000 --- /dev/null +++ b/scripts/shots.js @@ -0,0 +1,24 @@ +// Screenshots of the whole page at each layout width (3, 2 and 1 column), read +// before any page change is merged. Usage: just shots [url] [out-dir] +const path = require('path'); +const { execSync } = require('child_process'); +const root = execSync('mise where npm:playwright 2>/dev/null || mise where playwright', { encoding: 'utf8' }).trim(); +const { chromium } = require(path.join(root, 'node_modules/playwright')); +const [, , url = 'http://127.0.0.1:8226/', out = 'target/shots'] = process.argv; +(async () => { + require('fs').mkdirSync(out, { recursive: true }); + const browser = await chromium.launch({ + args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'], + }); + for (const [width, height] of [[1400, 2600], [900, 3600], [390, 5600]]) { + // The page scrolls inside its canvas, so a tall window shows all of it. + const page = await browser.newPage({ viewport: { width, height }, colorScheme: 'dark' }); + await page.goto(url); + await page.waitForTimeout(5000); + const file = path.join(out, `page-${width}.png`); + await page.screenshot({ path: file }); + console.log(file); + await page.close(); + } + await browser.close(); +})().catch((error) => { console.error(error); process.exit(1); });