mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
* fix(catalog): make component previews answer their variables panel Every control on a component's catalog page did nothing. Asking caption-camera-follow for a violet accent rendered gold, and so did green and blue, on 166 of the 168 components that declare variables. A component ships a snippet, which is what the page hands you to paste and which carries the declaration plus the script that turns a chosen value into a CSS custom property, and a demo.html which stages and animates it. The preview is built from the demo, and the demo was authored as a copy of the snippet rather than a reference to it. The copies drifted until almost none of them carried the declaration or the reader, so the payload for that page never contained the word violet at all. Components come in two shapes, so the repair does too. 123 ship a snippet that registers its own paused timeline. That snippet is a whole piece, so their preview is now built from it and carries markup, variables and motion together. 45 are markup plus a commented recipe, where the demo owns the motion. Those demos now carry the snippet's declaration, reader and var-driven CSS in the registry itself, written by scripts/catalog/sync-demo-variables.ts. Nothing is patched in at build time. A test runs that tool in dry mode and fails when a demo has drifted again, naming the command that repairs it. It also asserts it inspected more than a hundred components, because a check that silently matches nothing is how this rotted in the first place. Measured by rendering every payload in a real player rather than by reading markup: payloads declaring their variables go from 2 of 168 to 168 of 168, previews that animate go from 166 to 167, and nothing that moved stopped moving. ascii-render-pass and star-rating-fill render a still frame when built from their snippet, so they keep the demo path as a recorded exception and stay in the state they were already in. * refactor(catalog): give the preview pipeline one lookup and one entrypoint guard Follow-up on the same branch, no behaviour change: 42 tests still pass and `sync-demo-variables --check` still reports all 168 components clean. The payload generator and the demo sync had each grown their own copy of "given a component directory, find the snippet and the demo". Both now call `componentFiles`, which is the same duplication-by-copying that broke the previews in the first place. Both catalog generators also carried a byte-identical 12-line guard for "only run main() when this file is the entrypoint". That clone was already in the tree, but nothing had touched both files at once before, so it had never surfaced. It is now `runAsCommand`, and the sync script's variant of the same condition is `isEntrypoint`. The rest is flattening: the layering guards read as a table of conditions instead of a chain, the reporting splits by what it reports, and the entry resolution comes out of `buildPayload` rather than being spliced into it. Also runs the formatter over the demos this branch rewrote. Whitespace only, and `notes-typing` is the only component demo that renders pre-formatted text, which this does not touch.
1 line
6.8 KiB
JSON
1 line
6.8 KiB
JSON
{"html":"<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n <title>Matrix Decode - Demo</title>\n <script src=\"https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js\"></script>\n <style>\n * {\n box-sizing: border-box;\n }\n html,\n body {\n margin: 0;\n width: 1920px;\n height: 1080px;\n overflow: hidden;\n }\n #demo {\n width: 1920px;\n height: 1080px;\n display: grid;\n place-items: center;\n background: #f4f4f5;\n font-family: Inter, system-ui, sans-serif;\n }\n /* ponytail: scale on wrapper (not a GSAP target), zooms content ~3× for thumbnail legibility */\n .demo-frame {\n display: grid;\n place-items: center;\n gap: 32px;\n padding: 72px 96px;\n background: #18181b;\n border-radius: 20px;\n box-shadow: 0 32px 80px rgba(0, 0, 0, 0.22);\n transform: scale(3.2);\n transform-origin: center center;\n }\n .demo-label {\n font-size: 13px;\n font-weight: 500;\n letter-spacing: 0.12em;\n text-transform: uppercase;\n color: #71717a;\n }\n .hf-catalog-matrix-decode {\n display: inline-flex;\n gap: 4px;\n font:\n 700 52px/1 ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #4ade80;\n text-shadow: 0 0 24px rgba(74, 222, 128, 0.45);\n }\n .hf-catalog-matrix-decode span {\n display: inline-block;\n min-width: 0.64em;\n opacity: var(--hf-matrix-opacity, 1);\n }\n </style>\n </head>\n <body>\n <div\n id=\"demo\"\n data-composition-id=\"matrix-decode-demo\"\n data-start=\"0\"\n data-width=\"1920\"\n data-height=\"1080\"\n data-duration=\"5\"\n >\n <div class=\"demo-frame\">\n <div class=\"demo-label\">Matrix Decode</div>\n <div class=\"hf-catalog-matrix-decode\" data-final=\"HYPERFRAMES\" data-composition-variables='[\n { \"id\": \"text\", \"type\": \"string\", \"role\": \"content\", \"label\": \"Target text\", \"description\": \"Word the scramble resolves into. One scrambling cell per character, up to 32.\", \"default\": \"HYPERFRAMES\" },\n { \"id\": \"accent\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Accent\", \"description\": \"Colour family of the cells and their glow.\", \"default\": \"green\", \"options\": [{ \"value\": \"green\", \"label\": \"Green\" }, { \"value\": \"blue\", \"label\": \"Blue\" }, { \"value\": \"violet\", \"label\": \"Violet\" }] },\n { \"id\": \"size\", \"type\": \"number\", \"role\": \"style\", \"label\": \"Size\", \"description\": \"Type size of the cells in pixels. Cell width follows it.\", \"default\": 64, \"min\": 24, \"max\": 160, \"step\": 4, \"unit\": \"px\" },\n { \"id\": \"glow\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Glow\", \"description\": \"Strength of the halo behind the cells, from none to a heavy bloom.\", \"default\": \"standard\", \"options\": [{ \"value\": \"none\", \"label\": \"None\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"strong\", \"label\": \"Strong\" }] }\n ]'>\n <span>0</span><span>0</span><span>0</span><span>0</span><span>0</span><span>0</span\n ><span>0</span><span>0</span><span>0</span><span>0</span>\n </div>\n </div>\n <script>\n (function () {\n \"use strict\";\n\n var vars =\n window.__hyperframes && window.__hyperframes.getVariables\n ? window.__hyperframes.getVariables()\n : {};\n\n // Anything missing or invalid returns to its declared default.\n var accents = {\n green: { color: \"#16a34a\", rgb: \"22, 163, 74\" },\n blue: { color: \"#2563eb\", rgb: \"37, 99, 235\" },\n violet: { color: \"#7c3aed\", rgb: \"124, 58, 237\" },\n };\n var glows = {\n none: { radius: \"0px\", alpha: \"0\" },\n standard: { radius: \"18px\", alpha: \"0.28\" },\n strong: { radius: \"34px\", alpha: \"0.55\" },\n };\n\n function pick(table, value, fallback) {\n return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;\n }\n\n var text = typeof vars.text === \"string\" ? vars.text.trim().slice(0, 32) : \"\";\n if (!text) {\n text = \"HYPERFRAMES\";\n }\n\n var size =\n typeof vars.size === \"number\" || typeof vars.size === \"string\" ? Number(vars.size) : NaN;\n size = isFinite(size) && size > 0 ? Math.min(160, Math.max(24, size)) : 64;\n\n var accent = accents[pick(accents, vars.accent, \"green\")];\n var glow = glows[pick(glows, vars.glow, \"standard\")];\n\n var roots = document.querySelectorAll(\".hf-catalog-matrix-decode\");\n for (var i = 0; i < roots.length; i += 1) {\n roots[i].style.setProperty(\"--hf-matrix-size\", size + \"px\");\n roots[i].style.setProperty(\"--hf-matrix-color\", accent.color);\n roots[i].style.setProperty(\"--hf-matrix-glow-rgb\", accent.rgb);\n roots[i].style.setProperty(\"--hf-matrix-glow-radius\", glow.radius);\n roots[i].style.setProperty(\"--hf-matrix-glow-alpha\", glow.alpha);\n roots[i].setAttribute(\"data-final\", text);\n while (roots[i].firstChild) {\n roots[i].removeChild(roots[i].firstChild);\n }\n for (var j = 0; j < text.length; j += 1) {\n var cell = document.createElement(\"span\");\n cell.textContent = text.charAt(j) === \" \" ? \"\\u00a0\" : \"0\";\n roots[i].appendChild(cell);\n }\n }\n })();\n</script>\n<script>\n const tl = gsap.timeline({ paused: true });\n const startTime = 0.5;\n tl.fromTo(\n \".hf-catalog-matrix-decode span\",\n { opacity: 0, y: 12 },\n { opacity: 1, y: 0, duration: 0.18, stagger: 0.035, ease: \"power2.out\" },\n startTime,\n );\n tl.set({}, {}, 5);\n window.__timelines = window.__timelines || {};\n window.__timelines[\"matrix-decode-demo\"] = tl;\n </script>\n </div>\n <style>\n .hf-catalog-matrix-decode {\n color: #18181b;\n font-family: Inter, system-ui, sans-serif;\n font-weight: 900;\n letter-spacing: -0.04em;\n }\n .hf-catalog-matrix-decode {\n display: inline-flex;\n gap: 3px;\n font:\n 900 64px/1 ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n font-size: var(--hf-matrix-size, 64px);\n color: var(--hf-matrix-color, #16a34a);\n text-shadow: 0 0 var(--hf-matrix-glow-radius, 18px)\n rgba(var(--hf-matrix-glow-rgb, 22, 163, 74), var(--hf-matrix-glow-alpha, 0.28));\n }\n .hf-catalog-matrix-decode span {\n display: inline-block;\n min-width: 0.64em;\n opacity: var(--hf-matrix-opacity, 1);\n }\n</style>\n</body>\n</html>\n"} |