Files
FastD e352335822 Filter bar with hover layer, icon-only project links, design reports
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.
2026-10-15 05:50:52 +03:00

212 lines
13 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Сравнительный лист кандидатов: официальные знаки VK и RuStore в живом CSS страницы (kanban t_ecca48e2).
*
* Что делает:
* 1) открывает живую страницу (dev-server 127.0.0.1:8765) — оформление берётся НАСТОЯЩЕЕ, не копия;
* 2) вставляет в неё контактный лист: для каждого кандидата L (сторона знака в слоте 24×24 ед.)
* строит кнопки-ссылки реальными классами страницы (.case-card__link 36 px, .quickview__links .btn 48 px,
* ghost и primary) с официальной геометрией VK/RuStore и, для сравнения, со штриховыми знаками (глобус/камера);
* 3) снимает лист при увеличении 8x в светлой и тёмной теме;
* 4) замеряет в живом DOM: слот знака, чернила, массу, контраст знака к подложке и белого символа к синему
* квадрату, hit-area, фокус-кольцо — по каждому кандидату.
*
* Запуск: node design/brand-marks-2026-10-14/probe-candidates.cjs
* Выход: design/brand-marks-2026-10-14/shots/*.png + candidates.json
*/
const fs = require('fs');
const path = require('path');
const { launch } = require('./pw.cjs');
const HERE = __dirname;
const ROOT = path.resolve(HERE, '..', '..');
const BASE = process.env.PAGE_URL || 'http://127.0.0.1:8765';
const SHOTS = path.join(HERE, 'shots');
fs.mkdirSync(SHOTS, { recursive: true });
/* ---------- официальная геометрия: читается из файлов, не переписывается руками ---------- */
function parseSvg(file) {
const s = fs.readFileSync(file, 'utf8');
const root = s.match(/<svg[^>]*>/)[0];
const vb = (root.match(/viewBox="([^"]+)"/) || [])[1].split(/\s+/).map(Number);
return {
viewBox: vb,
paths: (s.match(/<path[^>]*>/g) || []).map((p) => ({
d: (p.match(/ d="([^"]+)"/) || [])[1],
fill: (p.match(/ fill="([^"]+)"/) || [])[1],
evenodd: /fill-rule="evenodd"/.test(p)
}))
};
}
const A = (p) => path.join(HERE, 'assets', p);
const VK = parseSvg(A('vk/VK Logo.svg'));
const RS = parseSvg(A('rustore/RuStore_Icon (2).svg'));
const meta = JSON.parse(fs.readFileSync(path.join(HERE, 'official-marks.json'), 'utf8'));
/* Константы варианта: L — сторона знака в слоте 24×24 ед. (общая для обоих брендов) */
function markOf(g, L) {
const ink = g === VK ? meta.brands.vk.ink : meta.brands.rustore.ink;
const maxSide = Math.max(ink.w, ink.h);
const s = L / maxSide;
const tx = +(12 - (ink.x + ink.w / 2) * s).toFixed(5);
const ty = +(12 - (ink.y + ink.h / 2) * s).toFixed(5);
const body = g.paths.map((p) => '<path d="' + p.d + '" fill="' + p.fill + '"' +
(p.evenodd ? ' fill-rule="evenodd"' : '') + '/>').join('');
return {
tx, ty, s: +s.toFixed(5),
svg: '<svg class="btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">' +
'<g transform="translate(' + tx + ' ' + ty + ') scale(' + s + ')">' + body + '</g></svg>'
};
}
/* Штриховые знаки — как отгружены (контроль: с ними сравнивается «единый размер») */
const LINE = {
site: '<svg class="btn__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><g transform="translate(2.976 2.976) scale(0.752)"><circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><ellipse cx="12" cy="12" rx="4" ry="9"/></g></svg>',
video: '<svg class="btn__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><g transform="translate(1.36364 1.36364) scale(0.88636)"><rect x="2" y="5" width="14" height="14" rx="2.5"/><path d="M16 10.5 22 7v10l-6-3.5z"/></g></svg>'
};
const CAND = process.env.CANDS ? process.env.CANDS.split(',').map(Number) : [21, 20, 18, 16, 24];
/* ---------- замер: слот, чернила, масса, контраст живого DOM ---------- */
const PROBE = `function (sel) {
const a = document.querySelector(sel);
const svg = a.querySelector('svg.btn__icon');
const r = a.getBoundingClientRect(), sr = svg.getBoundingClientRect(), cs = getComputedStyle(a);
let bgEl = a, bg = 'rgba(0, 0, 0, 0)';
while (bgEl && (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent')) { bg = getComputedStyle(bgEl).backgroundColor; bgEl = bgEl.parentElement; }
return { w: +r.width.toFixed(2), h: +r.height.toFixed(2), slot: +sr.width.toFixed(2) + 'x' + +sr.height.toFixed(2),
color: cs.color, bg, border: cs.borderTopColor, outline: cs.outlineWidth + ' ' + cs.outlineStyle + ' ' + cs.outlineOffset };
}`;
const INK = `async function (o) {
const { sel, S } = o;
const svg = document.querySelector(sel);
const clone = svg.cloneNode(true);
clone.setAttribute('style', 'display:block;width:' + S + 'px;height:' + S + 'px');
const str = new XMLSerializer().serializeToString(clone);
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(str)));
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, white = 0;
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;
if (d[i] > 220 && d[i + 1] > 220 && d[i + 2] > 220) white++;
}
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),
whiteMass: +(white * u * u).toFixed(2) };
}`;
/* ---------- контраст (считается здесь, WCAG 2.1) ---------- */
const rgb = (s) => (s.match(/[\d.]+/g) || [0, 0, 0]).slice(0, 3).map(Number);
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 ratio = (a, b) => { const l1 = lum(rgb(a)), l2 = lum(rgb(b)); return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05); };
(async () => {
const browser = await launch();
const out = { candidates: CAND, marks: {}, shots: [] };
for (const theme of ['light', 'dark']) {
const ctx = await browser.newContext({ viewport: { width: 1440, height: 1000 }, deviceScaleFactor: 8 });
const page = await ctx.newPage();
await page.goto(BASE + '/src/', { waitUntil: 'load' });
await page.waitForTimeout(500);
if (theme === 'dark') { await page.click('#theme-toggle'); await page.waitForTimeout(400); }
await page.addStyleTag({ content: '*{transition:none!important;animation:none!important}' });
/* контактный лист: реальные классы страницы, поэтому фон/границы/тени — настоящие */
const rows = CAND.map((L) => {
const rsv = markOf(RS, L).svg, vkv = markOf(VK, L).svg;
const cell = (inner, kind) => {
const cls = kind === 'card' ? 'btn btn--ghost case-card__link' : (kind === 'primary' ? 'btn btn--primary' : 'btn btn--ghost');
return '<span class="' + cls + '" style="display:inline-flex">' + inner + '</span>';
};
const label = '<b style="font:12px/1.4 monospace;min-width:132px">L=' + L + '</b>';
return '<div style="display:flex;gap:14px;align-items:center;margin:0 0 10px">' + label +
'<span style="font:10px monospace;width:64px">карточка</span>' +
cell(rsv, 'card') + cell(vkv, 'card') + cell(LINE.site, 'card') + cell(LINE.video, 'card') +
'<span style="font:10px monospace;width:64px;margin-left:18px">окно</span>' +
cell(rsv, 'win') + cell(vkv, 'win') + cell(LINE.site, 'win') + cell(LINE.video, 'win') +
'<span style="font:10px monospace;width:64px;margin-left:18px">окно primary</span>' +
cell(rsv, 'primary') + cell(vkv, 'primary') +
'</div>';
}).join('');
/* «до»: отгруженные самодельные силуэты */
const shipped = await page.evaluate(() => ({
rustore: document.querySelector('.case-card[data-slug="bukvika"] .case-card__links a svg').outerHTML,
vk: document.querySelectorAll('.case-card[data-slug="bukvika"] .case-card__links a svg')[1].outerHTML
}));
const beforeRow = '<div style="display:flex;gap:14px;align-items:center;margin:0 0 14px;padding-bottom:12px;border-bottom:1px dashed currentColor">' +
'<b style="font:12px/1.4 monospace;min-width:132px">отгружено</b>' +
'<span style="font:10px monospace;width:64px">карточка</span>' +
'<span class="btn btn--ghost case-card__link" style="display:inline-flex">' + shipped.rustore + '</span>' +
'<span class="btn btn--ghost case-card__link" style="display:inline-flex">' + shipped.vk + '</span>' +
'<span class="btn btn--ghost case-card__link" style="display:inline-flex">' + LINE.site + '</span>' +
'<span class="btn btn--ghost case-card__link" style="display:inline-flex">' + LINE.video + '</span>' +
'<span style="font:10px monospace;width:64px;margin-left:18px">окно</span>' +
'<span class="btn btn--ghost quickview__links" style="display:inline-flex;width:48px;min-height:48px;padding:0;justify-content:center">' + shipped.rustore + '</span>' +
'<span class="btn btn--primary" style="display:inline-flex;width:48px;min-height:48px;padding:0;justify-content:center">' + shipped.vk + '</span>' +
'</div>';
await page.evaluate((html) => {
const d = document.createElement('div');
d.id = 'cand-sheet';
d.style.cssText = 'position:fixed;left:0;top:0;z-index:9999;background:var(--card);color:var(--text-1);padding:20px 24px;border:2px solid var(--accent-deep)';
d.innerHTML = html;
document.body.appendChild(d);
}, beforeRow + rows);
await page.waitForTimeout(300);
const sheet = await page.$('#cand-sheet');
const file = path.join(SHOTS, 'candidates-' + theme + '.png');
await sheet.screenshot({ path: file });
out.shots.push(path.relative(ROOT, file).replace(/\\/g, '/'));
/* замеры по каждому кандидату */
for (const L of CAND) {
const rs = markOf(RS, L), vk = markOf(VK, L);
const key = 'L' + L;
out.marks[key] = out.marks[key] || {};
for (const [kind, m] of [['rustore', rs], ['vk', vk]]) {
/* вставляем кандидата в живую карточку Буквики (36 px) и в окно (48 px) */
await page.evaluate((o) => {
const card = document.querySelector('.case-card[data-slug="bukvika"] .case-card__links');
const links = card.querySelectorAll('a');
const target = o.kind === 'rustore' ? links[0] : links[1];
target.querySelector('svg').outerHTML = o.svg;
}, { kind, svg: m.svg });
}
await page.waitForTimeout(120);
const rec = { L, card: [], win: [] };
for (const [i, kind] of [[0, 'rustore'], [1, 'vk']]) {
const sel = '.case-card[data-slug="bukvika"] .case-card__links a:nth-child(' + (i + 1) + ')';
const box = await page.evaluate('(' + PROBE + ')(' + JSON.stringify(sel) + ')');
const ink = await page.evaluate('(async function(o){ return (' + INK + ')(o); })(' + JSON.stringify({ sel: sel + ' svg.btn__icon', S: 20 }) + ')');
rec.card.push({ kind, box, ink, contrast_mark_vs_bg: +ratio('#0077FF', box.bg).toFixed(2),
contrast_white_vs_blue: +ratio('#FFFFFF', '#0077FF').toFixed(2) });
}
out.marks['L' + L].card = rec.card;
out.marks['L' + L].transform = { rustore: { tx: rs.tx, ty: rs.ty, s: rs.s }, vk: { tx: vk.tx, ty: vk.ty, s: vk.s } };
}
await ctx.close();
}
fs.writeFileSync(path.join(HERE, 'candidates.json'), JSON.stringify(out, null, 2) + '\n');
console.log('листы:', out.shots.join(', '));
console.log('=== масса и чернила в карточке (слот 20 px, подложка — карточка) ===');
console.table(Object.entries(out.marks).map(([k, v]) => ({
вариант: k,
'RuStore чернила': v.card[0].ink.inkW + '×' + v.card[0].ink.inkh, 'RuStore масса': v.card[0].ink.mass,
'VK чернила': v.card[1].ink.inkW + '×' + v.card[1].ink.inkh, 'VK масса': v.card[1].ink.mass,
'контраст знак/подложка': v.card[0].contrast_mark_vs_bg, 'белый/синий': v.card[0].contrast_white_vs_blue,
'кнопка': v.card[0].box.w + '×' + v.card[0].box.h, 'слот': v.card[0].box.slot, 'фон': v.card[0].box.bg
})));
await browser.close();
})();