Files
hyperframes/registry/components/soft-blur-in/demo.html
Miguel Ángel 406bf316a3 fix(catalog): make component previews answer their variables panel (#3323)
* 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.
2026-08-18 01:37:46 -04:00

151 lines
5.9 KiB
HTML
Vendored

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=1920, height=1080" />
<title>Soft Blur In - 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;
}
body {
background: #101418;
font-family: Inter, system-ui, sans-serif;
}
#demo {
position: relative;
width: 1920px;
height: 1080px;
overflow: hidden;
background:
radial-gradient(circle at 25% 20%, #3b5b7a 0, transparent 30%),
linear-gradient(135deg, #101418, #20282f);
color: white;
}
.wrap {
position: absolute;
left: 180px;
top: 310px;
width: 1200px;
}
.eyebrow {
color: #80d9ff;
font-size: 40px;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.title {
margin-top: 28px;
font-size: 132px;
line-height: 0.92;
font-weight: 850;
letter-spacing: -0.02em;
}
.copy {
margin-top: 42px;
width: 780px;
color: #d7e3ea;
font-size: 42px;
line-height: 1.18;
}
.hf-soft-blur-in {
opacity: 0;
transform: translate3d(0, 28px, 0);
filter: blur(18px);
will-change: transform, opacity, filter;
}
</style>
</head>
<body>
<div
id="demo"
data-composition-id="soft-blur-in-demo"
data-width="1920"
data-height="1080"
data-duration="5"
data-composition-variables='[
{ "id": "distance", "type": "enum", "role": "motion", "label": "Distance", "description": "How far the element is offset before it slides home: 14px, 28px or 52px.", "default": "standard", "options": [{ "value": "close", "label": "Close" }, { "value": "standard", "label": "Standard" }, { "value": "far", "label": "Far" }] },
{ "id": "direction", "type": "enum", "role": "motion", "label": "Direction", "description": "up starts the element below its resting place so it rises in, down starts it above so it drops in.", "default": "up", "options": [{ "value": "up", "label": "Up" }, { "value": "down", "label": "Down" }] },
{ "id": "blur", "type": "enum", "role": "style", "label": "Blur", "description": "Starting blur radius, from a light haze to a full smear.", "default": "standard", "options": [{ "value": "soft", "label": "Soft" }, { "value": "standard", "label": "Standard" }, { "value": "heavy", "label": "Heavy" }] }
]'
>
<div class="wrap">
<div class="eyebrow hf-soft-blur-in">Motion Primitive</div>
<div class="title hf-soft-blur-in">Soft blur reveals that feel cinematic.</div>
<div class="copy hf-soft-blur-in">
Use it for titles, labels, stats, and scene intros without adding a framework.
</div>
</div>
<script>
(function () {
"use strict";
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
// Unrecognised overrides return to their declared defaults.
function pick(table, value, fallback) {
return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;
}
var distances = { close: 14, standard: 28, far: 52 };
var directions = { up: 1, down: -1 };
var blurs = { soft: 8, standard: 18, heavy: 34 };
var distance = distances[pick(distances, vars.distance, "standard")];
var direction = directions[pick(directions, vars.direction, "up")];
var blur = blurs[pick(blurs, vars.blur, "standard")];
// Set on the root so every element carrying the class inherits the values,
// whether it exists yet or not.
var root = document.documentElement;
root.style.setProperty("--hf-soft-blur-y", distance * direction + "px");
root.style.setProperty("--hf-soft-blur-radius", blur + "px");
})();
</script>
<script>
const tl = gsap.timeline({ paused: true });
tl.to(
".hf-soft-blur-in",
{
opacity: 1,
y: 0,
filter: "blur(0px)",
duration: 0.8,
ease: "power3.out",
stagger: 0.12,
},
0.35,
);
window.__timelines = window.__timelines || {};
window.__timelines["soft-blur-in-demo"] = tl;
</script>
</div>
<style
data-composition-variables='[
{ "id": "distance", "type": "enum", "role": "motion", "label": "Distance", "description": "How far the element is offset before it slides home: 14px, 28px or 52px.", "default": "standard", "options": [{ "value": "close", "label": "Close" }, { "value": "standard", "label": "Standard" }, { "value": "far", "label": "Far" }] },
{ "id": "direction", "type": "enum", "role": "motion", "label": "Direction", "description": "up starts the element below its resting place so it rises in, down starts it above so it drops in.", "default": "up", "options": [{ "value": "up", "label": "Up" }, { "value": "down", "label": "Down" }] },
{ "id": "blur", "type": "enum", "role": "style", "label": "Blur", "description": "Starting blur radius, from a light haze to a full smear.", "default": "standard", "options": [{ "value": "soft", "label": "Soft" }, { "value": "standard", "label": "Standard" }, { "value": "heavy", "label": "Heavy" }] }
]'
>
.hf-soft-blur-in {
opacity: 0;
transform: translate3d(0, var(--hf-soft-blur-y, 28px), 0);
filter: blur(var(--hf-soft-blur-radius, 18px));
will-change: transform, opacity, filter;
}
</style>
</body>
</html>