Files
Harvey_Team_Page/design/project-links-2026-10-14/patch-pen-projectlink.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

208 lines
8.6 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.
"""Persist the §10.28 ProjectLink component into the .pen files on disk.
Why: Pencil MCP does NOT autosave — the component now lives only in the running
editor. This script writes the same nodes into the canon .pen and the design/
snapshot: a Components master + three rows of the States matrix.
Recipe: references/pen-disk-patch.md (backup -> patch -> validate -> write).
Idempotent: skips a file that already carries ProjectLink.
Run: python design/project-links-2026-10-14/patch-pen-projectlink.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-20261014"
MASTER_ID = "EByJw"
MASTER = {
"type": "frame", "id": MASTER_ID, "name": "ProjectLink", "reusable": True,
"cornerRadius": "$radius-md", "stroke": "$brand-deep", "strokeWidth": 2,
"gap": 8, "padding": [12, 24],
"children": [
{"type": "icon", "id": "z4oNC", "name": "LinkMark", "width": 18, "height": 18,
"icon": "globe", "library": "lucide", "fill": "$brand-deep"},
{"type": "text", "id": "B9oDO", "name": "LinkLabel", "fill": "$brand-deep",
"content": "САЙТ ПРОЕКТА", "fontFamily": "$font-heading", "fontSize": 14,
"fontWeight": "700", "letterSpacing": 1},
],
}
MARK, LABEL = "z4oNC", "B9oDO"
def ref(nid, name, **over):
"""Instance of the master; overrides mirror what the MCP accepted."""
node = {"id": nid, "type": "ref", "ref": MASTER_ID, "name": name}
for key in ("fill", "stroke", "strokeWidth", "padding", "opacity"):
if key in over:
node[key] = over[key]
if over.get("mark") or over.get("label"):
desc = {}
if over.get("mark"):
desc[MARK] = over["mark"]
if over.get("label"):
desc[LABEL] = over["label"]
node["descendants"] = desc
return node
def row(rid, row_name, cap_id, cap_name, wrap_id, wrap_name, cap_text, children):
return {
"type": "frame", "id": rid, "name": row_name,
"layout": "vertical", "gap": 10,
"children": [
{"type": "text", "id": cap_id, "name": cap_name, "fill": "$text-3",
"content": cap_text, "fontFamily": "$font-heading", "fontSize": 12,
"fontWeight": "700", "letterSpacing": 1},
{"type": "frame", "id": wrap_id, "name": wrap_name, "gap": 16,
"alignItems": "center", "children": children},
],
}
def rows():
resources = row(
"zPfME", "Row_ССЫЛКА ПРОЕКТА", "APqQ5", "Cap_ССЫЛКА ПРОЕКТА", "OBLsJ", "Wrap_ССЫЛКА ПРОЕКТА",
"ССЫЛКА ПРОЕКТА (знак ресурса + подпись): состояния и три ресурса",
[
ref("xv726", "PL_site"),
ref("PLyfk", "PL_rustore", mark={"icon": "store"}, label={"content": "В RUSTORE"}),
ref("O5Vf0", "PL_vk", mark={"icon": "gamepad-2"}, label={"content": "ИГРАТЬ ВО VK"}),
ref("z4XWl", "PL_primary", fill="$brand", stroke="$brand",
mark={"fill": "#04180C"}, label={"fill": "#04180C"}),
])
states = row(
"NiCYg", "Row_ССЫЛКА ПРОЕКТА — СОСТОЯНИЯ", "X6kox", "Cap_ССЫЛКА СОСТОЯНИЯ", "S88VV", "Wrap_ССЫЛКА СОСТОЯНИЯ",
"ССЫЛКА ПРОЕКТА: default → hover → active → focus → disabled",
[
ref("ESknH", "PL_default"),
ref("lkOok", "PL_hover", fill="#007A3F17",
mark={"fill": "#00562C"}, label={"fill": "#00562C"}),
ref("tn69z", "PL_active", fill="#007A3F24", stroke="#00562C", strokeWidth=3,
mark={"fill": "#00562C"}, label={"fill": "#00562C"}),
ref("JIqc4", "PL_focus", strokeWidth=4),
ref("HZiiG", "PL_disabled", opacity=0.4),
])
card = row(
"P1wTl", "Row_ССЫЛКА КАРТОЧКА", "c9IKO7", "Cap_ССЫЛКА КАРТОЧКА", "QtK4W", "Wrap_ССЫЛКА КАРТОЧКА",
"ССЫЛКА ПРОЕКТА — КОМПАКТ (мини-карточка, 36 px)",
[
ref("C1esB", "PLC_rustore", padding=[8, 14],
mark={"icon": "store", "width": 16, "height": 16},
label={"content": "В RUSTORE", "fontSize": 12}),
ref("zqgsI", "PLC_vk", padding=[8, 14],
mark={"icon": "gamepad-2", "width": 16, "height": 16},
label={"content": "ИГРАТЬ ВО VK", "fontSize": 12}),
])
return [x for x in (resources, states, card)]
def find(node, name):
if isinstance(node, dict):
if node.get("name") == name:
return node
for c in node.get("children") or []:
r = find(c, name)
if r:
return r
return None
def find_id(node, nid):
if isinstance(node, dict):
if node.get("id") == nid:
return node
for c in node.get("children") or []:
r = find_id(c, nid)
if r:
return r
return None
NEW_IDS = ["EByJw", "z4oNC", "B9oDO", "zPfME", "APqQ5", "OBLsJ", "xv726", "PLyfk", "O5Vf0",
"z4XWl", "NiCYg", "X6kox", "S88VV", "ESknH", "lkOok", "tn69z", "JIqc4", "HZiiG",
"P1wTl", "c9IKO7", "QtK4W", "C1esB", "zqgsI"]
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
if find(doc, "ProjectLink") is not None:
print(" already carries ProjectLink — skipped")
continue
components = find(doc, "Components")
states = find(doc, "States")
if components is None or states is None:
fails.append(f"{path.name}: Components/States frame missing")
continue
comp_before = len(components["children"])
states_before = len(states["children"])
shutil.copyfile(path, str(path) + "." + STAMP)
components["children"].insert(2, MASTER) # right after GhostButton
states["children"].extend(rows())
# Keep each file's OWN formatting: the canon is pretty-printed with CRLF,
# the design/ snapshot is minified single-line JSON. Re-dumping the snapshot
# with indent=2 would inflate it 233 KB -> 631 KB (learned the hard way).
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"
# --- validate before writing ---
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)):
dup = sorted({i for i in ids if ids.count(i) > 1})
fails.append(f"{path.name}: duplicate ids {dup}")
if [n.get("name") for n in reloaded.get("children") or []] != tops_before:
fails.append(f"{path.name}: top-level frames changed")
for nid in NEW_IDS:
if find_id(reloaded, nid) is None:
fails.append(f"{path.name}: new node {nid} missing after reload")
comp2 = find(reloaded, "Components")
states2 = find(reloaded, "States")
if len(comp2["children"]) != comp_before + 1 or comp2["children"][2]["name"] != "ProjectLink":
fails.append(f"{path.name}: ProjectLink not at Components index 2")
if len(states2["children"]) != states_before + 3:
fails.append(f"{path.name}: States children {len(states2['children'])} != {states_before + 3}")
for nm in ("ССЫЛКА ПРОЕКТА", "ИГРАТЬ ВО VK", "gamepad-2"):
if nm not in text:
fails.append(f"{path.name}: {nm} missing in serialized text")
if len(text.encode("utf-8")) < size_before:
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; "
f"Components {comp_before}->{comp_before + 1}, States {states_before}->{states_before + 3}")
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)