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.
190 lines
7.2 KiB
HTML
Vendored
190 lines
7.2 KiB
HTML
Vendored
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=1920, height=1080" />
|
|
<title>Perspective Marquee - Demo</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
width: 1920px;
|
|
height: 1080px;
|
|
overflow: hidden;
|
|
}
|
|
#demo {
|
|
width: 1920px;
|
|
height: 1080px;
|
|
display: grid;
|
|
place-items: center;
|
|
background: #f7f7f8;
|
|
font-family: Inter, system-ui, sans-serif;
|
|
}
|
|
.demo-frame {
|
|
display: grid;
|
|
place-items: center;
|
|
/* ponytail: scale on wrapper — GSAP only targets the inner div, so CSS transform is safe here */
|
|
transform: scale(3);
|
|
}
|
|
.hf-catalog-perspective-marquee {
|
|
color: #18181b;
|
|
font-family: Inter, system-ui, sans-serif;
|
|
font-weight: 900;
|
|
letter-spacing: -0.04em;
|
|
}
|
|
.hf-catalog-perspective-marquee {
|
|
width: 580px;
|
|
perspective: 900px;
|
|
overflow: hidden;
|
|
transform: rotateX(18deg);
|
|
}
|
|
.hf-catalog-perspective-marquee div {
|
|
display: inline-flex;
|
|
gap: 22px;
|
|
white-space: nowrap;
|
|
transform: translateX(var(--hf-marquee-x, 0px));
|
|
}
|
|
.hf-catalog-perspective-marquee span {
|
|
padding: 12px 18px;
|
|
border-radius: 999px;
|
|
background: #18181b;
|
|
color: #fff;
|
|
font-size: 28px;
|
|
box-shadow: 0 18px 44px rgba(24, 24, 27, 0.18);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div
|
|
id="demo"
|
|
data-composition-id="perspective-marquee-demo"
|
|
data-start="0"
|
|
data-width="1920"
|
|
data-height="1080"
|
|
data-duration="5"
|
|
>
|
|
<div class="demo-frame">
|
|
<div
|
|
class="hf-catalog-perspective-marquee"
|
|
data-composition-variables='[
|
|
{ "id": "tilt", "type": "enum", "role": "style", "label": "Tilt", "description": "How far the marquee plane leans back toward the horizon.", "default": "standard", "options": [{ "value": "flat", "label": "Flat" }, { "value": "standard", "label": "Standard" }, { "value": "steep", "label": "Steep" }] },
|
|
{ "id": "travel", "type": "enum", "role": "motion", "label": "Travel", "description": "Scales the offset the timeline drives, so the strip covers a shorter or longer run in the same time.", "default": "standard", "options": [{ "value": "short", "label": "Short" }, { "value": "standard", "label": "Standard" }, { "value": "long", "label": "Long" }] },
|
|
{ "id": "tone", "type": "enum", "role": "style", "label": "Tone", "description": "Pill colour: ink for light frames, paper for dark ones, accent rides the brand token.", "default": "ink", "options": [{ "value": "ink", "label": "Ink" }, { "value": "paper", "label": "Paper" }, { "value": "accent", "label": "Accent" }] },
|
|
{ "id": "words", "type": "string", "role": "content", "label": "Words", "description": "Comma separated pill labels. The list is laid down twice so the strip still reads as a continuous loop.", "default": "COMPONENTS, PRIMITIVES, TRANSITIONS, AGENTS" }
|
|
]'
|
|
>
|
|
<div>
|
|
<span>COMPONENTS</span><span>PRIMITIVES</span><span>TRANSITIONS</span><span>AGENTS</span
|
|
><span>COMPONENTS</span><span>PRIMITIVES</span><span>TRANSITIONS</span
|
|
><span>AGENTS</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
// Unrecognised overrides return to their declared defaults.
|
|
var tilts = { flat: "6deg", standard: "18deg", steep: "34deg" };
|
|
var reaches = { short: 0.55, standard: 1, long: 1.8 };
|
|
var tones = {
|
|
ink: { bg: "#18181b", fg: "#fff" },
|
|
paper: { bg: "#fafafa", fg: "#18181b" },
|
|
accent: { bg: "var(--brand, #34d399)", fg: "#fff" },
|
|
};
|
|
var defaultWords = "COMPONENTS, PRIMITIVES, TRANSITIONS, AGENTS";
|
|
|
|
function pick(table, value, fallback) {
|
|
return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;
|
|
}
|
|
|
|
function parseWords(value) {
|
|
var source = typeof value === "string" ? value : "";
|
|
var parts = source.split(",");
|
|
var words = [];
|
|
for (var i = 0; i < parts.length; i += 1) {
|
|
var word = parts[i].trim();
|
|
if (word) words.push(word);
|
|
}
|
|
return words.length ? words : parseWords(defaultWords);
|
|
}
|
|
|
|
var tilt = tilts[pick(tilts, vars.tilt, "standard")];
|
|
var reach = reaches[pick(reaches, vars.travel, "standard")];
|
|
var tone = tones[pick(tones, vars.tone, "ink")];
|
|
var words = parseWords(vars.words);
|
|
|
|
var roots = document.querySelectorAll(".hf-catalog-perspective-marquee");
|
|
for (var i = 0; i < roots.length; i += 1) {
|
|
roots[i].style.setProperty("--hf-marquee-tilt", tilt);
|
|
roots[i].style.setProperty("--hf-marquee-reach", String(reach));
|
|
roots[i].style.setProperty("--hf-marquee-pill-bg", tone.bg);
|
|
roots[i].style.setProperty("--hf-marquee-pill-fg", tone.fg);
|
|
|
|
var strip = roots[i].querySelector("div");
|
|
if (!strip) continue;
|
|
var markup = "";
|
|
for (var pass = 0; pass < 2; pass += 1) {
|
|
for (var w = 0; w < words.length; w += 1) {
|
|
markup +=
|
|
"<span>" + words[w].replace(/&/g, "&").replace(/</g, "<") + "</span>";
|
|
}
|
|
}
|
|
strip.innerHTML = markup;
|
|
}
|
|
})();
|
|
</script>
|
|
<script>
|
|
const tl = gsap.timeline({ paused: true });
|
|
const startTime = 0.5;
|
|
tl.fromTo(
|
|
".hf-catalog-perspective-marquee div",
|
|
{ "--hf-marquee-x": "0px" },
|
|
{ "--hf-marquee-x": "-360px", duration: 4.5, ease: "none" },
|
|
startTime,
|
|
);
|
|
tl.set({}, {}, 5);
|
|
window.__timelines = window.__timelines || {};
|
|
window.__timelines["perspective-marquee-demo"] = tl;
|
|
</script>
|
|
</div>
|
|
<style>
|
|
.hf-catalog-perspective-marquee {
|
|
color: #18181b;
|
|
font-family: Inter, system-ui, sans-serif;
|
|
font-weight: 900;
|
|
letter-spacing: -0.04em;
|
|
}
|
|
.hf-catalog-perspective-marquee {
|
|
width: 720px;
|
|
perspective: 900px;
|
|
overflow: hidden;
|
|
transform: rotateX(var(--hf-marquee-tilt, 18deg));
|
|
}
|
|
.hf-catalog-perspective-marquee div {
|
|
display: inline-flex;
|
|
gap: 22px;
|
|
white-space: nowrap;
|
|
transform: translateX(calc(var(--hf-marquee-x, 0px) * var(--hf-marquee-reach, 1)));
|
|
}
|
|
.hf-catalog-perspective-marquee span {
|
|
padding: 12px 18px;
|
|
border-radius: 999px;
|
|
background: var(--hf-marquee-pill-bg, #18181b);
|
|
color: var(--hf-marquee-pill-fg, #fff);
|
|
font-size: 28px;
|
|
box-shadow: 0 18px 44px rgba(24, 24, 27, 0.18);
|
|
}
|
|
</style>
|
|
</body>
|
|
</html>
|