Files
site/scripts/lightcheck.mjs
Claude 36f6a01051 dark mode foundation: follow the device like live hanzo.ai (dark t_dark / light t_light), Hanzo's dark palette on every shared token, shared pieces dark-correct
- Theme before paint: app/layout.jsx runs live hanzo.ai's own pre-paint script (localStorage
  "hanzo.appearance.painted", else prefers-color-scheme) and sets light/dark + t_light/t_dark,
  color-scheme and data-scheme; it re-applies when the device setting changes. Measured: "dark
  t_dark" at first paint, after hydration and after client navigation; no flash; JS off stays bright.
  theme-color follows the scheme (#0A0A0A dark, as live). No appearance switch: no captured live
  menu shows one, so no new words.
- Tokens: html.dark gives --ink/--soft/--faint/--line/--card/--bg and Hanzo's --foreground/
  --background/--primary/--border/--hover/--muted Hanzo's own dark values (public/hanzo.css: page
  #0d0d0d, text #e5e5e5, muted #a3a3a3, borders white 10%, #171717 / #0f0f0f / #262626 surfaces);
  rooms (system.css) too. New --x-raised/--x-on-ink/--x-fill/--x-sunk/--x-knob/--x-e10..15
  replace hard-coded whites in shared rules (Hanzo already defines --card/--raised on inner
  elements, so the new names are prefixed). One-off greys keep their exact light value via
  light-dark(); html.light/html.dark pin color-scheme.
- Dark-correct: cookie banner and preferences, announcement strip, sign-in buttons, buttons, search
  palette and scrims, menus and the menu feature card, sheets, drawers, pause buttons, related
  cards, every components/v2/*.css; the hero dot field draws in the page ink at 17% and redraws on
  a theme change. Hanzo's header and footer go dark through hanzo.css.
- docs/DARK-MODE.md: how a page chat converts its pages; scripts/darkcheck.mjs (what is still
  bright in dark) and scripts/lightcheck.mjs (bright mode unchanged vs an older server).

Checks: bright mode 0 computed-colour diffs vs the base commit on / /pricing /chat (1470, 375) and
/enso /kai /api /affiliate /beta /about /dev /security /payments /models (1470); page text
identical (only the live tokens/s counters move); 0 console/page errors in both modes on / /pricing
/chat at 1470x801 and 375x812 (home's media requests to hanzo.ai are blocked in this sandbox, same
in light); taste, unique OK; build exits 0 with HZ_LIVE_OFFLINE=1 (live figure hosts are blocked
here). Page-owned CSS left for the page chats: /pricing .xpr-*, /chat .cht-*, home .xs-*/.xh-pause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P5YBdxPteCvBL7f74SauJt
2026-11-08 10:59:06 +00:00

40 lines
2.9 KiB
JavaScript

// Bright mode unchanged? (docs/DARK-MODE.md) Compares every element's computed colours, device set to light, between a
// server running the code before your change (HZ_OLD, e.g. a git worktree of origin/main on :4190) and yours (HZ_BASE,
// default :4180). Elements are matched by their DOM path; reduced motion keeps the animations still. Done means "0 diffs".
// Usage: HZ_OLD=http://localhost:4190 node scripts/lightcheck.mjs /pricing /chat (CHROME=path on Linux)
import puppeteer from 'puppeteer-core';
const NEW = process.env.HZ_BASE || 'http://localhost:4180', OLD = process.env.HZ_OLD;
if (!OLD) { console.error('Set HZ_OLD to a server running the code before your change.'); process.exit(2); }
const PROPS = ['color', 'backgroundColor', 'borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor', 'outlineColor', 'fill', 'stroke', 'boxShadow', 'backgroundImage'];
const b = await puppeteer.launch({ executablePath: process.env.CHROME || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true, args: ['--no-sandbox'] });
async function grab(base, path, w) {
const p = await b.newPage();
await p.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'light' }, { name: 'prefers-reduced-motion', value: 'reduce' }]);
await p.setViewport({ width: w, height: w < 500 ? 812 : 801, isMobile: w < 500, hasTouch: w < 500 });
await p.goto(base + path.replace(/\/?$/, '/'), { waitUntil: 'networkidle2', timeout: 120000 });
await new Promise((r) => setTimeout(r, 1500));
const out = await p.evaluate((PROPS) => {
const key = (e) => { const a = []; for (let x = e; x && x !== document.body; x = x.parentElement) { const sib = x.parentElement ? [...x.parentElement.children].filter((y) => y.tagName === x.tagName) : []; a.unshift(x.tagName + (typeof x.className === 'string' && x.className ? '.' + x.className.trim().split(/\s+/)[0] : '') + ':' + sib.indexOf(x)); } return a.join('>'); };
const o = {};
for (const e of document.querySelectorAll('body *')) { const cs = getComputedStyle(e); o[key(e)] = PROPS.map((q) => String(cs[q]).replace(/https?:\/\/[^/)"]+/g, '')).join('|'); }
return o;
}, PROPS);
await p.close();
return out;
}
let total = 0;
for (const path of process.argv.slice(2)) for (const w of [1470, 375]) {
const A = await grab(OLD, path, w), B = await grab(NEW, path, w);
const diff = [];
for (const k of Object.keys(A)) if (B[k] !== undefined && A[k] !== B[k]) { const a = A[k].split('|'), c = B[k].split('|'); PROPS.forEach((q, i) => { if (a[i] !== c[i]) diff.push(`${k.split('>').slice(-2).join('>')} ${q}: ${a[i]} -> ${c[i]}`); }); }
total += diff.length;
console.log(`${path.padEnd(14)} ${w}px ${diff.length} diffs`);
diff.slice(0, 12).forEach((d) => console.log(' ' + d.slice(0, 220)));
}
await b.close();
console.log(total ? `light: ${total} diffs` : 'light: OK (bright mode unchanged)');
process.exit(total ? 1 : 0);