Files
Harvey_Team_Page/design/pen-sync/patch-palette-2026-10-13.py
T
FastD da710c4686 Accents, page edits and planet tuning; drop Pencil backups
Design: add the orange second accent from the UZURON palette and split the
colour roles (orange marks, green acts) in both themes; soften the dark green
and lift the dark cards toward the page background. Background options for the
next review are in design/background-options-2026-10-13/.

Page: replace the process block with an individual-approach section; drop the
budget form field; rename the contact field to a preferred channel; add a
submit confirmation dialog, studio links (mail, VK, RuStore), the First Step
Radio card, portfolio filters by platform, stack, genre and status, a cookie
bar and a removable hero ticker. Cards keep the mascot face; the member window
gains the real photo and the city.

Planet: fold the speed knobs into SPEED_TAU and SPEED_MIN with a hard stop
below the threshold; the pill is the only hover target and the summary card is
inert.

Repo: remove .pen backups from the index, ignore backups and Python artefacts,
drop generated pen-sync exports.
2026-10-13 22:08:24 +03:00

168 lines
8.4 KiB
Python
Raw 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.
"""Точечный патч палитры в `.pen` (канбан t_1533ba29, 2026-10-13).
Зачем отдельный скрипт, а не `rebuild-frame-b.py`: эта волна меняет ТОЛЬКО токены и заливки
носителей — структура фрейма не трогается. Генератор пересобирает фрейм целиком и выдаёт
свою нумерацию id (приложение хранит свои), поэтому для правки «по цветам» правится
существующий JSON на месте — по рецепту `references/pen-disk-patch.md`:
сохранить `fileToken`, бэкап, валидация до и после, никаких структурных удалений.
Что меняется (spec.md §10.9.1 и §10.26):
1. тёмные значения поверхностей: card / field / hairline (сближение поверхностей);
2. зелёная семья приглушена + заливка `b-brand` стала тематической (была константой);
3. второй акцент: `b-accent` / `b-accent-deep` (оранжевый UZURON) + константа `b-on-accent`;
4. носители маркировки переведены на оранжевый: eyebrow, точка плашки, платформы в пилюле;
чипы плашки выровнены с продом (нейтральные, как `.planet-tag__chip`).
Запуск: python design/pen-sync/patch-palette-2026-10-13.py
Идемпотентен: повторный запуск не меняет файл. Exit 1 — если носитель не найден или
структура изменилась (fail-loud, файл не записывается).
"""
import json
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
FILES = [(ROOT / "Harvey_Monster_Team_Page.pen", "pretty"),
(ROOT / "design" / "Harvey_Monster_Team_Page.pen", "compact")]
FRAME_NAME = "B Editorial Agency" # светлый фрейм B (id у канона и снимка один: W0IwN)
DARK_NAME = "B Editorial Agency — Dark" # тёмный близнец: id зависит от того, кто сохранял файл
VAR_DARK = { # тёмные значения (светлые не меняются)
"b-card": "#1F160D", "b-field": "#261C11", "b-hairline": "#332719",
"b-brand-strong": "#1DA561", "b-brand-active": "#1A9E60",
"b-brand-deep": "#49CA85", "b-brand-ink": "#49CA85",
"b-brand-soft": "#22B46B29", "b-ghost-hover": "#49CA851F",
}
VAR_THEMED = { # новые тематические переменные (light, dark)
"b-brand": ("#00CC66", "#22B46B"),
"b-accent": ("#FFA400", "#D1911A"),
"b-accent-deep": ("#9C5800", "#E7A223"),
}
VAR_CONST = { # новые константы
"b-on-accent": "#2A1500",
}
CARRIERS = { # имя узла: {свойство: новое значение}
"Eyebrow": {"fill": "$b-accent-deep"},
"Точка объекта": {"fill": "$b-accent"},
"Платформы объекта": {"fill": "$b-accent-deep"},
}
CARRIER_PREFIX = { # префикс имени: {свойство: значение}
"Чип плашки ": {"fill": "$b-card", "stroke": "$b-line-strong", "strokeWidth": 1},
"Чип-подпись плашки ": {"fill": "$b-text-2"},
}
VAR_REMOVED = () # ничего не удаляем
def walk(node):
yield node
for key in ("children",): # только дерево узлов, не свойства/переменные
for c in node.get(key) or []:
yield from walk(c)
def themed(light, dark):
return [{"value": light, "theme": {"mode": "light"}},
{"value": dark, "theme": {"mode": "dark"}}]
def dark_value(var):
val = var.get("value")
if isinstance(val, list):
return next((v["value"] for v in val if v.get("theme", {}).get("mode") == "dark"), None)
return None
problems = []
def main():
for path, style in FILES:
doc = json.loads(path.read_text(encoding="utf-8"))
token = doc.get("fileToken")
before_ids = [n.get("id") for f in doc["children"] for n in walk(f)]
before_nodes = len(before_ids)
if len(set(before_ids)) != before_nodes:
problems.append(f"{path.name}: дубли id ДО правки")
# --- 1. переменные
changed_vars = []
for name, dark in VAR_DARK.items():
var = doc["variables"].get(name)
if var is None:
problems.append(f"{path.name}: нет переменной {name}")
continue
if dark_value(var) == dark:
continue
if isinstance(var.get("value"), list):
for v in var["value"]:
if v.get("theme", {}).get("mode") == "dark":
v["value"] = dark
else:
problems.append(f"{path.name}: {name} не тематическая — правится вручную")
continue
changed_vars.append(name)
for name, (light, dark) in VAR_THEMED.items():
cur = doc["variables"].get(name)
want = themed(light, dark)
if cur is None:
doc["variables"][name] = {"type": "color", "value": want}
changed_vars.append(name + " (new)")
elif cur.get("value") != want:
cur["value"] = want
doc["variables"][name] = cur
changed_vars.append(name)
for name, val in VAR_CONST.items():
if doc["variables"].get(name, {}).get("value") != val:
doc["variables"][name] = {"type": "color", "value": val}
changed_vars.append(name + " (new)")
# --- 2. носители в обоих фреймах
hits = {k: 0 for k in CARRIERS}
prefix_hits = {k: 0 for k in CARRIER_PREFIX}
for want_name in (FRAME_NAME, DARK_NAME):
frame = next((c for c in doc["children"] if c.get("name") == want_name), None)
if frame is None:
problems.append(f"{path.name}: нет фрейма «{want_name}»")
continue
for node in walk(frame):
name = node.get("name") or ""
if name in CARRIERS:
node.update(CARRIERS[name])
hits[name] += 1
for pfx, props in CARRIER_PREFIX.items():
if name.startswith(pfx):
node.update(props)
prefix_hits[pfx] += 1
for k, v in hits.items():
if v == 0:
problems.append(f"{path.name}: носитель «{k}» не найден")
for k, v in prefix_hits.items():
if v == 0:
problems.append(f"{path.name}: носители «{k}*» не найдены")
# --- 3. инварианты структуры
after_ids = [n.get("id") for f in doc["children"] for n in walk(f)]
if after_ids != before_ids:
problems.append(f"{path.name}: изменился состав/порядок узлов")
if doc.get("fileToken") != token:
problems.append(f"{path.name}: потерян fileToken")
if problems:
continue
text = (json.dumps(doc, ensure_ascii=False, indent=2) if style == "pretty"
else json.dumps(doc, ensure_ascii=False, separators=(",", ":")))
shutil.copyfile(path, str(path) + ".bak-before-patch")
path.write_text(text, encoding="utf-8")
print(f"{path.relative_to(ROOT)}: узлов {before_nodes}, переменных {len(doc['variables'])}")
print(f" переменных изменено: {len(changed_vars)} → {', '.join(changed_vars)}")
print(f" носители: " + ", ".join(f"{k}×{v}" for k, v in {**hits, **prefix_hits}.items()))
if problems:
print("\nПРОВАЛЫ (файлы не записаны):")
for p in problems:
print(" -", p)
return 1
print("\nOK: палитра и носители обновлены в обоих .pen")
return 0
if __name__ == "__main__":
sys.exit(main())