Files
Harvey_Team_Page/design/glyph-slot-2026-10-14/patch-pen-glyphslot.py
T
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

159 lines
7.1 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.
"""Персист §10.28 в .pen: единый слот знака (16×16 карточка / 18×18 окно) и компактные кнопки.
Зачем: Pencil MCP НЕ сохраняет .pen на диск — правки живут только в открытом редакторе.
Скрипт пишет те же значения в канон и в снимок design/, ничего больше не трогая.
Рецепт: references/pen-disk-patch.md (бэкап -> патч -> валидация -> запись).
Идемпотентно: файл, у которого ProjectLink уже с height 48 и gap 5, пропускается.
Запуск: py design/glyph-slot-2026-10-14/patch-pen-glyphslot.py
"""
import json
import re
import shutil
import sys
from pathlib import Path
ROOT = Path("G:/Project/Haevey_Monster_Team_Page")
FILES = [ROOT / "Harvey_Monster_Team_Page.pen", ROOT / "design" / "Harvey_Monster_Team_Page.pen"]
STAMP = "bak-glyphslot-20261014"
MASTER_ID = "EByJw"
MARK, LABEL = "z4oNC", "B9oDO"
# Значения совпадают с отгруженным CSS (§10.28, канбан t_d3adf730)
PATCHES = {
MASTER_ID: {"padding": [12, 16], "gap": 5, "height": 48}, # окно: 48 px, знак 18×18, 12 px
LABEL: {"fontSize": 12, "letterSpacing": 0.5},
MARK: {"width": 18, "height": 18},
"O5Vf0": {"descendants": {LABEL: {"content": "ИГРАТЬ"}}}, # подпись VK приведена к отгруженной
"C1esB": {"padding": [8, 8], "height": 36,
"descendants": {MARK: {"icon": "store", "width": 16, "height": 16},
LABEL: {"content": "В RUSTORE", "fontSize": 11, "letterSpacing": 0.5}}},
"zqgsI": {"padding": [8, 8], "height": 36,
"descendants": {MARK: {"icon": "gamepad-2", "width": 16, "height": 16},
LABEL: {"content": "ИГРАТЬ", "fontSize": 11, "letterSpacing": 0.5}}},
"APqQ5": {"content": "ССЫЛКА ПРОЕКТА (знак ресурса 18×18 + подпись 12 px): состояния и три ресурса"},
"c9IKO7": {"content": "ССЫЛКА ПРОЕКТА — КОМПАКТ (мини-карточка: 36 px, знак 16×16, 11 px)"},
}
def find(node, nid):
if isinstance(node, dict):
if node.get("id") == nid:
return node
for c in node.get("children") or []:
r = find(c, nid)
if r is not None:
return r
return None
def find_by_name(node, name):
"""Components/States ищутся по ИМЕНИ: «Components» — имя узла Tam1b, не id."""
if isinstance(node, dict):
if node.get("name") == name:
return node
for c in node.get("children") or []:
r = find_by_name(c, name)
if r is not None:
return r
return None
def merge(node, patch):
"""Перезапись свойств узла. `descendants` — карта переопределений ключами мастера:
у экземпляра (ref) собственных детей на диске нет, есть только эта карта."""
for key, val in patch.items():
if key == "descendants":
desc = node.setdefault("descendants", {})
for cid, cval in val.items():
desc.setdefault(cid, {}).update(cval)
else:
node[key] = val
fails = []
for path in FILES:
print("=" * 70)
print(path)
raw = path.read_text(encoding="utf-8")
doc = json.loads(raw)
token = doc.get("fileToken")
tops_before = [n.get("name") for n in doc.get("children") or []]
size_before = path.stat().st_size
master = find(doc, MASTER_ID)
comps = find_by_name(doc, "Components")
states = find_by_name(doc, "States")
if master is None or comps is None or states is None:
fails.append(f"{path.name}: ProjectLink / Components / States missing")
continue
if master.get("height") == 48 and master.get("gap") == 5:
print(" already carries the unified slot — skipped")
continue
shutil.copyfile(path, str(path) + "." + STAMP)
for nid, patch in PATCHES.items():
node = find(doc, nid)
if node is None:
fails.append(f"{path.name}: node {nid} missing")
continue
merge(node, patch)
# формат каждого файла сохраняется: канон — pretty с CRLF, снимок design/ — минифицированный
nl = "\r\n" if "\r\n" in raw else ("\n" if "\n" in raw else "")
if nl:
text = json.dumps(doc, ensure_ascii=False, indent=2)
if nl == "\r\n":
text = text.replace("\n", "\r\n")
else:
text = json.dumps(doc, ensure_ascii=False, separators=(",", ":"))
if raw.endswith(("\n", "\r\n")) and not text.endswith(("\n", "\r\n")):
text += nl or "\n"
# --- валидация до записи ---
reloaded = json.loads(text)
if reloaded.get("fileToken") != token:
fails.append(f"{path.name}: fileToken changed")
ids = re.findall(r'"id":\s*"([^"]+)"', text)
if len(ids) != len(set(ids)):
fails.append(f"{path.name}: duplicate ids")
if [n.get("name") for n in reloaded.get("children") or []] != tops_before:
fails.append(f"{path.name}: top-level frames changed")
m2 = find(reloaded, MASTER_ID)
if m2 is None or not (m2.get("height") == 48 and m2.get("gap") == 5 and m2.get("padding") == [12, 16]):
fails.append(f"{path.name}: master not patched after reload")
lbl2, mk2 = find(reloaded, LABEL), find(reloaded, MARK)
if lbl2 is None or mk2 is None or lbl2.get("fontSize") != 12 or mk2.get("width") != 18:
fails.append(f"{path.name}: master children not patched")
for nid, expect in (("C1esB", 36), ("zqgsI", 36)):
node = find(reloaded, nid) or {}
if node.get("height") != expect:
fails.append(f"{path.name}: {nid} height != {expect}")
if node.get("padding") != [8, 8]:
fails.append(f"{path.name}: {nid} padding != [8,8]")
if len((find_by_name(reloaded, "Components") or {}).get("children") or []) != len(comps["children"]):
fails.append(f"{path.name}: Components children count changed")
if len((find_by_name(reloaded, "States") or {}).get("children") or []) != len(states["children"]):
fails.append(f"{path.name}: States children count changed")
for nm in ("ИГРАТЬ", "16×16", "36 px, знак"):
if nm not in text:
fails.append(f"{path.name}: {nm!r} missing in serialized text")
if len(text.encode("utf-8")) < size_before * 0.9:
fails.append(f"{path.name}: file shrank — refusing to write")
if fails:
print(" VALIDATION FAILED — nothing written")
continue
path.write_text(text, encoding="utf-8", newline="")
print(f" ok: {size_before} -> {path.stat().st_size} bytes; master 48 px / gap 5, "
f"compact 36 px / padding [8,8]")
print(f" backup: {path.name}.{STAMP}")
print("=" * 70)
print("FAILS:", len(fails))
for f in fails:
print(" -", f)
sys.exit(1 if fails else 0)