- кегли 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-блок, отчёт, скриншоты, два верификатора
377 lines
19 KiB
Python
377 lines
19 KiB
Python
#!/usr/bin/env python3
|
||
# pen-rebuild.py — перерисовать hero-кадры канона под шкалу v3 (kanban t_508c0d90, 2026-11-16).
|
||
#
|
||
# Вход: канон Harvey_Monster_Team_Page.pen (JSON 2.21) + замеры прода work/pen-geometry.json.
|
||
# Выход: обновлённый канон + снапшот новым файлом (аргумент 2).
|
||
#
|
||
# Правило: тексты, заливки и переменные берутся из существующих узлов канона и НЕ переписываются.
|
||
# Меняются только геометрия, кегли/интерлиньяж/трекинг, зазоры, отступы и структура строки 3
|
||
# (плашки друг над другом, на всю ширину 1200). Все числа — замер прода (headless Chromium 1223).
|
||
import json, copy, sys
|
||
|
||
CANON = sys.argv[1]
|
||
SNAP = sys.argv[2] if len(sys.argv) > 2 else None
|
||
d = json.load(open(CANON, encoding='utf-8'))
|
||
|
||
HEAD, BODY = "$font-heading", "$font-body"
|
||
|
||
|
||
# ---------- утилиты ----------
|
||
def find(n, nid):
|
||
if n.get('id') == nid:
|
||
return n
|
||
for c in n.get('children', []):
|
||
r = find(c, nid)
|
||
if r:
|
||
return r
|
||
return None
|
||
|
||
|
||
def walk(n, out=None):
|
||
out = [] if out is None else out
|
||
out.append(n)
|
||
for c in n.get('children', []):
|
||
walk(c, out)
|
||
return out
|
||
|
||
|
||
def by_name(n, name):
|
||
return [x for x in walk(n) if x.get('name') == name]
|
||
|
||
|
||
class Minter:
|
||
def __init__(self, prefix):
|
||
self.p = prefix
|
||
self.n = 0
|
||
|
||
def __call__(self, _role=''):
|
||
self.n += 1
|
||
return f"{self.p}{self.n:03d}"
|
||
|
||
|
||
def remap(node, mk):
|
||
c = copy.deepcopy(node)
|
||
for n in walk(c):
|
||
n['id'] = mk()
|
||
return c
|
||
|
||
|
||
def text(nid, name, content, fill, size, weight, lh, ls, width, height, family=HEAD, align=None):
|
||
n = {"type": "text", "id": nid, "name": name, "fill": fill, "textGrowth": "fixed-width",
|
||
"width": round(width, 2), "height": round(height, 2), "content": content,
|
||
"lineHeight": lh, "fontFamily": family, "fontSize": size, "fontWeight": weight,
|
||
"letterSpacing": ls}
|
||
if align:
|
||
n["textAlign"] = align
|
||
return n
|
||
|
||
|
||
def frame(nid, name, w, h, layout="vertical", gap=None, pad=None, fill=None, radius=None,
|
||
align=None, justify=None, clip=None, stroke=None, stroke_width=1, children=None):
|
||
n = {"type": "frame", "id": nid, "name": name, "width": round(w, 2), "height": round(h, 2)}
|
||
n["layout"] = layout
|
||
if gap is not None:
|
||
n["gap"] = gap
|
||
if pad is not None:
|
||
n["padding"] = pad
|
||
if fill:
|
||
n["fill"] = fill
|
||
if radius is not None:
|
||
n["cornerRadius"] = radius
|
||
if align:
|
||
n["alignItems"] = align
|
||
if justify:
|
||
n["justifyContent"] = justify
|
||
if clip is not None:
|
||
n["clip"] = clip
|
||
if stroke:
|
||
n["stroke"] = stroke
|
||
n["strokeWidth"] = stroke_width
|
||
if children:
|
||
n["children"] = children
|
||
return n
|
||
|
||
|
||
# ---------- исходники канона ----------
|
||
src_hero = find(d, 'hz0574')
|
||
|
||
|
||
def txt(name, idx=0):
|
||
return by_name(src_hero, name)[idx]
|
||
|
||
|
||
C = {
|
||
'h1': txt('H1')['content'],
|
||
'offer': txt('Оффер')['content'],
|
||
'bar_title': txt('Титул полосы')['content'],
|
||
'bar_lead': txt('Лид полосы')['content'],
|
||
'card_titles': [x['content'] for x in by_name(src_hero, 'Заголовок плашки')],
|
||
'card_leads': [x['content'] for x in by_name(src_hero, 'Лид плашки')],
|
||
'terms': [x['content'] for x in by_name(src_hero, 'Термин')],
|
||
'descs': [x['content'] for x in by_name(src_hero, 'Описание')],
|
||
'group_labels': [x['content'] for x in by_name(src_hero, 'Метка группы')],
|
||
'chips': [x['content'] for x in by_name(src_hero, 'Чип-подпись')],
|
||
}
|
||
assert len(C['card_titles']) == 2 and len(C['terms']) == 3 and len(C['chips']) == 7, C
|
||
F = {'text1': txt('H1')['fill'], 'text2': txt('Оффер')['fill'], 'text3': txt('Подпись')['fill'],
|
||
'deep': txt('Термин')['fill']}
|
||
CARD_FILL = find(d, 'hz0604')['fill']
|
||
ACCENT_FILL = find(d, 'hz0606')['fill']
|
||
BTN_P = find(d, 'hz0578')
|
||
BTN_G = find(d, 'hz0580')
|
||
PLANET_FILL = copy.deepcopy(find(d, 'hz0585')['fill'])
|
||
|
||
STAT = [('5', 'НАПРАВЛЕНИЙ'), ('20', 'ПРОЕКТОВ'), ('5', 'РЕЛИЗОВ'), ('100%', 'СВОЙ ПРОДАКШН')]
|
||
CHIPS = [[('UNREAL ENGINE', 143.11), ('UNITY', 69.05), ('GODOT', 77.5)],
|
||
[('C++', 51.78), ('C#', 45.16)],
|
||
[('THREE.JS', 93.39), ('WEBGL', 78.19)]]
|
||
TERM_W = [76.13, 95.41, 77.78]
|
||
GLABEL_W = [65.67, 52.41, 57.42]
|
||
|
||
P = {
|
||
'1440': dict(W=1440, hero_h=810.83, hero_gap=12, hero_pad=[8, 120, 8, 120], row_gap=24,
|
||
copy_w=641.45, text_w=593.45, planet=[385.8, 299.95], visual_w=534.55,
|
||
h1=118.78, offer=28, bar_h=89, bar_pad=[8, 24, 8, 24], bar_gap=32,
|
||
title_h=23, lead_h=42, lead_w=550.77, intro_w=685.03,
|
||
cards_gap=8, card_pad=[8, 23, 8, 23], card_h=[172.69, 201.19],
|
||
card_gap=8, group_gap=8, intro_gap=8, pairs_gap=8),
|
||
'1366': dict(W=1366, hero_h=724.13, hero_gap=12, hero_pad=[8, 120, 8, 120], row_gap=24,
|
||
copy_w=641.45, text_w=593.45, planet=[300, 233.25], visual_w=534.55,
|
||
h1=118.78, offer=28, bar_h=85, bar_pad=[8, 24, 8, 24], bar_gap=32,
|
||
title_h=23, lead_h=42, lead_w=550.77, intro_w=685.03,
|
||
cards_gap=8, card_pad=[8, 23, 8, 23], card_h=[164.69, 193.19],
|
||
card_gap=8, group_gap=4, intro_gap=4, pairs_gap=4),
|
||
'1920': dict(W=1920, hero_h=967.17, hero_gap=16, hero_pad=[16, 360, 16, 360], row_gap=24,
|
||
copy_w=641.45, text_w=593.45, planet=[520, 404.3], visual_w=534.55,
|
||
h1=118.78, offer=28, bar_h=97, bar_pad=[12, 24, 12, 24], bar_gap=32,
|
||
title_h=23, lead_h=42, lead_w=550.77, intro_w=685.03,
|
||
cards_gap=12, card_pad=[12, 23, 12, 23], card_h=[180.69, 209.19],
|
||
card_gap=8, group_gap=8, intro_gap=8, pairs_gap=8),
|
||
'390': dict(W=390, hero_h=1756.44, hero_gap=24, hero_pad=[24, 24, 24, 24], row_gap=24,
|
||
copy_w=342, text_w=310, planet=[342, 265.89], visual_w=342,
|
||
h1=112.17, offer=84, bar_h=255, bar_pad=[16, 16, 16, 16], bar_gap=16,
|
||
title_h=23, lead_h=84, lead_w=310, intro_w=310,
|
||
cards_gap=12, card_pad=[16, 15, 16, 15], card_h=[418.19, 345.19],
|
||
card_gap=8, group_gap=12, intro_gap=8, pairs_gap=8),
|
||
}
|
||
|
||
|
||
def build(k, mk):
|
||
p = P[k]
|
||
mobile = (k == '390')
|
||
inner_w = 1200 if not mobile else 342
|
||
content_w = inner_w - 2 * (p['card_pad'][1] + 1)
|
||
row_w = 1152 if not mobile else 310
|
||
|
||
def btn(node):
|
||
return copy.deepcopy(node) if k == '1440' else remap(node, mk)
|
||
|
||
def title_row(tag, title):
|
||
return frame(mk('ct' + tag), 'Заголовок с маркером', content_w, 13.2, layout='none', children=[
|
||
dict(frame(mk('mk' + tag), 'Маркер', 8, 8, layout='none', fill=ACCENT_FILL, radius=2),
|
||
x=-16, y=2.6),
|
||
dict(text(mk('ctt' + tag), 'Заголовок плашки', title, F['text1'], 12, 700, 1.1, 1.2,
|
||
content_w, 13.2), x=0, y=0)])
|
||
|
||
# --- строка 1
|
||
h1n = text(mk('h1'), 'H1', C['h1'], F['text1'], 34 if mobile else 54, 800, 1.1, 1,
|
||
p['text_w'], p['h1'])
|
||
offer = text(mk('offer'), 'Оффер', C['offer'], F['text2'], 20, 400, 1.4, 0, p['text_w'],
|
||
p['offer'], family=BODY)
|
||
cta = frame(mk('cta'), 'CTA', p['text_w'], 112 if mobile else 48,
|
||
layout='vertical' if mobile else 'horizontal', gap=16,
|
||
children=[btn(BTN_P), btn(BTN_G)])
|
||
copy_children = ([frame(mk('h1box'), 'H1 блок', p['text_w'], p['h1'], gap=0, children=[h1n])]
|
||
if mobile else [h1n]) + [offer, cta]
|
||
copy_f = frame(mk('copy'), 'Копия', p['copy_w'],
|
||
p['h1'] + 16 + p['offer'] + 16 + (112 if mobile else 48), gap=16,
|
||
pad=[0, 16 if mobile else 24, 0, 16 if mobile else 24], children=copy_children)
|
||
planet = frame(mk('planet'), 'Арт планеты (Work_files/Planet)', p['planet'][0], p['planet'][1],
|
||
fill=copy.deepcopy(PLANET_FILL), radius=16)
|
||
visual = frame(mk('visual'), 'Колонка визуала', p['visual_w'], p['planet'][1],
|
||
layout='horizontal', align='center', justify='center', children=[planet])
|
||
row1 = frame(mk('row1'), 'Строка 1 · копия и планета', inner_w, p['planet'][1],
|
||
layout='horizontal', gap=p['row_gap'], align='center', children=[copy_f, visual])
|
||
|
||
# --- строка 2
|
||
intro = frame(mk('bar_intro'), 'Вступление полосы', p['intro_w'],
|
||
p['title_h'] + p['intro_gap'] + p['lead_h'], gap=p['intro_gap'], children=[
|
||
text(mk('bar_title'), 'Титул полосы', C['bar_title'], F['text1'], 20, 700, 1.15, .5,
|
||
p['intro_w'], p['title_h']),
|
||
text(mk('bar_lead'), 'Лид полосы', C['bar_lead'], F['text2'], 14, 400, 1.5, 0,
|
||
p['lead_w'], p['lead_h'], family=BODY)])
|
||
stats = []
|
||
for i, (val, lab) in enumerate(STAT):
|
||
sw = [112.38, 100.45, 92.31, 129.83][i] if not mobile else 143
|
||
pad = [0, 16, 0, 16] if not mobile else [0, 0, 0, 0]
|
||
if not mobile and i == 0:
|
||
pad = [0, 16, 0, 0]
|
||
if not mobile and i == 3:
|
||
pad = [0, 0, 0, 16]
|
||
tw = sw - pad[1] - pad[3]
|
||
stats.append(frame(mk(f'st{i}'), f'Стат {val}', sw, 42, gap=4, pad=pad,
|
||
stroke=None if (mobile or i == 0) else "$b-hairline",
|
||
children=[text(mk(f'stv{i}'), 'Значение', val, F['text1'], 24, 800, 1.0, 0, tw, 24),
|
||
text(mk(f'stl{i}'), 'Подпись', lab, F['text3'], 10, 600, 1.4, 1, tw, 14)]))
|
||
if mobile:
|
||
stats_n = frame(mk('stats'), 'Статы', 310, 92, gap=8, children=[
|
||
frame(mk('strow1'), 'Ряд 1', 310, 42, layout='horizontal', gap=24, children=stats[:2]),
|
||
frame(mk('strow2'), 'Ряд 2', 310, 42, layout='horizontal', gap=24, children=stats[2:])])
|
||
else:
|
||
stats_n = frame(mk('stats'), 'Статы', 434.97, 42, layout='horizontal', align='center', children=stats)
|
||
bar = frame(mk('bar'), 'Строка 2 · полоса на всю ширину', inner_w, p['bar_h'],
|
||
layout='vertical' if mobile else 'horizontal', gap=p['bar_gap'], pad=p['bar_pad'],
|
||
fill=CARD_FILL, radius=16, align=None if mobile else 'center',
|
||
children=[intro, stats_n])
|
||
|
||
# --- плашка «Кто мы»
|
||
pairs = []
|
||
for i in range(3):
|
||
if mobile:
|
||
pairs.append(frame(mk(f'pair{i}'), 'Пара', row_w, [85, 106, 64][i], gap=4, children=[
|
||
text(mk(f'term{i}'), 'Термин', C['terms'][i], F['deep'], 12, 700, 1.5, 1, 310, 18),
|
||
text(mk(f'desc{i}'), 'Описание', C['descs'][i], F['text2'], 14, 400, 1.5, 0, 310,
|
||
[63, 84, 42][i], family=BODY)]))
|
||
else:
|
||
tw_ = TERM_W[i]
|
||
pairs.append(frame(mk(f'pair{i}'), 'Пара', row_w, 22.5, layout='horizontal', gap=8,
|
||
align='baseline', children=[
|
||
text(mk(f'term{i}'), 'Термин', C['terms'][i], F['deep'], 12, 700, 1.5, 1,
|
||
tw_, 18),
|
||
text(mk(f'desc{i}'), 'Описание', C['descs'][i], F['text2'], 14, 400, 1.5,
|
||
0, row_w - tw_ - 8, 21, family=BODY)]))
|
||
pairs_h = (85 + 8 + 106 + 8 + 64) if mobile else (22.5 * 3 + p['pairs_gap'] * 2)
|
||
pairs_frame = frame(mk('pairs'), 'Пары', row_w, pairs_h, gap=p['pairs_gap'], children=pairs)
|
||
card0 = frame(mk('card0'), 'Плашка «Кто мы»', inner_w, p['card_h'][0], gap=p['card_gap'],
|
||
pad=p['card_pad'], fill=CARD_FILL, radius=12, stroke="$b-hairline", clip=True,
|
||
children=[title_row('0', C['card_titles'][0]),
|
||
text(mk('cardlead0'), 'Лид плашки', C['card_leads'][0], F['text2'], 14, 400,
|
||
1.5, 0, 755.34 if not mobile else 310, 84 if mobile else 42, family=BODY),
|
||
pairs_frame])
|
||
|
||
# --- плашка «Стек и технологии»
|
||
groups = []
|
||
for i in range(3):
|
||
chips = []
|
||
for j, (name, cw) in enumerate(CHIPS[i]):
|
||
chips.append(frame(mk(f'chip{i}{j}'), f'Чип {name}', cw, 32, layout='horizontal',
|
||
fill=CARD_FILL, radius=999, align='center', justify='center',
|
||
stroke="$b-hairline",
|
||
children=[text(mk(f'chiptx{i}{j}'), 'Чип-подпись', name, F['text2'],
|
||
12, 600, 1.5, 1, cw - 26, 18, align='center')]))
|
||
chips_w = sum(c[1] for c in CHIPS[i]) + 8 * (len(CHIPS[i]) - 1)
|
||
chips_f = frame(mk(f'chips{i}'), 'Чипы', 310 if mobile else chips_w, 32,
|
||
layout='horizontal', gap=8, align='center', children=chips)
|
||
if mobile:
|
||
groups.append(frame(mk(f'group{i}'), f'Группа {C["group_labels"][i]}', row_w, 58, gap=8,
|
||
children=[text(mk(f'glabel{i}'), 'Метка группы', C['group_labels'][i],
|
||
F['deep'], 12, 700, 1.5, 1, 310, 18), chips_f]))
|
||
else:
|
||
groups.append(frame(mk(f'group{i}'), f'Группа {C["group_labels"][i]}', row_w, 32,
|
||
layout='horizontal', gap=8, align='center', children=[
|
||
text(mk(f'glabel{i}'), 'Метка группы', C['group_labels'][i],
|
||
F['deep'], 12, 700, 1.5, 1, GLABEL_W[i], 18), chips_f]))
|
||
groups_frame = frame(mk('groups'), 'Группы', row_w,
|
||
(58 * 3 + 12 * 2) if mobile else (32 * 3 + p['group_gap'] * 2),
|
||
gap=p['group_gap'], children=groups)
|
||
card1 = frame(mk('card1'), 'Плашка «Стек и технологии»', inner_w, p['card_h'][1], gap=p['card_gap'],
|
||
pad=p['card_pad'], fill=CARD_FILL, radius=12, stroke="$b-hairline", clip=True,
|
||
children=[title_row('1', C['card_titles'][1]),
|
||
text(mk('cardlead1'), 'Лид плашки', C['card_leads'][1], F['text2'], 14, 400,
|
||
1.5, 0, 755.34 if not mobile else 310, 84 if mobile else 42, family=BODY),
|
||
groups_frame])
|
||
|
||
cards = frame(mk('cards'), 'Строка 3 · плашки друг над другом, на всю ширину', inner_w,
|
||
p['card_h'][0] + p['cards_gap'] + p['card_h'][1], gap=p['cards_gap'],
|
||
children=[card0, card1])
|
||
|
||
hero_children = [copy_f, planet, bar, cards] if mobile else [row1, bar, cards]
|
||
return frame(mk('hero'), 'Hero', p['W'], p['hero_h'], gap=p['hero_gap'], pad=p['hero_pad'],
|
||
children=hero_children)
|
||
|
||
|
||
# ---------- id-политика: кадр 1440 сохраняет свои id, остальные кадры получают свои ----------
|
||
mint1440 = Minter('hv')
|
||
mint390 = Minter('hm')
|
||
mint1920 = Minter('hx')
|
||
_id_map = {'h1': 'hz0582', 'offer': 'hz0583', 'cta': 'hz0577', 'copy': 'hz0576', 'planet': 'hz0585',
|
||
'visual': 'hz0584', 'row1': 'hz0575', 'bar': 'hz0586', 'bar_intro': 'hz0587',
|
||
'bar_title': 'hz0588', 'bar_lead': 'hz0589', 'stats': 'hz0590', 'cards': 'hz0603',
|
||
'card0': 'hz0604', 'card1': 'hz0618'}
|
||
_m390 = {'h1box': 'hz0794', 'offer': 'hz0796', 'cta': 'hz0746', 'planet': 'hz0797',
|
||
'bar': 'hz0798', 'cards': 'hz0751'}
|
||
|
||
|
||
def mk1440(role=''):
|
||
return _id_map.get(role or '') or mint1440()
|
||
|
||
|
||
def mk390(role=''):
|
||
return _m390.get(role or '') or mint390()
|
||
|
||
|
||
f1440 = find(d, 'hz0573')
|
||
nav1440 = f1440['children'][0]
|
||
m390 = find(d, 'hz0741')
|
||
mnav = m390['children'][0]
|
||
ticker_c = by_name(f1440, 'Тикер первого экрана')[0]
|
||
ticker_m = by_name(m390, 'Тикер первого экрана')[0]
|
||
|
||
hero1366 = build('1366', Minter('hg'))
|
||
hero1440 = build('1440', mk1440)
|
||
hero390 = build('390', mk390)
|
||
hero1920 = build('1920', mint1920)
|
||
|
||
f1440['name'] = 'Hero — одна шкала · 1440×900'
|
||
f1440['children'] = [nav1440, hero1440]
|
||
f1440['x'], f1440['y'] = 0, 11200
|
||
|
||
m390['name'] = 'Hero — одна шкала · 390×844'
|
||
m390['children'] = [mnav, hero390]
|
||
m390['x'], m390['y'] = 0, 13200
|
||
m390['clip'] = True # первый экран: hero на мобайле выше кадра (1756 px) — кадр показывает фолд
|
||
|
||
f1366 = find(d, 'hz0657')
|
||
nav1366 = f1366['children'][0]
|
||
ticker_1366 = by_name(f1366, 'Тикер первого экрана')[0]
|
||
nav1366['padding'] = [0, 83, 0, 83]
|
||
f1366['name'] = 'Hero — одна шкала · 1366×768'
|
||
f1366['children'] = [nav1366, hero1366]
|
||
f1366['x'], f1366['y'] = 0, 14200
|
||
tk1366 = {"type": "frame", "id": "hz1956", "name": "Тикер первого экрана (за фолдом) · 1366",
|
||
"width": 1366, "height": 49, "x": 1560, "y": 11440, "layout": "vertical"}
|
||
tk1366['children'] = [ticker_1366]
|
||
|
||
f1920 = {"type": "frame", "id": "hz1900", "name": "Hero — одна шкала · 1920×1080",
|
||
"width": 1920, "height": 1080, "x": 0, "y": 12200, "layout": "vertical", "fill": "$b-bg"}
|
||
nav1920 = remap(nav1440, Minter('hn'))
|
||
nav1920['width'] = 1920
|
||
nav1920['padding'] = [0, 360, 0, 360]
|
||
f1920['children'] = [nav1920, hero1920]
|
||
|
||
tk1440 = {"type": "frame", "id": "hz1950", "name": "Тикер первого экрана (за фолдом) · 1440",
|
||
"width": 1440, "height": 49, "x": 1560, "y": 11200, "layout": "vertical"}
|
||
tk1440['children'] = [ticker_c]
|
||
tk1920 = {"type": "frame", "id": "hz1952", "name": "Тикер первого экрана (за фолдом) · 1920",
|
||
"width": 1920, "height": 49, "x": 1560, "y": 11320, "layout": "vertical"}
|
||
t2 = remap(ticker_c, Minter('hk'))
|
||
t2['width'] = 1920
|
||
t2['padding'] = [0, 360, 0, 360]
|
||
tk1920['children'] = [t2]
|
||
tk390 = {"type": "frame", "id": "hz1954", "name": "Тикер первого экрана (за фолдом) · 390",
|
||
"width": 390, "height": 49, "x": 450, "y": 13200, "layout": "vertical"}
|
||
tk390['children'] = [ticker_m]
|
||
|
||
d['children'] += [f1920, tk1440, tk1920, tk390, tk1366]
|
||
|
||
ids_ = [n.get('id') for n in walk(d) if n.get('id')]
|
||
dups = {i for i in ids_ if ids_.count(i) > 1}
|
||
assert not dups, f'duplicate ids: {dups}'
|
||
|
||
out = json.dumps(d, ensure_ascii=False, indent=2)
|
||
open(CANON, 'w', encoding='utf-8').write(out)
|
||
print('canon written:', CANON, len(out), 'bytes')
|
||
if SNAP:
|
||
open(SNAP, 'w', encoding='utf-8').write(out)
|
||
print('snapshot written:', SNAP)
|