- кегли hero: 8 ступеней -> 6 (10/12/14/20/24/54) - зазоры: 10 разных -> сетка 4/8 (4/8/12/16/24/32) - один текстовый край: --edge 24 (мобайл 16), края совпадают в 0 px - планета: clamp((100vh - k) x 1.286), k = 658/600/583 - .pen: 4 кадра hero перерисованы, плашки друг над другом, тикер вынесен за фолд - design/hero-scale-2026-11-16: CSS-блок, отчёт, скриншоты, два верификатора
69 lines
3.5 KiB
JavaScript
69 lines
3.5 KiB
JavaScript
// Machine check of the delivered scale: every gap/padding/margin and font size inside the hero
|
|
// layout must come from the 4/8 grid and the type ladder. Reads live computed styles.
|
|
import { chromium } from 'file:///C:/Users/deeen/node_modules/playwright-core/index.mjs';
|
|
import { pathToFileURL } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const url = pathToFileURL(path.resolve(process.argv[2] || 'preview/index.html')).href;
|
|
const VPS = [[1440, 900], [1920, 1080], [390, 844], [1366, 768]];
|
|
const SCALE = new Set([0, 4, 8, 12, 16, 24, 32, 48]);
|
|
const EDGE = new Set([23, 15]); // --edge − 1px рамки плашки
|
|
const LADDER = new Set([10, 12, 14, 20, 24, 34, 54]);
|
|
const SCOPES = ['.hero', '.hero__grid', '.hero__copy', '.hero-about', '.about-acc'];
|
|
// .btn — страничный компонент кнопки: своя маска (padding 12/26, min-height 48) на весь сайт,
|
|
// ритм hero её не задаёт. .planet* — арт и подсказки внутри кадра планеты.
|
|
const SKIP = '.planet, .planet-tag, .planet-hint, .hero-ticker, .btn';
|
|
|
|
const b = await chromium.launch({ executablePath: 'C:/Users/deeen/AppData/Local/ms-playwright/chromium-1223/chrome-win64/chrome.exe' });
|
|
let total = 0;
|
|
for (const [w, h] of VPS) {
|
|
const p = await b.newPage({ viewport: { width: w, height: h } });
|
|
await p.goto(url);
|
|
await p.evaluate(() => document.fonts.ready);
|
|
await p.addStyleTag({ content: '*,*::before,*::after{animation:none!important;transition:none!important}' });
|
|
const res = await p.evaluate(({ SCOPES, SKIP, SCALE, EDGE, LADDER }) => {
|
|
SCALE = new Set(SCALE); EDGE = new Set(EDGE); LADDER = new Set(LADDER);
|
|
const bad = [];
|
|
const seen = new Set();
|
|
const nodes = [];
|
|
const set = new Set();
|
|
for (const s of SCOPES) {
|
|
document.querySelectorAll(s + ',' + s + ' *').forEach(el => { if (!set.has(el)) { set.add(el); nodes.push(el); } });
|
|
}
|
|
for (const el of nodes) {
|
|
if (el.closest(SKIP)) continue;
|
|
const cs = getComputedStyle(el);
|
|
const id = (el.className || el.tagName) + '';
|
|
const push = (prop, val) => {
|
|
if (val == null || val === '' || val === 'normal' || val === 'auto') return;
|
|
for (const part of String(val).split(' ')) {
|
|
const n = parseFloat(part);
|
|
if (Number.isNaN(n)) continue;
|
|
if (SCALE.has(n) || EDGE.has(n)) continue;
|
|
const key = `${id}|${prop}|${n}`;
|
|
if (seen.has(key)) continue;
|
|
seen.add(key);
|
|
bad.push(`${id}.${prop} = ${part}`);
|
|
}
|
|
};
|
|
const flexy = /flex|grid/.test(cs.display);
|
|
if (flexy) { push('gap', cs.gap); }
|
|
push('padding', cs.padding);
|
|
push('margin', `${cs.marginTop} ${cs.marginBottom}`);
|
|
const hasOwnText = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
|
|
if (cs.fontSize && hasOwnText) {
|
|
const fs = parseFloat(cs.fontSize);
|
|
if (!LADDER.has(fs)) { const key = `${id}|font|${fs}`; if (!seen.has(key)) { seen.add(key); bad.push(`${id}.font-size = ${fs}`); } }
|
|
}
|
|
}
|
|
return bad;
|
|
}, { SCOPES, SKIP, SCALE: [...SCALE], EDGE: [...EDGE], LADDER: [...LADDER] });
|
|
console.log(`${w}x${h}: нарушений ${res.length}`);
|
|
for (const x of res.slice(0, 12)) console.log(' -', x);
|
|
total += res.length;
|
|
await p.close();
|
|
}
|
|
await b.close();
|
|
console.log(total === 0 ? '\nOK: все зазоры и кегли hero — из шкалы' : `\nВСЕГО нарушений: ${total}`);
|
|
process.exit(total === 0 ? 0 : 1);
|