Filters: the panel is a bar (status segment, always visible) plus a body that lives as a layer under it - collapsed by default, expands on hover/focus/tap and never moves the case grid; the reset control appears only when a facet is limited; width capped at 720px (measured 45px slack against 477px before). Facet research report is included. Links: project links in the mini card and in the project window are icon-only buttons with a uniform slot (16px card / 18px window) and the accessible name in aria-label; studio contacts (mail, VK, RuStore) live outside the cards. Team and page: real photos from the public TITANS team page go to the member window while the card keeps the mascot; the portfolio gains the First Step Radio card and genre values, the process block became an individual-approach section, plus a cookie bar and a removable ticker. Design folders under design/ keep reports, measurements, scripts and the .pen; probe and before/after screenshot dumps, editor backups and caches are removed. Background-variant and palette previews stay until the client picks one.
346 lines
23 KiB
JavaScript
346 lines
23 KiB
JavaScript
/*
|
||
* «ДО / ПОСЛЕ» знаков ресурсов (§10.28, канбан t_d3adf730).
|
||
*
|
||
* Состояние «ДО» восстанавливается ОБРАТНЫМ ПАТЧЕМ текущих файлов: все правки волны известны
|
||
* точно (строка → строка), поэтому «до» строится из тех же файлов, что уже лежат в проекте,
|
||
* а не берётся из git (в HEAD знаков ресурсов ещё нет — прошлая волна не закоммичена).
|
||
* Копия сайта кладётся в before-src/ и удаляется после замеров (KEEP=1 оставляет).
|
||
*
|
||
* ЧЕСТНОСТЬ РЕКОНСТРУКЦИИ ПРОВЕРЯЕТСЯ: замер «ДО» должен воспроизвести числа, снятые до правок
|
||
* (ширины кнопок 138.27 / 121.95 / 168.92 / 107.89; слот-бокс знака 16.81×16 и 25.36×16;
|
||
* масса знаков 183.3 / 212.5 / 89.7 / 88.7). Расхождение — провал.
|
||
*
|
||
* Выход: shots/before-after-<ширина>-<тема>.png (полоса «до» над полосой «после»),
|
||
* shots/glyph-grid-<тема>.png (четыре знака слотом, увеличение 6x, ДО и ПОСЛЕ),
|
||
* before-after.json (все замеры), exit 1 при расхождении с ожидаемым «до».
|
||
*
|
||
* Запуск: node design/glyph-slot-2026-10-14/probe-before-after.cjs
|
||
*/
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const { launch } = require('./pw.cjs');
|
||
|
||
const ROOT = path.resolve(__dirname, '..', '..');
|
||
const SRC = path.join(ROOT, 'src');
|
||
const BEFORE = path.join(ROOT, 'src-before-glyphslot'); // рядом с src/, как src-baseline прошлой волны:
|
||
// тогда относительные пути (../Work_files) живут
|
||
const SHOTS = path.join(__dirname, 'shots');
|
||
fs.mkdirSync(SHOTS, { recursive: true });
|
||
|
||
/* ожидаемые числа «ДО» — снятые замером до правок (measure-glyph-mass / measure-containers) */
|
||
const EXPECT_BEFORE = {
|
||
buttons: { 'В RuStore': 138.27, 'Играть': 121.95, 'Сайт проекта': 168.92 }, // «Видео» на странице нет (только стенд)
|
||
slots: { rustore: 16.81, vk: 25.36, site: 16, video: 16 },
|
||
bukvikaRow: 268.22,
|
||
mass16: { rustore: 183.32, vk: 212.47, site: 89.66 } // video — только стенд, в карточках не встречается
|
||
};
|
||
|
||
/* --- обратный патч: строка → строка, каждая замена обязательна --- */
|
||
const HTML_PATCHES = [
|
||
['.btn__icon{display:block;flex:none;width:18px;height:18px}', '.btn__icon{display:block;flex:none;height:18px;width:auto}'],
|
||
['.case-card__link .btn__icon{width:16px;height:16px}', '.case-card__link .btn__icon{height:16px}'],
|
||
['.case-card__links{display:flex;flex-wrap:wrap;gap:6px}', '.case-card__links{display:flex;flex-wrap:wrap;gap:8px}'],
|
||
['.case-card__link{min-height:36px;padding:8px;gap:5px;font-size:11px;letter-spacing:.5px;white-space:nowrap}',
|
||
'.case-card__link{min-height:36px;padding:8px 14px;font-size:12px}'],
|
||
['.quickview__links{display:flex;gap:8px;flex-wrap:wrap}', '.quickview__links{display:flex;gap:12px;flex-wrap:wrap}'],
|
||
[' .quickview__links .btn{padding:12px 16px;gap:5px;font-size:12px;letter-spacing:.5px;white-space:nowrap}\r\n', ''],
|
||
[' .quickview__links .btn{padding:12px 16px;gap:5px;font-size:12px;letter-spacing:.5px;white-space:nowrap}\n', '']
|
||
];
|
||
|
||
function buildBefore() {
|
||
fs.rmSync(BEFORE, { recursive: true, force: true });
|
||
fs.cpSync(SRC, BEFORE, { recursive: true });
|
||
let html = fs.readFileSync(path.join(BEFORE, 'index.html'), 'utf8');
|
||
for (const pair of HTML_PATCHES) {
|
||
if (pair[1] === '' && html.indexOf(pair[0]) === -1) continue; // вариант переноса строки не совпал
|
||
if (html.indexOf(pair[0]) === -1) throw new Error('обратный патч index.html: не найдено «' + pair[0].slice(0, 60) + '…»');
|
||
html = html.replace(pair[0], pair[1]);
|
||
}
|
||
if (/quickview__links \.btn/.test(html)) throw new Error('обратный патч: правило .quickview__links .btn осталось');
|
||
fs.writeFileSync(path.join(BEFORE, 'index.html'), html);
|
||
|
||
let js = fs.readFileSync(path.join(BEFORE, 'js', 'main.js'), 'utf8');
|
||
const before = js;
|
||
js = js.replace(/\n\s*'<g transform="[^"]*">' \+/g, '');
|
||
js = js.replace(/<\/g><\/svg>/g, '</svg>');
|
||
js = js.replace(/(rustore: '<svg class="btn__icon" viewBox=")0 0 24 24(")/, '$114.65 15.95 58.835 55.99$2');
|
||
js = js.replace(/(vk: '<svg class="btn__icon" viewBox=")0 0 24 24(")/, '$13.9 7.15 16.31 10.29$2');
|
||
if (/<g transform=/.test(js) || /<\/g><\/svg>/.test(js)) throw new Error('обратный патч main.js: группы нормализации остались');
|
||
fs.writeFileSync(path.join(BEFORE, 'js', 'main.js'), js);
|
||
fs.writeFileSync(path.join(__dirname, 'before-main.js'), js); // доказательство реконструкции «до»
|
||
return { htmlBytes: before.length !== js.length };
|
||
}
|
||
function dropBefore() { if (process.env.KEEP_BEFORE !== '1') fs.rmSync(BEFORE, { recursive: true, force: true }); }
|
||
|
||
const PROBE_LINKS = `function (sel) {
|
||
const out = [];
|
||
document.querySelectorAll(sel).forEach(function (a) {
|
||
const svg = a.querySelector('svg.btn__icon');
|
||
const r = a.getBoundingClientRect();
|
||
const cs = getComputedStyle(a);
|
||
out.push({
|
||
label: a.textContent.trim(),
|
||
w: +r.width.toFixed(2), h: +r.height.toFixed(2),
|
||
fontSize: parseFloat(cs.fontSize), letterSpacing: cs.letterSpacing, pad: cs.padding,
|
||
iconW: svg ? +svg.getBoundingClientRect().width.toFixed(2) : 0,
|
||
iconH: svg ? +svg.getBoundingClientRect().height.toFixed(2) : 0
|
||
});
|
||
});
|
||
return out;
|
||
}`;
|
||
|
||
const PROBE_ROW = `function (sel) {
|
||
const box = document.querySelector(sel);
|
||
if (!box) return null;
|
||
const rs = Array.from(box.children).map(function (k) { return k.getBoundingClientRect(); });
|
||
const gap = parseFloat(getComputedStyle(box).gap) || 0;
|
||
const bb = box.getBoundingClientRect();
|
||
return {
|
||
n: rs.length, containerW: +bb.width.toFixed(2),
|
||
rowW: +(rs.reduce(function (s, k) { return s + k.width; }, 0) + gap * (rs.length - 1)).toFixed(2),
|
||
lines: new Set(rs.map(function (k) { return Math.round(k.top); })).size
|
||
};
|
||
}`;
|
||
|
||
const PROBE_MASS = `async function (sel, S) {
|
||
const svg = document.querySelector(sel);
|
||
const r = svg.getBoundingClientRect();
|
||
const W = +r.width.toFixed(2), H = +r.height.toFixed(2); // реальный бокс знака, не слот
|
||
const clone = svg.cloneNode(true);
|
||
clone.setAttribute('style', 'display:block;width:' + W + 'px;height:' + H + 'px');
|
||
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(clone))));
|
||
const SCALE = 24, px = Math.round(W * SCALE), py = Math.round(H * SCALE);
|
||
const img = new Image();
|
||
await new Promise(function (res, rej) { img.onload = res; img.onerror = rej; img.src = url; });
|
||
const c = document.createElement('canvas'); c.width = px; c.height = py;
|
||
const ctx = c.getContext('2d'); ctx.drawImage(img, 0, 0, px, py);
|
||
const d = ctx.getImageData(0, 0, px, py).data;
|
||
let sum = 0, minX = 1e9, minY = 1e9, maxX = -1, maxY = -1;
|
||
for (let y = 0; y < py; y++) for (let x = 0; x < px; x++) {
|
||
const a = d[(y * px + x) * 4 + 3]; if (a === 0) continue;
|
||
sum += a / 255;
|
||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||
}
|
||
const u = 1 / SCALE;
|
||
return { mass: +(sum * u * u).toFixed(2), box: [W, H], inkW: +((maxX - minX + 1) * u).toFixed(2), inkh: +((maxY - minY + 1) * u).toFixed(2) };
|
||
}`;
|
||
|
||
/* Слот-сетка: четыре знака на одном размере, увеличение 6x — стенд для «до/после» */
|
||
const gridPage = (label, icons, slot, themes) => '<!doctype html><meta charset="utf-8">' +
|
||
'<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">' +
|
||
'<style>body{margin:0;padding:18px 22px;background:' + themes.bg + ';color:' + themes.fg + ';font-family:Montserrat,sans-serif}' +
|
||
'.cap{font-size:11px;letter-spacing:1px;text-transform:uppercase;font-weight:700;color:' + themes.mute + ';margin:0 0 10px}' +
|
||
'.grid{display:flex;gap:22px}' +
|
||
'.cell{display:flex;flex-direction:column;align-items:center;gap:6px;font-size:10px;letter-spacing:1px;text-transform:uppercase;color:' + themes.mute + '}' +
|
||
'.box{width:' + (slot * 6) + 'px;height:' + (slot * 6) + 'px;display:flex;align-items:center;justify-content:center;background:' + themes.card + ';border:1px dashed ' + themes.line + ';border-radius:10px;overflow:hidden}' +
|
||
'.box svg{transform:scale(6);transform-origin:center}' +
|
||
'.mass{font-size:10px;letter-spacing:.5px;color:' + themes.fg + '}' +
|
||
'</style><body><p class="cap">' + label + ' — слот ' + slot + '×' + slot + ' px, увеличение 6x (масса в px²)</p><div class="grid">' +
|
||
icons.map((ic) => '<div class="cell"><div class="box">' + ic.svg.replace(/class="btn__icon"/, 'class="btn__icon" style="width:' + slot + 'px;height:' + slot + 'px"') +
|
||
'</div><span>' + ic.name + '</span><span class="mass">' + ic.mass.toFixed(1) + '</span></div>').join('') +
|
||
'</div></body>';
|
||
|
||
(async () => {
|
||
const info = buildBefore();
|
||
const browser = await launch();
|
||
const out = { info, before: {}, after: {}, fails: [] };
|
||
|
||
const run = async (dir, tag, slot) => {
|
||
const res = { card: {}, window: {}, rows: {}, masses: {}, grid: [] };
|
||
for (const vp of [{ w: 1440, h: 900 }, { w: 390, h: 844 }]) {
|
||
for (const theme of ['light', 'dark']) {
|
||
const ctx = await browser.newContext({ viewport: { width: vp.w, height: vp.h }, deviceScaleFactor: 3 });
|
||
const page = await ctx.newPage();
|
||
await page.goto('http://127.0.0.1:8765/' + dir + '/', { waitUntil: 'load' });
|
||
await page.waitForTimeout(500);
|
||
if (theme === 'dark') {
|
||
if (vp.w > 767) await page.click('#theme-toggle');
|
||
else {
|
||
await page.click('.nav-toggle'); await page.waitForTimeout(250);
|
||
await page.click('#theme-toggle-panel'); await page.waitForTimeout(250);
|
||
await page.click('.nav-toggle');
|
||
}
|
||
await page.waitForTimeout(400);
|
||
}
|
||
const key = vp.w + '-' + theme;
|
||
/* превью должны снимать ОТГРУЖЕННОЕ состояние, а не кадр reveal-анимации:
|
||
.reveal{opacity:0} до появления .is-visible — на медленном кадре карточка пустая */
|
||
await page.addStyleTag({ content: '.reveal{opacity:1!important;translate:none!important;transition:none!important}' +
|
||
'*{transition:none!important;animation:none!important}' });
|
||
await page.evaluate(() => document.querySelectorAll('.reveal').forEach((e) => e.classList.add('is-visible')));
|
||
await page.waitForTimeout(120);
|
||
for (const slug of ['bukvika', 'associations', 'first-step-radio']) {
|
||
await page.locator('.case-card[data-slug="' + slug + '"]').scrollIntoViewIfNeeded();
|
||
await page.waitForTimeout(220);
|
||
const cardSel = '.case-card[data-slug="' + slug + '"]';
|
||
const links = await page.evaluate('(' + PROBE_LINKS + ')(' + JSON.stringify(cardSel + ' .case-card__links a') + ')');
|
||
const row = await page.evaluate('(' + PROBE_ROW + ')(' + JSON.stringify(cardSel + ' .case-card__links') + ')');
|
||
res.card[slug + '@' + key] = { links, row };
|
||
if (key === '1440-light') res.rows[slug] = row;
|
||
if (key === '1440-light') {
|
||
for (let i = 0; i < links.length; i++) {
|
||
const m = await page.evaluate('(async function(s,S){ return (' + PROBE_MASS + ')(s,S); })(' +
|
||
JSON.stringify(cardSel + ' .case-card__links a:nth-child(' + (i + 1) + ') svg.btn__icon') + ', ' + slot + ')');
|
||
res.masses[links[i].label] = m;
|
||
}
|
||
}
|
||
if (key === '1440-light' || key === '1440-dark') {
|
||
await page.locator('.case-card[data-slug="' + slug + '"] .case-card__links')
|
||
.screenshot({ path: path.join(SHOTS, 'ba-' + tag + '-card-' + slug + '-' + key + '.png') });
|
||
}
|
||
}
|
||
await page.locator('.case-card[data-slug="first-step-radio"] .case-card__more').click();
|
||
await page.waitForTimeout(420);
|
||
const win = await page.evaluate('(' + PROBE_LINKS + ')("#quickview .quickview__links a")');
|
||
const rowW = await page.evaluate('(' + PROBE_ROW + ')("#quickview .quickview__links")');
|
||
res.window['fsr@' + key] = { links: win, row: rowW };
|
||
await page.locator('#quickview .quickview__links').screenshot({ path: path.join(SHOTS, 'ba-' + tag + '-window-' + key + '.png') });
|
||
if (tag === 'before' && key === '1440-light') {
|
||
res.masses['окно:Сайт проекта'] = await page.evaluate('(async function(s,S){ return (' + PROBE_MASS + ')(s,S); })("#quickview .quickview__links a:nth-child(1) svg.btn__icon", 18)');
|
||
res.masses['окно:В RuStore'] = await page.evaluate('(async function(s,S){ return (' + PROBE_MASS + ')(s,S); })("#quickview .quickview__links a:nth-child(2) svg.btn__icon", 18)');
|
||
}
|
||
await page.evaluate(() => document.querySelector('#qv-close').click());
|
||
await page.waitForTimeout(200);
|
||
|
||
/* полоса «до/после» для отчёта: ряд ссылок карточки + ряд окна, снятые вместе */
|
||
if (key === '1440-light' || key === '1440-dark') {
|
||
await page.locator('.case-card[data-slug="bukvika"] .case-card__links').screenshot({ path: path.join(SHOTS, 'ba-' + tag + '-strip1-' + key + '.png') });
|
||
}
|
||
await ctx.close();
|
||
}
|
||
}
|
||
return res;
|
||
};
|
||
|
||
out.before = await run('src-before-glyphslot', 'before', 16);
|
||
out.after = await run('src', 'after', 16);
|
||
|
||
/* --- проверка честности «до»: числа должны совпасть с замером до правок --- */
|
||
const beforeNames = {};
|
||
for (const key of Object.keys(out.before.card)) {
|
||
if (!/@1440-light$/.test(key)) continue;
|
||
out.before.card[key].links.forEach((l) => { beforeNames[l.label] = l; });
|
||
}
|
||
for (const [label, exp] of Object.entries(EXPECT_BEFORE.buttons)) {
|
||
const l = beforeNames[label];
|
||
if (!l) { out.fails.push('«до»: кнопки «' + label + '» на странице нет (ожидалась)'); continue; }
|
||
if (Math.abs(l.w - exp) > 0.02) out.fails.push('«до»: ширина «' + label + '» = ' + l.w + ', ожидалось ' + exp);
|
||
}
|
||
const vkBefore = beforeNames['Играть'];
|
||
if (vkBefore && Math.abs(vkBefore.iconW - EXPECT_BEFORE.slots.vk) > 0.05) out.fails.push('«до»: бокс знака VK ' + vkBefore.iconW + ', ожидалось ' + EXPECT_BEFORE.slots.vk + ' (знак не восстановлен)');
|
||
const rsBefore = beforeNames['В RuStore'];
|
||
if (rsBefore && Math.abs(rsBefore.iconW - EXPECT_BEFORE.slots.rustore) > 0.05) out.fails.push('«до»: бокс знака RuStore ' + rsBefore.iconW + ', ожидалось ' + EXPECT_BEFORE.slots.rustore);
|
||
const bukRowBefore = out.before.rows.bukvika;
|
||
if (Math.abs(bukRowBefore.rowW - EXPECT_BEFORE.bukvikaRow) > 0.05) out.fails.push('«до»: ряд Буквики ' + bukRowBefore.rowW + ', ожидалось ' + EXPECT_BEFORE.bukvikaRow);
|
||
if (bukRowBefore.lines !== 2) out.fails.push('«до»: ряд Буквики в одну строку — ожидался перенос (2 строки)');
|
||
for (const [k, v] of Object.entries(EXPECT_BEFORE.mass16)) {
|
||
const label = { rustore: 'В RuStore', vk: 'Играть', site: 'Сайт проекта' }[k];
|
||
const got = out.before.masses[label];
|
||
if (!got) { out.fails.push('«до»: масса «' + label + '» не замерена'); continue; }
|
||
/* допуск 3%: прежний замер растрировал знак боксом из чернильного bbox (VK 25.62×16),
|
||
живой элемент имеет бокс из пропорции viewBox (25.36×16) — масса отличается на ~1% */
|
||
if (Math.abs(got.mass - v) > v * 0.03) out.fails.push('«до»: масса «' + label + '» = ' + got.mass + ', ожидалось ' + v + ' (±3%)');
|
||
}
|
||
|
||
/* --- сводка --- */
|
||
const massRow = (set) => Object.entries(set).filter(([k]) => !/окно/.test(k)).map(([k, v]) => k + ' ' + v.mass.toFixed(1));
|
||
const spread = (set) => {
|
||
const v = Object.entries(set).filter(([k]) => !/окно/.test(k)).map(([, x]) => x.mass);
|
||
return +(Math.max.apply(null, v) / Math.min.apply(null, v)).toFixed(3);
|
||
};
|
||
out.summary = {
|
||
massBefore: massRow(out.before.masses), massAfter: massRow(out.after.masses),
|
||
spreadBefore: spread(out.before.masses), spreadAfter: spread(out.after.masses),
|
||
rowsBefore: Object.fromEntries(Object.entries(out.before.rows).map(([k, v]) => [k, v.rowW + ' / ' + v.containerW + ' px, строк: ' + v.lines])),
|
||
rowsAfter: Object.fromEntries(Object.entries(out.after.rows).map(([k, v]) => [k, v.rowW + ' / ' + v.containerW + ' px, строк: ' + v.lines]))
|
||
};
|
||
|
||
/* --- сетка «четыре знака в одном размере», 6x: марка знаков берётся из обоих main.js --- */
|
||
const iconsFromMainJs = (file) => {
|
||
const block = fs.readFileSync(file, 'utf8').match(/var LINK_ICONS = \{[\s\S]*?\n \};/);
|
||
return eval('(function(){' + block[0] + ' return LINK_ICONS;})()');
|
||
};
|
||
const beforeIcons = iconsFromMainJs(path.join(__dirname, 'before-main.js'));
|
||
const afterIcons = iconsFromMainJs(path.join(ROOT, 'src', 'js', 'main.js'));
|
||
|
||
const gridBrowserPage = await browser.newPage({ viewport: { width: 900, height: 700 }, deviceScaleFactor: 3 });
|
||
const measureMass = async (svg, W, H) => gridBrowserPage.evaluate(async ([s, W, H]) => {
|
||
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(s)));
|
||
const img = new Image();
|
||
await new Promise((res, rej) => { img.onload = res; img.onerror = rej; img.src = url; });
|
||
const SCALE = 24, px = Math.round(W * SCALE), py = Math.round(H * SCALE);
|
||
const c = document.createElement('canvas'); c.width = px; c.height = py;
|
||
const ctx = c.getContext('2d'); ctx.drawImage(img, 0, 0, px, py);
|
||
const d = ctx.getImageData(0, 0, px, py).data;
|
||
let sum = 0, minX = 1e9, minY = 1e9, maxX = -1, maxY = -1;
|
||
for (let y = 0; y < py; y++) for (let x = 0; x < px; x++) {
|
||
const a = d[(y * px + x) * 4 + 3]; if (a === 0) continue;
|
||
sum += a / 255;
|
||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||
}
|
||
const u = 1 / SCALE;
|
||
return { mass: +(sum * u * u).toFixed(2), inkW: +((maxX - minX + 1) * u).toFixed(2), inkh: +((maxY - minY + 1) * u).toFixed(2) };
|
||
}, [svg.replace(/style="[^"]*"/, '').replace('<svg ', '<svg xmlns="http://www.w3.org/2000/svg" style="display:block;width:' + W + 'px;height:' + H + 'px" '), W, H]);
|
||
|
||
/* реальные боксы знаков: «до» — из живого замера (у VK и RuStore бокс шире квадрата), «после» — слот 16×16.
|
||
Видео в карточках не встречается — бокс считается по геометрии (viewBox 24×24, height 16). */
|
||
const boxes = {
|
||
before: {
|
||
rustore: (out.before.masses['В RuStore'] || {}).box || [16.81, 16],
|
||
vk: (out.before.masses['Играть'] || {}).box || [25.36, 16],
|
||
site: (out.before.masses['Сайт проекта'] || {}).box || [16, 16],
|
||
video: [16, 16]
|
||
},
|
||
after: { rustore: [16, 16], vk: [16, 16], site: [16, 16], video: [16, 16] }
|
||
};
|
||
|
||
const gridData = {};
|
||
for (const [state, set] of [['before', beforeIcons], ['after', afterIcons]]) {
|
||
gridData[state] = [];
|
||
for (const k of ['rustore', 'vk', 'site', 'video']) {
|
||
const b = boxes[state][k];
|
||
const m = await measureMass(set[k], b[0], b[1]);
|
||
gridData[state].push({ name: k, svg: set[k], box: b, mass: m.mass, inkW: m.inkW, inkh: m.inkh });
|
||
}
|
||
}
|
||
out.grid = gridData;
|
||
for (const theme of ['light', 'dark']) {
|
||
const pal = theme === 'light'
|
||
? { bg: '#F5EEE2', card: '#FFFCF7', line: '#847863', fg: '#211E18', mute: '#6A6453' }
|
||
: { bg: '#181109', card: '#1F160D', line: '#A28B6E', fg: '#F8F2E7', mute: '#AA9679' };
|
||
const html = '<!doctype html><meta charset="utf-8">' +
|
||
'<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">' +
|
||
'<style>body{margin:0;padding:20px 24px;background:' + pal.bg + ';color:' + pal.fg + ';font-family:Montserrat,sans-serif}' +
|
||
'h2{font-size:12px;letter-spacing:1px;text-transform:uppercase;font-weight:700;color:' + pal.mute + ';margin:0 0 10px}' +
|
||
'section{margin:0 0 22px}.grid{display:flex;gap:20px}' +
|
||
'.cell{display:flex;flex-direction:column;align-items:center;gap:4px;font-size:10px;letter-spacing:1px;text-transform:uppercase;color:' + pal.mute + '}' +
|
||
'.box{width:170px;height:110px;display:flex;align-items:center;justify-content:center;background:' + pal.card + ';border:1px dashed ' + pal.line + ';border-radius:10px;overflow:hidden}' +
|
||
'.box svg{transform:scale(6);transform-origin:center;flex:none}' +
|
||
'.mass{color:' + pal.fg + ';font-size:10px;letter-spacing:.5px;text-transform:none}' +
|
||
'</style><body>' +
|
||
[['ДО — отгружено (height 16 px, width:auto)', gridData.before], ['ПОСЛЕ — единый слот 16×16', gridData.after]]
|
||
.map(([label, set]) => '<section><h2>' + label + '</h2><div class="grid">' + set.map((ic) =>
|
||
'<div class="cell"><div class="box">' + ic.svg.replace('<svg ', '<svg style="display:block;width:' + ic.box[0] + 'px;height:' + ic.box[1] + 'px" ') +
|
||
'</div><span>' + ic.name + '</span><span class="mass">бокс ' + ic.box[0] + '×' + ic.box[1] + ' · чернила ' + ic.inkW + '×' + ic.inkh + ' · масса ' + ic.mass.toFixed(1) + ' px²</span></div>').join('') +
|
||
'</div></section>').join('') + '</body>';
|
||
await gridBrowserPage.setContent(html, { waitUntil: 'networkidle' });
|
||
await gridBrowserPage.waitForTimeout(300);
|
||
await gridBrowserPage.screenshot({ path: path.join(SHOTS, 'glyph-grid-' + theme + '.png'), fullPage: true });
|
||
}
|
||
await gridBrowserPage.close();
|
||
|
||
fs.writeFileSync(path.join(__dirname, 'before-after.json'), JSON.stringify(out, null, 2) + '\n');
|
||
console.log('разброс массы ДО:', out.summary.spreadBefore, ' ПОСЛЕ:', out.summary.spreadAfter);
|
||
console.log('ряды ДО:', JSON.stringify(out.summary.rowsBefore));
|
||
console.log('ряды ПОСЛЕ:', JSON.stringify(out.summary.rowsAfter));
|
||
console.log('масса ДО:', out.summary.massBefore.join(' · '));
|
||
console.log('масса ПОСЛЕ:', out.summary.massAfter.join(' · '));
|
||
out.fails.forEach((f) => console.log('FAIL:', f));
|
||
await browser.close();
|
||
dropBefore();
|
||
console.log(out.fails.length ? 'Exit 1' : 'Exit 0');
|
||
process.exit(out.fails.length ? 1 : 0);
|
||
})();
|