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.
424 lines
28 KiB
JavaScript
424 lines
28 KiB
JavaScript
/* Живая проверка официальных знаков VK и RuStore (§10.28; канбан t_ecca48e2).
|
||
*
|
||
* Проверяет замером, а не описанием:
|
||
* 1. ОФИЦИАЛЬНОСТЬ: в разметке лежат дословные пути официальных файлов и родные цвета
|
||
* (#0077FF + white), а не силуэт в currentColor; знак не обрезан (чернила = весь квадрат).
|
||
* 2. СЛОТ И ГАБАРИТ: viewBox 0 0 24 24, слот 20×20 (карточка) / 24×24 (окно),
|
||
* чернила знаков 15 px / 18 px; штриховые знаки (глобус/камера) не сдвинулись.
|
||
* 3. ТЕМА И ТОЧКА: обе темы × две точки × 1440/390 — слот, фон, контраст.
|
||
* 4. a11y: icon-only ссылка, имя в aria-label+title, знак aria-hidden/focusable=false,
|
||
* hit-area ≥ 24×24, видимое фокус-кольцо, контраст нетекстовой графики ≥ 3:1 (SC 1.4.11),
|
||
* контраст белого символа к синему квадрату ≥ 3:1.
|
||
* 5. ОХРАННОЕ ПОЛЕ RuStore (брендбук с. 5): свободное пространство ≥ половины высоты знака.
|
||
* 6. ГИГИЕНА: ноль новых сетевых запросов против копии `git show HEAD:src/*`, ноль JS-ошибок,
|
||
* знаки инлайновые (нет img/use/image/внешних файлов).
|
||
*
|
||
* Запуск: node design/brand-marks-2026-10-14/verify-marks.cjs (dev-server 127.0.0.1:8765)
|
||
* Exit 0 = все проверки прошли. Протокол — verify-2026-10-14.md, снимки — shots/.
|
||
*/
|
||
/* ⚠️ ИСТОРИЧЕСКИЙ ЗАМЕР ВОЛНЫ `t_ecca48e2` (2026-10-14). Ожидания этого прогона — слот 20×20 (карточка) /
|
||
* 24×24 (окно) и чернила 15 / 18 px при `L = 18`. Позже отгружено другое состояние (`t_a33fce2f`: кнопка 48×48
|
||
* в обеих точках, знак заполняет слот, чернила 24×24 px, `L = 12`, рамки у знака площадки нет), поэтому на живом
|
||
* DOM этот скрипт даст провалы. Он оставлен как запись волны; действующая проверка —
|
||
* `design/link-slot-2026-10-14/verify-link-slot.cjs`. Ради истории и сверки: HISTORICAL=1 node <этот файл>.
|
||
*/
|
||
if (process.env.HISTORICAL !== '1') {
|
||
console.log('исторический замер волны t_ecca48e2 (слот 20/24, чернила 15/18 px) — номер протокола: verify-2026-10-14.md');
|
||
console.log('актуальная проверка ссылок: node design/link-slot-2026-10-14/verify-link-slot.cjs');
|
||
console.log('запуск этой записи как есть: HISTORICAL=1 node design/brand-marks-2026-10-14/verify-marks.cjs');
|
||
process.exit(0);
|
||
}
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const { execSync } = require('child_process');
|
||
const { launch } = require('./pw.cjs');
|
||
|
||
const BASE = process.env.PAGE_URL || 'http://127.0.0.1:8765';
|
||
const ROOT = path.resolve(__dirname, '..', '..');
|
||
const SHOTS = path.join(__dirname, 'shots');
|
||
fs.mkdirSync(SHOTS, { recursive: true });
|
||
const REPORT = path.join(__dirname, 'verify-2026-10-14.md');
|
||
|
||
const FAILS = [], L = [];
|
||
const w = (s = '') => { L.push(s); console.log(s); };
|
||
|
||
/* ---------- эталоны ---------- */
|
||
const official = JSON.parse(fs.readFileSync(path.join(__dirname, 'official-marks.json'), 'utf8'));
|
||
const mainSrc = fs.readFileSync(path.join(ROOT, 'src', 'js', 'main.js'), 'utf8');
|
||
/* пути берём из официальных файлов: сверяем, что они целиком лежат в разметке */
|
||
function officialPaths(rel) {
|
||
const s = fs.readFileSync(path.join(__dirname, 'assets', rel), 'utf8');
|
||
return (s.match(/<path[^>]*>/g) || []).map((p) => ({
|
||
d: p.match(/ d="([^"]+)"/)[1], fill: p.match(/ fill="([^"]+)"/)[1]
|
||
}));
|
||
}
|
||
const OFFICIAL = {
|
||
vk: officialPaths('vk/VK Logo.svg'),
|
||
rustore: officialPaths('rustore/RuStore_Icon (2).svg')
|
||
};
|
||
|
||
/* контраст цвета к цвету; фон может быть полупрозрачным — композит по подложке */
|
||
const rgbOf = (s) => { const m = (s.match(/[\d.]+/g) || [0, 0, 0]).map(Number); return m.slice(0, 3); };
|
||
const alphaOf = (s) => { const m = (s.match(/[\d.]+/g) || []); return m.length > 3 ? Number(m[3]) : 1; };
|
||
const lum = (c) => c.map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); })
|
||
.reduce((s, v, i) => s + v * [0.2126, 0.7152, 0.0722][i], 0);
|
||
const cr = (a, b) => { const l1 = lum(a), l2 = lum(b); return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05); };
|
||
const over = (fg, alpha, bg) => fg.map((v, i) => v * alpha + bg[i] * (1 - alpha));
|
||
const BLUE = [0, 119, 255], WHITE = [255, 255, 255];
|
||
|
||
/* ---------- страничные замеры ---------- */
|
||
const LINKS = `function (sel) {
|
||
const out = [];
|
||
document.querySelectorAll(sel).forEach(function (a) {
|
||
const svg = a.querySelector('svg.btn__icon');
|
||
const r = a.getBoundingClientRect(), sr = svg.getBoundingClientRect();
|
||
const paths = svg.querySelectorAll('path');
|
||
let bgEl = a, bg = 'rgba(0, 0, 0, 0)', bgChain = [];
|
||
while (bgEl && bgEl !== document.documentElement) {
|
||
const c = getComputedStyle(bgEl).backgroundColor;
|
||
bgChain.push({ el: bgEl.tagName + '.' + String(bgEl.className).split(' ')[0], bg: c });
|
||
if (bg === 'rgba(0, 0, 0, 0)' && c !== 'rgba(0, 0, 0, 0)') bg = c;
|
||
bgEl = bgEl.parentElement;
|
||
}
|
||
if (bg === 'rgba(0, 0, 0, 0)') bg = getComputedStyle(document.body).backgroundColor;
|
||
const g = svg.querySelector('g');
|
||
out.push({
|
||
href: a.getAttribute('href'), ariaLabel: a.getAttribute('aria-label'), title: a.getAttribute('title'),
|
||
cls: a.className, text: a.textContent.trim(),
|
||
w: +r.width.toFixed(2), h: +r.height.toFixed(2), slotW: +sr.width.toFixed(2), slotH: +sr.height.toFixed(2),
|
||
viewBox: svg.getAttribute('viewBox'), ariaHidden: svg.getAttribute('aria-hidden'), focusable: svg.getAttribute('focusable'),
|
||
transform: g ? g.getAttribute('transform') : null,
|
||
fills: Array.from(paths).map(function (p) { return p.getAttribute('fill'); }),
|
||
paths: Array.from(paths).map(function (p) { return { d: p.getAttribute('d'), fill: p.getAttribute('fill') }; }),
|
||
hasImg: a.querySelectorAll('img, use, image').length,
|
||
bg: bg, bgChain: bgChain,
|
||
outlineW: getComputedStyle(a).outlineWidth, outlineStyle: getComputedStyle(a).outlineStyle,
|
||
outlineOffset: getComputedStyle(a).outlineOffset, color: getComputedStyle(a).color
|
||
});
|
||
});
|
||
return out;
|
||
}`;
|
||
|
||
const INK = `async function (o) {
|
||
const { sel, S } = o;
|
||
const svg = document.querySelector(sel).cloneNode(true);
|
||
svg.setAttribute('style', 'display:block;width:' + S + 'px;height:' + S + 'px');
|
||
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(svg))));
|
||
const SCALE = 24, px = Math.round(S * 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 = c.height = px;
|
||
const ctx = c.getContext('2d'); ctx.drawImage(img, 0, 0, px, px);
|
||
const d = ctx.getImageData(0, 0, px, px).data;
|
||
let sum = 0, minX = 1e9, minY = 1e9, maxX = -1, maxY = -1;
|
||
for (let y = 0; y < px; y++) for (let x = 0; x < px; x++) {
|
||
const i = (y * px + x) * 4, al = d[i + 3];
|
||
if (al === 0) continue;
|
||
sum += al / 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),
|
||
air: { l: +(minX * u).toFixed(2), t: +(minY * u).toFixed(2) } };
|
||
}`;
|
||
|
||
/* ---------- сетевой дифф против отгруженной копии ---------- */
|
||
function ensureBaseline() {
|
||
const dir = path.join(ROOT, 'src-baseline-brandmarks');
|
||
if (fs.existsSync(path.join(dir, 'index.html'))) return dir;
|
||
fs.mkdirSync(path.join(dir, 'js'), { recursive: true });
|
||
fs.mkdirSync(path.join(dir, 'data'), { recursive: true });
|
||
const git = (spec, out) => fs.writeFileSync(out,
|
||
execSync('git show ' + spec, { cwd: ROOT, encoding: 'buffer' }));
|
||
git('HEAD:src/index.html', path.join(dir, 'index.html'));
|
||
for (const f of ['main.js', 'form.js', 'planet.js']) git('HEAD:src/js/' + f, path.join(dir, 'js', f));
|
||
for (const f of ['projects.js', 'team.js']) git('HEAD:src/data/' + f, path.join(dir, 'data', f));
|
||
return dir;
|
||
}
|
||
async function requests(url) {
|
||
const b = await launch();
|
||
const p = await (await b.newContext({ viewport: { width: 1440, height: 900 } })).newPage();
|
||
const reqs = [];
|
||
p.on('request', (r) => reqs.push(r.url().replace(/^https?:\/\/[^/]+/, '')));
|
||
p.setDefaultNavigationTimeout(60000);
|
||
await p.goto(url, { waitUntil: 'domcontentloaded' });
|
||
await p.waitForTimeout(1200);
|
||
await b.close();
|
||
return Array.from(new Set(reqs));
|
||
}
|
||
|
||
const EXPECT_LINKS = {
|
||
bukvika: ['rustore', 'vk'],
|
||
associations: ['vk'],
|
||
'first-step-radio': ['site', 'rustore']
|
||
};
|
||
const LINE_INK_REF = { site: '12.53', video: '16.25' }; // прошлая волна, слот 20 px
|
||
|
||
(async () => {
|
||
w('# Проверка: официальные знаки VK и RuStore в ссылках проектов (§10.28)');
|
||
w();
|
||
w('Проект: `G:\\Project\\Haevey_Monster_Team_Page` · канбан `t_ecca48e2` · 2026-10-14');
|
||
w('Живая страница `' + BASE + '/src/` · Playwright/Chromium (Chrome 148), замер живого DOM.');
|
||
w();
|
||
|
||
/* ---------- 1. Официальность геометрии (по исходнику + в живом DOM) ---------- */
|
||
w('## 1. Официальность знаков');
|
||
w();
|
||
w('| Знак | Файл-источник | Штрихов | Цвета | Пути в `main.js` дословно |');
|
||
w('|---|---|---|---|---|');
|
||
for (const k of ['vk', 'rustore']) {
|
||
const b = official.brands[k];
|
||
const allIn = OFFICIAL[k].every((p) => mainSrc.includes(p.d));
|
||
w('| `LINK_ICONS.' + k + '` | `' + b.file.split('/').pop() + '` | ' + OFFICIAL[k].length + ' | ' +
|
||
OFFICIAL[k].map((p) => p.fill).join(' + ') + ' | ' + (allIn ? 'да' : '**НЕТ**') + ' |');
|
||
if (!allIn) FAILS.push(k + ': пути официального файла не найдены в main.js дословно');
|
||
}
|
||
/* знак не обрезан: чернила = весь квадрат основания */
|
||
for (const k of ['vk', 'rustore']) {
|
||
const b = official.brands[k];
|
||
const aspect = b.inkAspect;
|
||
w('- `' + k + '`: чернила ' + b.ink.w + '×' + b.ink.h + ' ед., аспект ' + aspect +
|
||
' → основание квадрат 1:1 ' + (Math.abs(aspect - 1) < 0.02 ? 'да' : '**НЕТ**') +
|
||
'; выреза нет — внутренний символ непрозрачный (' + (b.whiteShareOfSilhouette * 100).toFixed(1) + ' % силуэта белёное).');
|
||
if (Math.abs(aspect - 1) >= 0.02) FAILS.push(k + ': чернила не квадрат 1:1 (аспект ' + aspect + ')');
|
||
}
|
||
/* проверка: клип-путь VK на чернила не влияет (в разметке клип снят) */
|
||
{
|
||
const b = await launch(); const p = await (await b.newContext()).newPage();
|
||
await p.setContent('<body style="margin:0"></body>');
|
||
const r = await p.evaluate(async function () {
|
||
const mk = (withClip) => {
|
||
const s = `<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 101 100">` +
|
||
(withClip ? '<g clip-path="url(#c)">' : '') +
|
||
'<path d="M0.5 48C0.5 25.3726 0.5 14.0589 7.52944 7.02944C14.5589 0 25.8726 0 48.5 0H52.5C75.1274 0 86.4411 0 93.4706 7.02944C100.5 14.0589 100.5 25.3726 100.5 48V52C100.5 74.6274 100.5 85.9411 93.4706 92.9706C86.4411 100 75.1274 100 52.5 100H48.5C25.8726 100 14.5589 100 7.52944 92.9706C0.5 85.9411 0.5 74.6274 0.5 52V48Z" fill="#0077FF"/>' +
|
||
(withClip ? '</g><defs><clipPath id="c"><rect width="100" height="100" fill="#fff" transform="translate(0.5)"/></clipPath></defs>' : '') +
|
||
'</svg>';
|
||
return s;
|
||
};
|
||
const mass = async (svg) => {
|
||
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg)));
|
||
const img = new Image();
|
||
await new Promise((res, rej) => { img.onload = res; img.onerror = rej; img.src = url; });
|
||
const c = document.createElement('canvas'); c.width = c.height = 400;
|
||
const ctx = c.getContext('2d'); ctx.drawImage(img, 0, 0, 400, 400);
|
||
const d = ctx.getImageData(0, 0, 400, 400).data; let s = 0;
|
||
for (let i = 3; i < d.length; i += 4) if (d[i]) s += d[i] / 255;
|
||
return s;
|
||
};
|
||
return { withClip: await mass(mk(true)), without: await mass(mk(false)) };
|
||
});
|
||
await b.close();
|
||
w('- клип-путь VK: alpha-площадь с клипом ' + r.withClip + ' / без клипа ' + r.without +
|
||
' → разница ' + (Math.abs(r.withClip - r.without) / r.withClip * 100).toFixed(4) + ' % (клип снят, форма не меняется)');
|
||
if (Math.abs(r.withClip - r.without) / r.withClip > 0.001) FAILS.push('VK: снятие клип-пути меняет форму знака');
|
||
}
|
||
w();
|
||
|
||
/* ---------- 2. Сеть ---------- */
|
||
w('## 2. Сетевые запросы (знаки — инлайновые, CDN нет)');
|
||
w();
|
||
const baseDir = ensureBaseline();
|
||
const nowReq = await requests(BASE + '/src/');
|
||
const baseReq = await requests(BASE + '/src-baseline-brandmarks/');
|
||
if (process.env.KEEP_BASELINE !== '1') fs.rmSync(baseDir, { recursive: true, force: true });
|
||
/* обе страницы отдают один и тот же набор файлов, отличается только корень раздачи */
|
||
const nowU = nowReq.map((u) => u.replace(/^\/src(?=\/)/, ''));
|
||
const baseU = baseReq.map((u) => u.replace(/^\/src-baseline-brandmarks(?=\/)/, ''));
|
||
const added = nowU.filter((u) => !baseU.includes(u));
|
||
const iconish = nowReq.filter((u) => /\.svg(\?|$)/i.test(u) || /icon|awesome|lucide|feather|icomoon/i.test(u));
|
||
w('| Что | Значение |');
|
||
w('|---|---|');
|
||
w('| запросов (после правки) | ' + nowReq.length + ' |');
|
||
w('| запросов (копия `git show HEAD:src/*`) | ' + baseReq.length + ' |');
|
||
w('| добавлено правкой | ' + (added.length ? '**' + added.join(', ') + '**' : 'нет') + ' |');
|
||
w('| иконочных запросов | ' + (iconish.length ? '**' + iconish.join(', ') + '**' : 'нет — знаки инлайновые') + ' |');
|
||
w();
|
||
if (added.length) FAILS.push('новые сетевые запросы: ' + added.length + ' шт., первые: ' + added.slice(0, 5).join(', '));
|
||
if (iconish.length) FAILS.push('иконочный сетевой запрос: ' + iconish.join(', '));
|
||
|
||
/* ---------- 3..5. Живой DOM: обе темы × две точки × 1440/390 ---------- */
|
||
const browser = await launch();
|
||
w('## 3. Живой DOM: слот, габарит, контраст, a11y');
|
||
w();
|
||
const summary = [];
|
||
|
||
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: 4 });
|
||
const page = await ctx.newPage();
|
||
const errs = [];
|
||
page.on('pageerror', (e) => errs.push(String(e)));
|
||
page.on('console', (m) => { if (m.type() === 'error' && !/Failed to load resource/i.test(m.text())) errs.push(m.text()); });
|
||
page.setDefaultNavigationTimeout(60000);
|
||
await page.goto(BASE + '/src/', { waitUntil: 'domcontentloaded' });
|
||
await page.waitForTimeout(400);
|
||
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 got = await page.evaluate(() => document.documentElement.getAttribute('data-theme') || 'light');
|
||
if (got !== theme) FAILS.push(vp.w + '/' + theme + ': тема не переключилась');
|
||
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(150);
|
||
|
||
const tag = vp.w + 'px · ' + theme;
|
||
w('### ' + tag);
|
||
w();
|
||
w('| Точка | Ссылка | Кнопка | Слот | Чернила | Масса | Знак vs подложка | Белый vs синий | Охранное поле |');
|
||
w('|---|---|---|---|---|---|---|---|---|');
|
||
|
||
for (const [slug, kinds] of Object.entries(EXPECT_LINKS)) {
|
||
const sel = '.case-card[data-slug="' + slug + '"] .case-card__links a';
|
||
await page.locator('.case-card[data-slug="' + slug + '"]').scrollIntoViewIfNeeded();
|
||
await page.waitForTimeout(200);
|
||
const links = await page.evaluate('(' + LINKS + ')(' + JSON.stringify(sel) + ')');
|
||
if (links.length !== kinds.length) { FAILS.push(tag + '/' + slug + ': ссылок ' + links.length + ', ожидалось ' + kinds.length); continue; }
|
||
for (let i = 0; i < links.length; i++) {
|
||
const l = links[i], kind = kinds[i], p = tag + '/' + slug + '[' + i + ']';
|
||
if (l.text !== '') FAILS.push(p + ': в ссылке текст «' + l.text + '» — должна быть только иконка');
|
||
if (!l.ariaLabel || !l.title) FAILS.push(p + ': нет aria-label/title у icon-only ссылки');
|
||
if (l.viewBox !== '0 0 24 24') FAILS.push(p + ': viewBox ' + l.viewBox + ' ≠ «0 0 24 24»');
|
||
if (l.ariaHidden !== 'true' || l.focusable !== 'false') FAILS.push(p + ': знак не aria-hidden/focusable=false');
|
||
if (l.hasImg) FAILS.push(p + ': знак не инлайновый (img/use/image)');
|
||
if (Math.abs(l.slotW - 20) > 0.5 || Math.abs(l.slotH - 20) > 0.5) FAILS.push(p + ': слот ' + l.slotW + '×' + l.slotH + ', ожидался 20×20');
|
||
if (l.w < 24 || l.h < 24) FAILS.push(p + ': hit-area ' + l.w + '×' + l.h + ' < 24×24');
|
||
if (Math.abs(l.h - 36) > 1) FAILS.push(p + ': высота кнопки ' + l.h + ', ожидалось 36');
|
||
if (!/translate\(/.test(l.transform || '') || !/scale\(/.test(l.transform || '')) FAILS.push(p + ': знак не вписан группой translate/scale');
|
||
if (/btn--primary/.test(l.cls) && kind !== 'site' && kind !== 'video') FAILS.push(p + ': официальный знак стоит на зелёной заливке CTA');
|
||
|
||
const ink = await page.evaluate('(async function(o){return (' + INK + ')(o);})(' + JSON.stringify({ sel: sel + ':nth-child(' + (i + 1) + ') svg.btn__icon', S: 20 }) + ')');
|
||
const bg = rgbOf(l.bg);
|
||
const markC = kind === 'rustore' || kind === 'vk' ? cr(BLUE, bg) : cr(rgbOf(l.color), bg);
|
||
const innerC = kind === 'rustore' || kind === 'vk' ? cr(WHITE, BLUE) : null;
|
||
const logoH = ink.inkh;
|
||
const free = (36 - logoH) / 2;
|
||
const clearOk = free >= logoH / 2;
|
||
w('| карточка | `' + kind + '` | ' + l.w + '×' + l.h + ' | ' + l.slotW + '×' + l.slotH + ' | ' + ink.inkW + '×' + ink.inkh +
|
||
' | ' + ink.mass.toFixed(1) + ' | ' + markC.toFixed(2) + ':1' + (markC >= 3 ? '' : ' **<3**') +
|
||
' | ' + (innerC ? innerC.toFixed(2) + ':1' : '—') + ' | ' + free.toFixed(2) + ' px ≥ ' + (logoH / 2).toFixed(2) +
|
||
(clearOk ? ' ✓' : ' **✗**') + ' |');
|
||
|
||
if (kind === 'rustore' || kind === 'vk') {
|
||
if (markC < 3) FAILS.push(p + ': контраст знака к подложке ' + markC.toFixed(2) + ':1 < 3:1');
|
||
if (innerC < 3) FAILS.push(p + ': контраст белого символа к синему квадрату ' + innerC.toFixed(2) + ':1 < 3:1');
|
||
const want = 15, got2 = ink.inkW;
|
||
if (Math.abs(got2 - want) > 0.6) FAILS.push(p + ': чернила знака ' + got2 + ' px, ожидалось ≈' + want);
|
||
if (!clearOk) FAILS.push(p + ': охранное поле RuStore нарушено (' + free.toFixed(2) + ' < ' + (logoH / 2).toFixed(2) + ')');
|
||
const OFF = OFFICIAL[kind];
|
||
OFF.forEach((op) => {
|
||
if (!l.paths.some((pp) => pp.d === op.d)) FAILS.push(p + ': в DOM нет официального пути ' + kind);
|
||
if (!l.paths.some((pp) => pp.fill === op.fill)) FAILS.push(p + ': в DOM нет официального цвета ' + op.fill + ' (' + kind + ')');
|
||
});
|
||
summary.push({ tag, kind, point: 'карточка', ink: ink.inkW, mass: ink.mass, markC: +markC.toFixed(2), innerC: +innerC.toFixed(2), slot: l.slotW });
|
||
} else {
|
||
const f = LINE_INK_REF[kind];
|
||
if (ink.inkW.toFixed(2) !== f && Math.abs(ink.inkW - parseFloat(f)) > 0.6) FAILS.push(p + ': штриховой знак «' + kind + '» сдвинулся (' + ink.inkW + ' px, ждали ' + f + ')');
|
||
}
|
||
}
|
||
}
|
||
w();
|
||
|
||
/* окно проекта: Буквика (RuStore+VK) и First Step Radio (сайт+RuStore) */
|
||
for (const slug of ['first-step-radio', 'bukvika']) {
|
||
await page.evaluate((sl) => {
|
||
const c = document.querySelector('.case-card[data-slug="' + sl + '"]');
|
||
c.querySelector('.case-card__more').click();
|
||
}, slug);
|
||
await page.waitForTimeout(420);
|
||
const win = await page.evaluate('(' + LINKS + ')(\"#quickview .quickview__links a\")');
|
||
for (let i = 0; i < win.length; i++) {
|
||
const l = win[i], p = tag + '/окно:' + slug + '[' + i + ']';
|
||
const kind = /rustore/i.test(l.href) ? 'rustore' : (/vk\./i.test(l.href) ? 'vk' : 'site');
|
||
if (Math.abs(l.slotW - 24) > 0.5) FAILS.push(p + ': слот ' + l.slotW + ', ожидался 24');
|
||
if (l.w < 24 || l.h < 24) FAILS.push(p + ': hit-area ' + l.w + '×' + l.h);
|
||
if (Math.abs(l.h - 48) > 1) FAILS.push(p + ': высота ' + l.h + ', ожидалось 48');
|
||
const ink = await page.evaluate('(async function(o){return (' + INK + ')(o);})(' + JSON.stringify({ sel: '#quickview .quickview__links a:nth-child(' + (i + 1) + ') svg.btn__icon', S: 24 }) + ')');
|
||
const bg = rgbOf(l.bg);
|
||
const brand = kind === 'rustore' || kind === 'vk';
|
||
const markC = brand ? cr(BLUE, bg) : cr(rgbOf(l.color), bg);
|
||
const innerC = brand ? cr(WHITE, BLUE) : null;
|
||
const free = (48 - ink.inkh) / 2;
|
||
const clearOk = free >= ink.inkh / 2;
|
||
w('| окно:' + slug + '[' + i + '] | `' + kind + '`' + (/btn--primary/.test(l.cls) ? ' **primary**' : '') + ' | ' + l.w + '×' + l.h +
|
||
' | ' + l.slotW + '×' + l.slotH + ' | ' + ink.inkW + '×' + ink.inkh + ' | ' + ink.mass.toFixed(1) +
|
||
' | ' + markC.toFixed(2) + ':1' + (markC >= 3 ? '' : ' **<3**') + ' | ' + (innerC ? innerC.toFixed(2) + ':1' : '—') + ' | ' + free.toFixed(2) + ' px ✓ |');
|
||
if (brand) {
|
||
if (markC < 3) FAILS.push(p + ': контраст знака к подложке ' + markC.toFixed(2) + ':1 < 3:1');
|
||
if (Math.abs(ink.inkW - 18) > 0.7) FAILS.push(p + ': чернила знака ' + ink.inkW + ' px, ожидалось ≈18');
|
||
if (!clearOk) FAILS.push(p + ': охранное поле RuStore нарушено в окне');
|
||
summary.push({ tag, kind, point: 'окно', ink: ink.inkW, mass: ink.mass, markC: +markC.toFixed(2), innerC: +innerC.toFixed(2), slot: l.slotW });
|
||
}
|
||
}
|
||
await page.evaluate(() => document.querySelector('#qv-close').click());
|
||
await page.waitForTimeout(220);
|
||
}
|
||
w();
|
||
|
||
/* фокус-кольцо + hover-подложка. Фокус ставится ПОСЛЕ клавиатурного ввода: :focus-visible
|
||
не срабатывает при программном фокусе, если последнее действие было мышью (клик темы). */
|
||
await page.keyboard.press('Tab');
|
||
await page.waitForTimeout(80);
|
||
const foc = await page.evaluate(function (sel) {
|
||
const a = document.querySelector(sel);
|
||
if (!a) return null;
|
||
a.focus();
|
||
const cs = getComputedStyle(a);
|
||
return { fv: a.matches(':focus-visible'), w: cs.outlineWidth, s: cs.outlineStyle, o: cs.outlineOffset, c: cs.outlineColor };
|
||
}, '.case-card[data-slug="bukvika"] .case-card__links a');
|
||
w('- :focus-visible на ссылке карточки — ' + (foc && foc.fv ? 'да' : 'НЕТ') + ', кольцо ' + (foc ? foc.w + ' ' + foc.s + ' offset ' + foc.o + ' ' + foc.c : '—'));
|
||
if (!foc || !foc.fv || parseFloat(foc.w) < 2 || foc.s === 'none') FAILS.push(tag + ': нет видимого фокус-кольца');
|
||
|
||
await page.hover('.case-card[data-slug="bukvika"] .case-card__links a');
|
||
await page.waitForTimeout(220);
|
||
const hov = await page.evaluate('(' + LINKS + ')(\".case-card[data-slug=\\\"bukvika\\\"] .case-card__links a\")');
|
||
const hoverBg = rgbOf(hov[0].bg), hoverA = alphaOf(hov[0].bg);
|
||
const cardBg = rgbOf(hov[0].bgChain[hov[0].bgChain.length - 1].bg);
|
||
const flat = over(hoverBg, hoverA, cardBg);
|
||
const hc = cr(BLUE, flat);
|
||
w('- hover-подложка ghost: ' + hov[0].bg + ' поверх ' + hov[0].bgChain[hov[0].bgChain.length - 1].bg +
|
||
' → ' + 'rgb(' + flat.map(Math.round).join(',') + '), контраст знака ' + hc.toFixed(2) + ':1');
|
||
if (hc < 3) FAILS.push(tag + ': контраст знака на hover-подложке ' + hc.toFixed(2) + ':1 < 3:1');
|
||
w();
|
||
|
||
await page.locator('.case-card[data-slug="bukvika"] .case-card__links').screenshot({ path: path.join(SHOTS, 'card-links-' + vp.w + '-' + theme + '.png') });
|
||
await page.locator('.case-card[data-slug="first-step-radio"]').screenshot({ path: path.join(SHOTS, 'card-fsr-' + vp.w + '-' + theme + '.png') });
|
||
errs.forEach((e) => FAILS.push(tag + ': console — ' + e.slice(0, 160)));
|
||
w('- JS-ошибок: ' + errs.length);
|
||
w();
|
||
await ctx.close();
|
||
}
|
||
}
|
||
await browser.close();
|
||
|
||
/* ---------- 5. Масса: почему не выравнивается ---------- */
|
||
w('## 4. Оптическая масса и габарит (замер)');
|
||
w();
|
||
w('| Знак | Чернила, слот 20 px | Масса, ед² | Отношение к штриховым |');
|
||
w('|---|---|---|---|');
|
||
for (const k of ['site', 'video']) {
|
||
const l = official.line_glyphs;
|
||
w('| `' + k + '` (штриховой) | ' + (l.L_units[k] / 24 * 20).toFixed(2) + ' px | ' + l.mass_at_slot24px[k] + ' | 1.00 |');
|
||
}
|
||
for (const k of ['rustore', 'vk']) {
|
||
const b = official.candidates.L18[k];
|
||
w('| `' + k + '` (официальный, L=18) | ' + b.squareCardPx + ' px | ' + b.mass + ' | ' + b.massVsLine + '× |');
|
||
}
|
||
w();
|
||
w('Вывод: официальное основание — плотный квадрат, штриховой знак — контур. Одна полоса массы недостижима:');
|
||
w('при равном габарите квадрат тяжелее в ' + official.candidates.L18.vk.massVsLine + '×, при L=14 (неразличимо) — в ' +
|
||
official.candidates.L14.vk.massVsLine + '×. Выравнивание заменено на паритет ГАБАРИТА: чернила официальных знаков равны чернилам глобуса.');
|
||
w();
|
||
|
||
w('## 5. Итог');
|
||
w();
|
||
w('- Провалено проверок: **' + FAILS.length + '**');
|
||
FAILS.forEach((f) => w(' - FAIL: ' + f));
|
||
w();
|
||
fs.writeFileSync(REPORT, L.join('\n') + '\n', 'utf8');
|
||
console.log('\nпротокол:', path.relative(ROOT, REPORT));
|
||
process.exit(FAILS.length ? 1 : 0);
|
||
})();
|