Files
FastD 446ed39da8 One type system for the hero, proven in the .pen
- The Pencil frames had the term->value pairs as a single $font-body text
  node, so labels like КОМАНДА rendered in Roboto while every other label is
  Montserrat. They are now a frame with Термин ($font-heading 700/11 upper)
  and Описание ($font-body 400/14), same in V1/V2/390 frames.
- The planet art in the five new frames is an image fill again instead of a
  black rectangle (the generator wrote a solid fill).
- Nine hero roles pinned to production computed styles, written into
  DESIGN.md and checked by scripts/verify-pen.py: 0 violations on the canon.
- .pen reserialised, previous state kept in archive/snapshot-2026-11-15-b.pen.
  src/ is untouched: production already matched the table, the drift was only
  in the design file.
2026-11-15 21:02:32 +03:00

113 lines
5.0 KiB
JavaScript

// measure-hero.mjs — computed styles + geometry of the hero roles, on the live page.
// Usage: node measure-hero.mjs <url> <out.json>
import { createRequire } from 'node:module';
const require = createRequire('C:/Users/deeen/AppData/Local/hermes/hermes-agent/node_modules/');
const { chromium } = require('C:/Users/deeen/AppData/Local/hermes/hermes-agent/node_modules/.pnpm/playwright-core@1.64.0/node_modules/playwright-core');
import { writeFileSync } from 'node:fs';
const URL_ = process.argv[2] || 'http://127.0.0.1:8765/src/';
const OUT = process.argv[3] || 'measure.json';
const VIEWPORTS = [
[1920, 1080], [1600, 1000], [1536, 864], [1440, 900], [1366, 768], [820, 1180], [390, 844],
];
const ROLES = {
h1: '.hero__copy .h1, .hero__copy h1',
offer: '.hero__offer',
cta_primary: '.hero__copy .btn--primary, .hero__copy .btn',
bar_title: '.hero-about__title',
bar_lead: '.hero-about__lead',
stat_value: '.hero-stat__value',
stat_label: '.hero-stat__label',
card_title: '.about-acc__card-title',
card_lead: '.about-acc__lead',
term: '.about-acc__term',
desc: '.about-acc__desc',
chip: '.about-acc__chips .chip',
ticker_item: '.hero-ticker__item',
eyebrow: '.eyebrow',
};
const browser = await chromium.launch({ executablePath: 'C:/Users/deeen/AppData/Local/ms-playwright/chromium-1223/chrome-win64/chrome.exe' });
const out = { url: URL_, viewports: {}, roles: {}, heroText: null, sha1: null };
const crypto = await import('node:crypto');
const HERO_TEXT_SHA1 = [];
for (const [w, h] of VIEWPORTS) {
const page = await browser.newPage({ viewport: { width: w, height: h } });
await page.goto(URL_, { waitUntil: 'load' });
await page.waitForTimeout(400);
await page.emulateMedia({ reducedMotion: 'reduce' });
await page.waitForTimeout(150);
const geom = await page.evaluate(() => {
const q = (s) => document.querySelector(s);
const box = (el) => { if (!el) return null; const r = el.getBoundingClientRect(); return { x: +r.x.toFixed(1), y: +r.y.toFixed(1), w: +r.width.toFixed(1), h: +r.height.toFixed(1), bottom: +r.bottom.toFixed(1) }; };
const hero = q('.hero');
const grid = q('.hero__grid');
const gs = grid ? getComputedStyle(grid) : null;
const tick = q('.hero-ticker');
const heroR = hero ? hero.getBoundingClientRect() : null;
const doc = document.documentElement;
return {
vw: innerWidth, vh: innerHeight,
overflowX: +(doc.scrollWidth - innerWidth).toFixed(1),
overflowY: +(doc.scrollHeight - innerHeight).toFixed(1),
gridAreas: gs ? gs.gridTemplateAreas : null,
gridCols: gs ? gs.gridTemplateColumns : null,
gridRows: gs ? gs.gridTemplateRows : null,
hero: box(hero),
ticker: box(tick),
tickerBottom: tick ? +tick.getBoundingClientRect().bottom.toFixed(1) : null,
heroVisibleHeight: heroR ? +(Math.min(heroR.bottom, innerHeight) - Math.max(heroR.top, 0)).toFixed(1) : null,
planet: box(q('.hero__visual .planet') || q('.hero__visual')),
planetAspect: (() => { const el = q('.hero__visual .planet') || q('.hero__visual'); if (!el) return null; const r = el.getBoundingClientRect(); return +(r.width / r.height).toFixed(4); })(),
copy: box(q('.hero__copy')),
bar: box(q('.hero-about')),
cards: box(q('.about-acc')),
card1: box(q('.about-acc .faq-item')),
statRow: (() => {
const st = q('.hero-about__stats');
if (!st) return null;
const kids = [...st.children].map((k) => { const r = k.getBoundingClientRect(); return { y: +r.y.toFixed(1), h: +r.height.toFixed(1), w: +r.width.toFixed(1) }; });
const rows = [...new Set(kids.map((k) => k.y))];
return { rows: rows.length, perRow: kids.length / rows.length, kids };
})(),
pairs: [...document.querySelectorAll('.about-acc__row')].map((r) => {
const b = r.getBoundingClientRect();
return { w: +b.width.toFixed(1), h: +b.height.toFixed(1) };
}),
};
});
const roles = await page.evaluate((ROLES) => {
const res = {};
for (const [k, sel] of Object.entries(ROLES)) {
const el = document.querySelector(sel);
if (!el) { res[k] = null; continue; }
const cs = getComputedStyle(el);
res[k] = {
sel, text: (el.textContent || '').trim().slice(0, 40),
fontFamily: cs.fontFamily, fontSize: cs.fontSize, fontWeight: cs.fontWeight,
lineHeight: cs.lineHeight, letterSpacing: cs.letterSpacing,
textTransform: cs.textTransform, color: cs.color,
};
}
return res;
}, ROLES);
const heroText = await page.evaluate(() => (document.querySelector('.hero')?.innerText || '').replace(/\s+/g, ' ').trim());
out.viewports[`${w}x${h}`] = geom;
if (!out.roles[`${w}x${h}`]) out.roles[`${w}x${h}`] = roles;
out.heroText = out.heroText || heroText;
HERO_TEXT_SHA1.push([`${w}x${h}`, crypto.createHash('sha1').update(heroText).digest('hex').slice(0, 12)]);
await page.close();
}
out.sha1 = HERO_TEXT_SHA1;
writeFileSync(OUT, JSON.stringify(out, null, 2), 'utf8');
await browser.close();
console.log('written', OUT);