Files
hyperframes/docs/catalog/components/light-sweep-pass.mdx
Miguel ÁngelandMiguel Angel Simon Sierra 1ae2067b8d feat(catalog): put the variables panel back, on payloads (#3199)
* feat(catalog): put the variables panel back, on payloads

The panel drove its preview by loading an .html from docs/public, a type the
host does not publish, so it showed an empty frame in production and was
parked when the catalog was re-landed.

It now mounts the same JSON payload the plain player uses and re-mounts it as
values change, injecting them as window.__hfVariables into the composition head
before any of its scripts run, which is where the runtime reads overrides from.
Doing it in the markup rather than after load is what stops the composition
initialising with the wrong values first.

172 items with variables get the panel back; the playhead carries across a
change so a tweak mid-shot does not jump back to frame zero.

* fix(docs): drop the unused url form and the needless escapes

* fix(docs): the panel cannot reference a binding beside the export

* feat(catalog): make importing an SVG the obvious move

A reader arrives at this control with a shape, not with path data, and the
panel asked for the coordinates first. Import is now the primary action in a
drop target you can see is a drop target, and the raw path sits behind a
disclosure for anyone who wants it.

* feat(cli): let a fruitless catalog search report the gap

An agent that searches by meaning and finds nothing worth installing knows
something we do not: the name of a move the catalog is missing. There was no
way to tell us, so that knowledge was lost at the end of every run.

hyperframes feedback --search-miss "<query>" --wanted "<the move>" records it.
It carries no rating, so it never lands in the rating metric, and it is a
separate deliberate command rather than something catalog --query does on its
own: plain search still sends nothing, which is what the CLI promises.

--rating stops being required at the arg level, since a miss has no rating to
give. The check moved into the run body, where an absent one is now handled
rather than crashing on undefined.

* feat(cli): carry tuned variable values into the install snippet

Someone who tunes a block on its catalog page had no way to keep those values:
the install command was the same one everybody gets, and the tuning stayed on
the page.

hyperframes add <item> --vars '<json>' now prints a mount element carrying
data-variable-values, so the values land where the block is used.

They ride on the host rather than being written into the installed file. That
keeps the composition on disk byte-identical to the registry's, so a later
reinstall can still tell an edit from an update, and it lets two mounts of the
same block carry different values.

* fix(catalog): serve the item's own directory so runtime paths resolve

Some compositions assemble their asset URLs at run time —
"compositions/components/" + texture + ".png" for the texture masks, a font the
compiler pulled into _remote_media — and no scan of the markup can see a string
that does not exist until a script concatenates it. Those items either rendered
black or were dropped to a video that had never been uploaded.

Each item that needs it now has its prepared directory published, and its
payload carries a <base> pointing at it, so any relative path the composition
invents resolves. caption-texture renders its masks again, and
variable-font-flex has a preview at all for the first time: its MP4 and poster
are both 403.

Both layouts are published, because which one a composition asks for differs
per item, and a directory only earns that if it is under 2 MB. The 12 MB
texture sheet keeps the recorded video it already had.

* fix(catalog): let the variables panel actually drive the composition

Every control on the panel was inert. The values reached the composition and
nothing repainted, because the payload had already been compiled: compiling
inlines a mounted component and resolves its variables into the markup and CSS,
so by the time a reader turns a knob there is nothing left to change.

An item that declares variables now ships uncompiled, keeping the mount the
runtime loads at run time, which is the only state where data-variable-values
still means anything. The component travels inline as a data URI rather than a
sibling file, because .html is the one type the docs host will not publish. The
demo's own pinned values come off, so the reader's choices reach the mount
instead of losing to the values the demo picked to show itself off.

Measured on the rendered frame rather than the DOM: green rgb(98,207,144),
blue rgb(6,6,199), violet rgb(177,147,230), and back to green.

docs/public/catalog drops from 48 MB to 35 MB along the way, since an
uncompiled payload carries far less than an inlined one.

* feat(catalog): keep variable changes in the url

A reader who tuned a piece lost it on reload, and had nothing to send anyone.
The values now live in the query string, scoped by composition id so two links
never read each other,and only the ones that differ from the defaults are
written, so changing one knob gives a short URL rather than every variable
spelled out.

replaceState rather than pushState: dragging a slider should not leave a trail
of history entries. An unreadable value is ignored rather than thrown, so a
truncated or hand-edited link opens the piece at its defaults.

* fix(catalog): only rewrite the url when a value actually changed

* refactor(catalog): memoise the declared defaults on their content

* feat(catalog): offer an install command carrying the tuned values

The Install block is generated before anyone touches a knob, so it can only
ever print the plain command. Someone who spent a minute tuning a piece copied
it and got the defaults back.

The panel now carries its own command in the Snippet tab, with --vars holding
exactly the values that differ. An untouched piece still offers the same short
command, so nothing gets noisier for the common case.

* fix(catalog): a piece with nothing to render is a skip, not a failure

caption-blend-difference is a stylesheet and a paragraph of prose — a class you
add to your own captions, with no standalone scene to show. The generator
treated that as a build failure, so every run ended by reporting something
broken when nothing was.

It now reports the shape it is and keeps its recorded video, which is the only
honest preview such an item has. A genuine render failure still throws.

* fix(catalog): restore variables from the url on a cold load

A shared link opened at the defaults. The first render happens on the server,
where there is no window to read the query string from, and React then hydrates
against that markup and never revisits it — so the values only appeared once you
touched a control.

The URL is read again after mount, which is the first moment it exists. The
value is also escaped once now rather than twice: URLSearchParams already
decodes on the way out, and decoding a second time turned an SVG path full of
percent-escapes into something that no longer parsed, besides doubling the
length of every link.

* fix(catalog): mount the preview with the values a link carried

The frame was built from the declared defaults and the shared values were
posted to it afterwards, which is too late for anything the composition reads
once at init: a path arrived after the mark had already been drawn from the
default one, so a link looked right in the panel and wrong on screen.

* feat(catalog): the install command follows the values you tuned

Copying the Install line gave the plain command back, because that block is
generated before anyone touches a knob and had no way to know what changed. The
tuned command only existed in the panel Snippet tab, which is not where anyone
looks for it.

The line now reads the same query string the panel writes, so the two agree
without either component knowing the other exists, and a shared link carries the
right command too. replaceState fires no event, so the panel announces its own
writes.

* fix(catalog): send a text variable to the preview once it is finished

Every other control in the explorer reports a whole value on every event: a
slider at any position is a position, a swatch is a colour. A text field is
not. Typing v3 into a badge posted v first, so the preview remounted and
rendered a composition built from half a word.

The post now waits while a text field has focus and goes out when the edit is
committed, with Enter or by clicking away. The field itself is unchanged and
still tracks every keystroke.

---------

Co-authored-by: Miguel Angel Simon Sierra <miguelangelsi07@gmail.com>
2026-08-10 22:40:01 -04:00

1030 lines
42 KiB
Plaintext

---
title: "Light Sweep Pass"
description: "A traveling key light re-shades a slotted scene: a soft diagonal gradient band crosses the frame once while every per-element highlight and shadow shifts in lockstep (all driven by one --light-x property), then the light settles into a resting key. Quiet, expensive-feeling; the scene itself never moves. Callers fill the named scene slot; a token hero-and-cards default renders when it is left empty."
---
import { InstallCommand } from "/snippets/install-command.jsx";
import { VariablesExplorer } from "/snippets/variables-explorer.jsx";
<VariablesExplorer
previewSrc="/public/catalog/components/light-sweep-pass.json"
compositionId="light-sweep-pass"
compositionSrc="compositions/components/light-sweep-pass.html"
variables={[{"id":"angle","type":"number","role":"style","label":"Angle","description":"Band and highlight gradient angle in degrees.","default":115,"min":60,"max":160,"step":1,"unit":"deg"},{"id":"sweep_at","type":"number","role":"timing","label":"Sweep start","description":"Seconds after mount start when the band starts crossing.","default":0.9,"min":0,"max":8,"step":0.05,"unit":"s"},{"id":"strength","type":"enum","role":"style","label":"Strength","description":"Band opacity and highlight bloom multiplier.","default":"standard","options":[{"value":"subtle","label":"Subtle"},{"value":"standard","label":"Standard"}]},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Tint inside the band and the highlight blooms.","default":"green","options":[{"value":"green","label":"Green"},{"value":"blue","label":"Blue"},{"value":"violet","label":"Violet"}]},{"id":"exit","type":"enum","role":"timing","label":"Exit","description":"Outgoing transition. None holds the settled key.","default":"none","options":[{"value":"none","label":"None"},{"value":"fade","label":"Fade"},{"value":"up","label":"Up"}]}]}
>
```html light-sweep-pass.html
<!doctype html>
<!--
light-sweep-pass: HyperFrames video primitive (overlays / light)
Concept: a traveling key light re-shades a slotted scene. A soft diagonal
gradient band crosses the frame once while every per-element highlight and
shadow shifts in lockstep, then the light settles into a resting key from
the upper third. Quiet, expensive-feeling; the scene itself never moves.
Wave L, unit L3. Reference: motion-reference/ordinaryfolkco
2001090228958752945 (the traveling light band re-shading the frame).
ONE PROPERTY OWNS THE PASS: --light-x (a unitless 0-100-ish scalar on
#root) is the only animated value. The band's translate, every element's
highlight bloom, every shadow offset, and the ambient lift all read it
through calc()/clamp()/max() in static CSS. The timeline tweens a plain
JS number proxy and writes --light-x in onUpdate (never a var() string),
so seeks in any order resolve the same computed styles.
Slot (see README.md for a worked example):
- [data-slot="scene"]: the full-bleed scene being lit. Replace the
children of this element in your installed copy. Default: a token
hero card and three feature cards. Elements opt into the light with
the data-lit attribute plus an inline --lsp-x (their center along
the sweep axis, percent of frame width).
Variables (declared in data-composition-variables below):
- angle (number, degrees, default 115, 60 to 160): band and highlight
gradient angle. 115 reads as upper-left key light.
- sweep_at (number, seconds, default 0.9): when the band starts
crossing, relative to mount start.
- strength (subtle | standard, default standard): band opacity and
highlight bloom multiplier. subtle is the barely-there pass.
- accent (green | blue | violet, default green): warm tint inside the
band and the highlight blooms. green maps to --brand, blue to
--accent, violet to --accent-2.
- exit (none | fade | up, default none): outgoing transition. none
holds the settled key (frame roots own transitions).
Envelope (fixed IN/OUT, elastic HOLD only, never gsap.timeScale()):
IN = sweep_at + 1.60s crossing + 0.55s settle to the resting key
HOLD = elastic = max(0, D - (IN + OUT)); the settled key is still
OUT = 0.50s when exit is fade or up, 0 when exit is none
If D < IN + OUT, IN and OUT scale down together so IN + OUT == D.
Sync point: sweep-land when the light reaches its resting key (3.05s at
defaults). Dispatches a bubbling hf:sfx CustomEvent with id
"light-settle-soft" there. This primitive never plays audio.
Mount contract: MOUNTABLE SUB-COMPOSITION. The runtime clones only
<template> contents; #root fills the host box (inset:0, container-type:
size), has no data-width/data-height, and registers one paused timeline
under the literal "light-sweep-pass" key. Variables come from
window.__hyperframes.getVariables().
-->
<html
lang="en"
data-composition-id="light-sweep-pass"
data-composition-duration="4"
data-composition-variables='[
{ "id": "angle", "type": "number", "role": "style", "label": "Angle", "description": "Band and highlight gradient angle in degrees.", "default": 115, "min": 60, "max": 160, "step": 1, "unit": "deg" },
{ "id": "sweep_at", "type": "number", "role": "timing", "label": "Sweep start", "description": "Seconds after mount start when the band starts crossing.", "default": 0.9, "min": 0, "max": 8, "step": 0.05, "unit": "s" },
{ "id": "strength", "type": "enum", "role": "style", "label": "Strength", "description": "Band opacity and highlight bloom multiplier.", "default": "standard", "options": [{ "value": "subtle", "label": "Subtle" }, { "value": "standard", "label": "Standard" }] },
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Tint inside the band and the highlight blooms.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
{ "id": "exit", "type": "enum", "role": "timing", "label": "Exit", "description": "Outgoing transition. None holds the settled key.", "default": "none", "options": [{ "value": "none", "label": "None" }, { "value": "fade", "label": "Fade" }, { "value": "up", "label": "Up" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Light Sweep Pass</title>
</head>
<body>
<template>
<div id="root" data-composition-id="light-sweep-pass" data-duration="4" data-fps="30">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
/* --light-x starts off-frame left; the timeline is its only
writer. --lsp-angle and --lsp-strength are set once at mount. */
#root {
--light-x: -35;
--lsp-angle: 115;
--lsp-strength: 1;
position: absolute;
inset: 0;
container-type: size;
isolation: isolate;
overflow: hidden;
background: var(--bg, #0b0c0e);
color: var(--fg, #f8fafc);
font-family: var(--font-body, Inter, system-ui, sans-serif);
}
.lsp-clip,
.lsp-stage,
.lsp-scene,
.lsp-ambient,
.lsp-band {
position: absolute;
inset: 0;
}
.lsp-clip {
overflow: hidden;
}
.lsp-stage {
opacity: 0;
}
.lsp-scene {
overflow: hidden;
}
/* Every lit element derives its whole treatment from the ONE
--light-x scalar: distance d to the band, |d| via max(d, -d),
a 0..1 proximity bloom, a shadow that slides away from the
light and deepens as the band passes. Elements opt in with
data-lit and an inline --lsp-x (center along the sweep axis,
percent of frame width). */
[data-lit] {
--lsp-d: calc(var(--light-x) - var(--lsp-x, 50));
--lsp-abs: max(var(--lsp-d), calc(-1 * var(--lsp-d)));
--lsp-glow: clamp(0, calc(1 - var(--lsp-abs) / 26), 1);
position: relative;
box-shadow: calc(clamp(-30, var(--lsp-d), 30) * -0.05cqw)
calc(0.8cqh + var(--lsp-glow) * 0.7cqh) calc(2.2cqh + var(--lsp-glow) * 2.4cqh)
color-mix(in srgb, #000000 26%, transparent);
}
/* The highlight bloom: a static angle-matched gradient whose
opacity is the proximity term. No transitions, no tweens. */
[data-lit]::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
color-mix(in srgb, #ffffff 86%, var(--lsp-accent, #22c55e)) 0%,
transparent 62%
);
opacity: calc(var(--lsp-glow) * 0.32 * var(--lsp-strength));
}
/* Ambient lift: the scene starts a touch dim and brightens for
good once the band has entered the frame. Monotonic in
--light-x, so the settle never re-dims it. */
.lsp-ambient {
pointer-events: none;
background: #000000;
opacity: calc(clamp(0, (26 - var(--light-x)) / 130, 0.16) * var(--lsp-strength));
}
/* The band: an oversized angle-matched gradient sheet that only
ever translates along X, driven by the same scalar. Screen
blend keeps it a light, never a paint. */
.lsp-band {
inset: -55%;
pointer-events: none;
mix-blend-mode: screen;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
transparent 36%,
color-mix(in srgb, #ffffff 24%, transparent) 46%,
color-mix(in srgb, #ffffff 78%, var(--lsp-accent, #22c55e)) 50%,
color-mix(in srgb, #ffffff 24%, transparent) 54%,
transparent 64%
);
opacity: 0;
transform: translateX(calc((var(--light-x) - 50) * 1.4cqw));
will-change: transform, opacity;
}
#root[data-strength="subtle"] {
--lsp-strength: 0.55;
}
/* ---------- default slot scene: token hero + three cards ---------- */
.lsp-default {
position: absolute;
inset: 0;
display: grid;
grid-template-rows: auto auto;
align-content: center;
justify-items: center;
row-gap: var(--space-3, 5cqh);
padding: var(--space-3, 6cqh) 10cqw;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
color-mix(in srgb, var(--fg, #f8fafc) 3%, var(--bg, #0b0c0e)) 0%,
var(--bg, #0b0c0e) 55%,
color-mix(in srgb, #000000 6%, var(--bg, #0b0c0e)) 100%
);
}
.lsp-hero {
display: grid;
align-content: center;
row-gap: var(--space-2, 2.4cqh);
width: 58cqw;
height: 30cqh;
padding: var(--space-3, 4cqh) var(--space-3, 3cqw);
border: 0.16cqw solid var(--border, #343a46);
border-radius: var(--radius, 2.4cqmin);
background: var(--surface, #14171c);
}
.lsp-hero-bar {
width: 46%;
height: 4.6cqh;
border-radius: 1.4cqh;
background: color-mix(in srgb, var(--fg, #f8fafc) 82%, var(--surface, #14171c));
}
.lsp-hero-line {
height: 2.2cqh;
border-radius: 1.1cqh;
background: var(--muted, #94a3b8);
opacity: 0.55;
}
.lsp-hero-line:nth-of-type(3) {
width: 72%;
}
.lsp-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
column-gap: var(--space-2, 2cqw);
width: 58cqw;
}
.lsp-card {
display: grid;
align-content: start;
row-gap: var(--space-1, 1.6cqh);
height: 24cqh;
padding: var(--space-2, 2.6cqh) var(--space-2, 1.6cqw);
border: 0.16cqw solid var(--border, #343a46);
border-radius: var(--radius, 2.4cqmin);
background: var(--surface, #14171c);
}
.lsp-dot {
width: 3.4cqh;
height: 3.4cqh;
border-radius: 50%;
background: color-mix(in srgb, var(--lsp-accent, #22c55e) 72%, var(--surface, #14171c));
}
.lsp-line {
height: 1.9cqh;
border-radius: 1cqh;
background: var(--muted, #94a3b8);
opacity: 0.5;
}
.lsp-line:nth-of-type(3) {
width: 64%;
}
</style>
<div
id="light-sweep-pass-clip"
class="lsp-clip clip"
data-start="0"
data-duration="4"
data-track-index="0"
>
<div class="lsp-stage">
<div class="lsp-scene" data-slot="scene">
<!-- SLOT "scene": replace the children of this element with
your own full-bleed content. Mark elements that should
catch the light with data-lit and give each an inline
style="--lsp-x: NN" (center along the sweep, percent). -->
<div class="lsp-default" aria-hidden="true">
<div class="lsp-hero" data-lit style="--lsp-x: 50">
<div class="lsp-hero-bar"></div>
<div class="lsp-hero-line"></div>
<div class="lsp-hero-line"></div>
</div>
<div class="lsp-row">
<div class="lsp-card" data-lit style="--lsp-x: 31">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
<div class="lsp-card" data-lit style="--lsp-x: 50">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
<div class="lsp-card" data-lit style="--lsp-x: 69">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
</div>
</div>
</div>
<div class="lsp-ambient" aria-hidden="true"></div>
<div class="lsp-band" aria-hidden="true"></div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script>
(function () {
"use strict";
var root = document.getElementById("root");
// Literal id: mount flattening strips data-composition-id from the
// live root before this timeline registers.
var compositionId = "light-sweep-pass";
var stage = root.querySelector(".lsp-stage");
var band = root.querySelector(".lsp-band");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
function clampNumber(raw, fallback, min, max) {
var value = raw == null ? fallback : Number(raw);
if (!Number.isFinite(value)) return fallback;
return Math.max(min, Math.min(max, value));
}
var angle = clampNumber(vars.angle, 115, 60, 160);
var sweepAt = clampNumber(vars.sweep_at, 0.9, 0, 8);
var strength = vars.strength === "subtle" ? "subtle" : "standard";
var accentTokens = {
green: "var(--brand, #22c55e)",
blue: "var(--accent, #38bdf8)",
violet: "var(--accent-2, #c5a3ff)",
};
var accent = Object.prototype.hasOwnProperty.call(accentTokens, vars.accent)
? vars.accent
: "green";
// The bundler mirrors composition variables as scoped CSS custom
// props, so this unit's own accent variable can shadow the contract
// --accent token ("blue" is a valid CSS color). When the shadow is
// present, fall back to the literal contract value.
var shadowedAccent = getComputedStyle(root).getPropertyValue("--accent").trim();
if (
shadowedAccent === "green" ||
shadowedAccent === "blue" ||
shadowedAccent === "violet"
) {
accentTokens.blue = "#38bdf8";
}
// INVARIANT: only none | fade | up reaches the timeline.
var exit = vars.exit === "fade" || vars.exit === "up" ? vars.exit : "none";
root.dataset.strength = strength;
root.style.setProperty("--lsp-angle", String(angle));
root.style.setProperty("--lsp-accent", accentTokens[accent]);
// RETIME RANGE: fixed IN and OUT scale together only when D is
// too short. HOLD is the sole elastic phase. Never timeScale().
var SWEEP_BASE = 1.6;
var SETTLE_BASE = 0.55;
var STAGE_IN_BASE = 0.5;
var IN_BASE = sweepAt + SWEEP_BASE + SETTLE_BASE;
var OUT_BASE = exit === "none" ? 0 : 0.5;
var duration = Math.max(0.001, parseFloat(root.dataset.duration || "4"));
var totalBase = IN_BASE + OUT_BASE;
var scale = duration < totalBase ? duration / totalBase : 1;
var SWEEP = SWEEP_BASE * scale;
var SETTLE = SETTLE_BASE * scale;
var STAGE_IN = Math.min(STAGE_IN_BASE * scale, IN_BASE * scale);
var SWEEP_AT = sweepAt * scale;
var SWEEP_END = SWEEP_AT + SWEEP;
var IN = IN_BASE * scale;
var OUT = OUT_BASE * scale;
var HOLD = Math.max(0, duration - (IN + OUT));
var OUT_START = IN + HOLD;
// The light's authored waypoints: parked off-frame left, fully
// crossed off-frame right, then the resting key in the upper
// third of the travel. All in --light-x units (frame percent).
var LIGHT_START = -35;
var LIGHT_CROSSED = 118;
var LIGHT_REST = 62;
function fireSfx(id, t) {
root.dispatchEvent(
new CustomEvent("hf:sfx", { detail: { id: id, t: t }, bubbles: true }),
);
}
// ONE proxy owns --light-x; every highlight, shadow, ambient
// lift, and the band transform read it via calc in static CSS.
var light = { x: LIGHT_START };
function writeLight() {
root.style.setProperty("--light-x", light.x.toFixed(3));
}
writeLight();
gsap.set(stage, { opacity: 0, y: "1.5cqh" });
gsap.set(band, { autoAlpha: 0 });
var tl = gsap.timeline({ paused: true });
// IN: the scene settles first, then one confident crossing.
tl.to(stage, { opacity: 1, y: "0cqh", duration: STAGE_IN, ease: "power2.out" }, 0);
tl.fromTo(
light,
{ x: LIGHT_START },
{
x: LIGHT_CROSSED,
duration: SWEEP,
ease: "sine.inOut",
onUpdate: writeLight,
},
SWEEP_AT,
);
tl.fromTo(
band,
{ autoAlpha: 0 },
{
autoAlpha: 1,
duration: Math.min(0.3 * scale, SWEEP),
ease: "power1.out",
immediateRender: false,
},
SWEEP_AT,
);
tl.to(
band,
{ autoAlpha: 0, duration: 0.35 * scale, ease: "power1.in" },
Math.max(SWEEP_AT, SWEEP_END - 0.35 * scale),
);
// The settle: the band is gone; the key light glides back to its
// resting position and the per-element shading follows it there.
tl.to(
light,
{ x: LIGHT_REST, duration: SETTLE, ease: "power2.out", onUpdate: writeLight },
SWEEP_END,
);
tl.call(
function () {
fireSfx("light-settle-soft", IN);
},
[],
IN,
);
// HOLD: deliberately still under the settled key.
// OUT: only when the exit variable asks for one.
if (exit !== "none") {
tl.to(stage, { opacity: 0, duration: OUT, ease: "power2.in" }, OUT_START);
if (exit === "up") {
tl.to(stage, { y: "-6cqh", duration: OUT, ease: "power2.in" }, OUT_START);
}
}
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines[compositionId] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</VariablesExplorer>
## Install
<InstallCommand command="npx hyperframes add light-sweep-pass" item="light-sweep-pass" />
That writes one file: `compositions/components/light-sweep-pass.html`.
## Paste it into your composition
Open `compositions/components/light-sweep-pass.html` and copy what is inside into your own composition.
A component has no size or duration of its own. It takes both from the composition
you paste it into.
## Variables
Every one of these has a default, so the piece works untouched. Set the ones you
want to change on the element:
| Variable | Default | Accepts | What it does |
| --- | --- | --- | --- |
| `angle` | `115` | 60deg to 160deg, step 1deg | Band and highlight gradient angle in degrees. |
| `sweep_at` | `0.9` | 0s to 8s, step 0.05s | Seconds after mount start when the band starts crossing. |
| `strength` | `standard` | `subtle`, `standard` | Band opacity and highlight bloom multiplier. |
| `accent` | `green` | `green`, `blue`, `violet` | Tint inside the band and the highlight blooms. |
| `exit` | `none` | `none`, `fade`, `up` | Outgoing transition. None holds the settled key. |
Set them with `data-variable-values` on the element that mounts it. These are the
defaults, so this behaves exactly like the preview above until you change one:
```html wrap
<div
data-composition-id="light-sweep-pass"
data-composition-src="compositions/components/light-sweep-pass.html"
data-variable-values='{"angle":115,"sweep_at":0.9,"strength":"standard","accent":"green","exit":"none"}'
></div>
```
## Source
<Accordion title={`light-sweep-pass.html`}>
```html
<!doctype html>
<!--
light-sweep-pass: HyperFrames video primitive (overlays / light)
Concept: a traveling key light re-shades a slotted scene. A soft diagonal
gradient band crosses the frame once while every per-element highlight and
shadow shifts in lockstep, then the light settles into a resting key from
the upper third. Quiet, expensive-feeling; the scene itself never moves.
Wave L, unit L3. Reference: motion-reference/ordinaryfolkco
2001090228958752945 (the traveling light band re-shading the frame).
ONE PROPERTY OWNS THE PASS: --light-x (a unitless 0-100-ish scalar on
#root) is the only animated value. The band's translate, every element's
highlight bloom, every shadow offset, and the ambient lift all read it
through calc()/clamp()/max() in static CSS. The timeline tweens a plain
JS number proxy and writes --light-x in onUpdate (never a var() string),
so seeks in any order resolve the same computed styles.
Slot (see README.md for a worked example):
- [data-slot="scene"]: the full-bleed scene being lit. Replace the
children of this element in your installed copy. Default: a token
hero card and three feature cards. Elements opt into the light with
the data-lit attribute plus an inline --lsp-x (their center along
the sweep axis, percent of frame width).
Variables (declared in data-composition-variables below):
- angle (number, degrees, default 115, 60 to 160): band and highlight
gradient angle. 115 reads as upper-left key light.
- sweep_at (number, seconds, default 0.9): when the band starts
crossing, relative to mount start.
- strength (subtle | standard, default standard): band opacity and
highlight bloom multiplier. subtle is the barely-there pass.
- accent (green | blue | violet, default green): warm tint inside the
band and the highlight blooms. green maps to --brand, blue to
--accent, violet to --accent-2.
- exit (none | fade | up, default none): outgoing transition. none
holds the settled key (frame roots own transitions).
Envelope (fixed IN/OUT, elastic HOLD only, never gsap.timeScale()):
IN = sweep_at + 1.60s crossing + 0.55s settle to the resting key
HOLD = elastic = max(0, D - (IN + OUT)); the settled key is still
OUT = 0.50s when exit is fade or up, 0 when exit is none
If D < IN + OUT, IN and OUT scale down together so IN + OUT == D.
Sync point: sweep-land when the light reaches its resting key (3.05s at
defaults). Dispatches a bubbling hf:sfx CustomEvent with id
"light-settle-soft" there. This primitive never plays audio.
Mount contract: MOUNTABLE SUB-COMPOSITION. The runtime clones only
<template> contents; #root fills the host box (inset:0, container-type:
size), has no data-width/data-height, and registers one paused timeline
under the literal "light-sweep-pass" key. Variables come from
window.__hyperframes.getVariables().
-->
<html
lang="en"
data-composition-id="light-sweep-pass"
data-composition-duration="4"
data-composition-variables='[
{ "id": "angle", "type": "number", "role": "style", "label": "Angle", "description": "Band and highlight gradient angle in degrees.", "default": 115, "min": 60, "max": 160, "step": 1, "unit": "deg" },
{ "id": "sweep_at", "type": "number", "role": "timing", "label": "Sweep start", "description": "Seconds after mount start when the band starts crossing.", "default": 0.9, "min": 0, "max": 8, "step": 0.05, "unit": "s" },
{ "id": "strength", "type": "enum", "role": "style", "label": "Strength", "description": "Band opacity and highlight bloom multiplier.", "default": "standard", "options": [{ "value": "subtle", "label": "Subtle" }, { "value": "standard", "label": "Standard" }] },
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Tint inside the band and the highlight blooms.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
{ "id": "exit", "type": "enum", "role": "timing", "label": "Exit", "description": "Outgoing transition. None holds the settled key.", "default": "none", "options": [{ "value": "none", "label": "None" }, { "value": "fade", "label": "Fade" }, { "value": "up", "label": "Up" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Light Sweep Pass</title>
</head>
<body>
<template>
<div id="root" data-composition-id="light-sweep-pass" data-duration="4" data-fps="30">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
/* --light-x starts off-frame left; the timeline is its only
writer. --lsp-angle and --lsp-strength are set once at mount. */
#root {
--light-x: -35;
--lsp-angle: 115;
--lsp-strength: 1;
position: absolute;
inset: 0;
container-type: size;
isolation: isolate;
overflow: hidden;
background: var(--bg, #0b0c0e);
color: var(--fg, #f8fafc);
font-family: var(--font-body, Inter, system-ui, sans-serif);
}
.lsp-clip,
.lsp-stage,
.lsp-scene,
.lsp-ambient,
.lsp-band {
position: absolute;
inset: 0;
}
.lsp-clip {
overflow: hidden;
}
.lsp-stage {
opacity: 0;
}
.lsp-scene {
overflow: hidden;
}
/* Every lit element derives its whole treatment from the ONE
--light-x scalar: distance d to the band, |d| via max(d, -d),
a 0..1 proximity bloom, a shadow that slides away from the
light and deepens as the band passes. Elements opt in with
data-lit and an inline --lsp-x (center along the sweep axis,
percent of frame width). */
[data-lit] {
--lsp-d: calc(var(--light-x) - var(--lsp-x, 50));
--lsp-abs: max(var(--lsp-d), calc(-1 * var(--lsp-d)));
--lsp-glow: clamp(0, calc(1 - var(--lsp-abs) / 26), 1);
position: relative;
box-shadow: calc(clamp(-30, var(--lsp-d), 30) * -0.05cqw)
calc(0.8cqh + var(--lsp-glow) * 0.7cqh) calc(2.2cqh + var(--lsp-glow) * 2.4cqh)
color-mix(in srgb, #000000 26%, transparent);
}
/* The highlight bloom: a static angle-matched gradient whose
opacity is the proximity term. No transitions, no tweens. */
[data-lit]::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
color-mix(in srgb, #ffffff 86%, var(--lsp-accent, #22c55e)) 0%,
transparent 62%
);
opacity: calc(var(--lsp-glow) * 0.32 * var(--lsp-strength));
}
/* Ambient lift: the scene starts a touch dim and brightens for
good once the band has entered the frame. Monotonic in
--light-x, so the settle never re-dims it. */
.lsp-ambient {
pointer-events: none;
background: #000000;
opacity: calc(clamp(0, (26 - var(--light-x)) / 130, 0.16) * var(--lsp-strength));
}
/* The band: an oversized angle-matched gradient sheet that only
ever translates along X, driven by the same scalar. Screen
blend keeps it a light, never a paint. */
.lsp-band {
inset: -55%;
pointer-events: none;
mix-blend-mode: screen;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
transparent 36%,
color-mix(in srgb, #ffffff 24%, transparent) 46%,
color-mix(in srgb, #ffffff 78%, var(--lsp-accent, #22c55e)) 50%,
color-mix(in srgb, #ffffff 24%, transparent) 54%,
transparent 64%
);
opacity: 0;
transform: translateX(calc((var(--light-x) - 50) * 1.4cqw));
will-change: transform, opacity;
}
#root[data-strength="subtle"] {
--lsp-strength: 0.55;
}
/* ---------- default slot scene: token hero + three cards ---------- */
.lsp-default {
position: absolute;
inset: 0;
display: grid;
grid-template-rows: auto auto;
align-content: center;
justify-items: center;
row-gap: var(--space-3, 5cqh);
padding: var(--space-3, 6cqh) 10cqw;
background: linear-gradient(
calc(var(--lsp-angle) * 1deg),
color-mix(in srgb, var(--fg, #f8fafc) 3%, var(--bg, #0b0c0e)) 0%,
var(--bg, #0b0c0e) 55%,
color-mix(in srgb, #000000 6%, var(--bg, #0b0c0e)) 100%
);
}
.lsp-hero {
display: grid;
align-content: center;
row-gap: var(--space-2, 2.4cqh);
width: 58cqw;
height: 30cqh;
padding: var(--space-3, 4cqh) var(--space-3, 3cqw);
border: 0.16cqw solid var(--border, #343a46);
border-radius: var(--radius, 2.4cqmin);
background: var(--surface, #14171c);
}
.lsp-hero-bar {
width: 46%;
height: 4.6cqh;
border-radius: 1.4cqh;
background: color-mix(in srgb, var(--fg, #f8fafc) 82%, var(--surface, #14171c));
}
.lsp-hero-line {
height: 2.2cqh;
border-radius: 1.1cqh;
background: var(--muted, #94a3b8);
opacity: 0.55;
}
.lsp-hero-line:nth-of-type(3) {
width: 72%;
}
.lsp-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
column-gap: var(--space-2, 2cqw);
width: 58cqw;
}
.lsp-card {
display: grid;
align-content: start;
row-gap: var(--space-1, 1.6cqh);
height: 24cqh;
padding: var(--space-2, 2.6cqh) var(--space-2, 1.6cqw);
border: 0.16cqw solid var(--border, #343a46);
border-radius: var(--radius, 2.4cqmin);
background: var(--surface, #14171c);
}
.lsp-dot {
width: 3.4cqh;
height: 3.4cqh;
border-radius: 50%;
background: color-mix(in srgb, var(--lsp-accent, #22c55e) 72%, var(--surface, #14171c));
}
.lsp-line {
height: 1.9cqh;
border-radius: 1cqh;
background: var(--muted, #94a3b8);
opacity: 0.5;
}
.lsp-line:nth-of-type(3) {
width: 64%;
}
</style>
<div
id="light-sweep-pass-clip"
class="lsp-clip clip"
data-start="0"
data-duration="4"
data-track-index="0"
>
<div class="lsp-stage">
<div class="lsp-scene" data-slot="scene">
<!-- SLOT "scene": replace the children of this element with
your own full-bleed content. Mark elements that should
catch the light with data-lit and give each an inline
style="--lsp-x: NN" (center along the sweep, percent). -->
<div class="lsp-default" aria-hidden="true">
<div class="lsp-hero" data-lit style="--lsp-x: 50">
<div class="lsp-hero-bar"></div>
<div class="lsp-hero-line"></div>
<div class="lsp-hero-line"></div>
</div>
<div class="lsp-row">
<div class="lsp-card" data-lit style="--lsp-x: 31">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
<div class="lsp-card" data-lit style="--lsp-x: 50">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
<div class="lsp-card" data-lit style="--lsp-x: 69">
<div class="lsp-dot"></div>
<div class="lsp-line"></div>
<div class="lsp-line"></div>
</div>
</div>
</div>
</div>
<div class="lsp-ambient" aria-hidden="true"></div>
<div class="lsp-band" aria-hidden="true"></div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script>
(function () {
"use strict";
var root = document.getElementById("root");
// Literal id: mount flattening strips data-composition-id from the
// live root before this timeline registers.
var compositionId = "light-sweep-pass";
var stage = root.querySelector(".lsp-stage");
var band = root.querySelector(".lsp-band");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
function clampNumber(raw, fallback, min, max) {
var value = raw == null ? fallback : Number(raw);
if (!Number.isFinite(value)) return fallback;
return Math.max(min, Math.min(max, value));
}
var angle = clampNumber(vars.angle, 115, 60, 160);
var sweepAt = clampNumber(vars.sweep_at, 0.9, 0, 8);
var strength = vars.strength === "subtle" ? "subtle" : "standard";
var accentTokens = {
green: "var(--brand, #22c55e)",
blue: "var(--accent, #38bdf8)",
violet: "var(--accent-2, #c5a3ff)",
};
var accent = Object.prototype.hasOwnProperty.call(accentTokens, vars.accent)
? vars.accent
: "green";
// The bundler mirrors composition variables as scoped CSS custom
// props, so this unit's own accent variable can shadow the contract
// --accent token ("blue" is a valid CSS color). When the shadow is
// present, fall back to the literal contract value.
var shadowedAccent = getComputedStyle(root).getPropertyValue("--accent").trim();
if (
shadowedAccent === "green" ||
shadowedAccent === "blue" ||
shadowedAccent === "violet"
) {
accentTokens.blue = "#38bdf8";
}
// INVARIANT: only none | fade | up reaches the timeline.
var exit = vars.exit === "fade" || vars.exit === "up" ? vars.exit : "none";
root.dataset.strength = strength;
root.style.setProperty("--lsp-angle", String(angle));
root.style.setProperty("--lsp-accent", accentTokens[accent]);
// RETIME RANGE: fixed IN and OUT scale together only when D is
// too short. HOLD is the sole elastic phase. Never timeScale().
var SWEEP_BASE = 1.6;
var SETTLE_BASE = 0.55;
var STAGE_IN_BASE = 0.5;
var IN_BASE = sweepAt + SWEEP_BASE + SETTLE_BASE;
var OUT_BASE = exit === "none" ? 0 : 0.5;
var duration = Math.max(0.001, parseFloat(root.dataset.duration || "4"));
var totalBase = IN_BASE + OUT_BASE;
var scale = duration < totalBase ? duration / totalBase : 1;
var SWEEP = SWEEP_BASE * scale;
var SETTLE = SETTLE_BASE * scale;
var STAGE_IN = Math.min(STAGE_IN_BASE * scale, IN_BASE * scale);
var SWEEP_AT = sweepAt * scale;
var SWEEP_END = SWEEP_AT + SWEEP;
var IN = IN_BASE * scale;
var OUT = OUT_BASE * scale;
var HOLD = Math.max(0, duration - (IN + OUT));
var OUT_START = IN + HOLD;
// The light's authored waypoints: parked off-frame left, fully
// crossed off-frame right, then the resting key in the upper
// third of the travel. All in --light-x units (frame percent).
var LIGHT_START = -35;
var LIGHT_CROSSED = 118;
var LIGHT_REST = 62;
function fireSfx(id, t) {
root.dispatchEvent(
new CustomEvent("hf:sfx", { detail: { id: id, t: t }, bubbles: true }),
);
}
// ONE proxy owns --light-x; every highlight, shadow, ambient
// lift, and the band transform read it via calc in static CSS.
var light = { x: LIGHT_START };
function writeLight() {
root.style.setProperty("--light-x", light.x.toFixed(3));
}
writeLight();
gsap.set(stage, { opacity: 0, y: "1.5cqh" });
gsap.set(band, { autoAlpha: 0 });
var tl = gsap.timeline({ paused: true });
// IN: the scene settles first, then one confident crossing.
tl.to(stage, { opacity: 1, y: "0cqh", duration: STAGE_IN, ease: "power2.out" }, 0);
tl.fromTo(
light,
{ x: LIGHT_START },
{
x: LIGHT_CROSSED,
duration: SWEEP,
ease: "sine.inOut",
onUpdate: writeLight,
},
SWEEP_AT,
);
tl.fromTo(
band,
{ autoAlpha: 0 },
{
autoAlpha: 1,
duration: Math.min(0.3 * scale, SWEEP),
ease: "power1.out",
immediateRender: false,
},
SWEEP_AT,
);
tl.to(
band,
{ autoAlpha: 0, duration: 0.35 * scale, ease: "power1.in" },
Math.max(SWEEP_AT, SWEEP_END - 0.35 * scale),
);
// The settle: the band is gone; the key light glides back to its
// resting position and the per-element shading follows it there.
tl.to(
light,
{ x: LIGHT_REST, duration: SETTLE, ease: "power2.out", onUpdate: writeLight },
SWEEP_END,
);
tl.call(
function () {
fireSfx("light-settle-soft", IN);
},
[],
IN,
);
// HOLD: deliberately still under the settled key.
// OUT: only when the exit variable asks for one.
if (exit !== "none") {
tl.to(stage, { opacity: 0, duration: OUT, ease: "power2.in" }, OUT_START);
if (exit === "up") {
tl.to(stage, { y: "-6cqh", duration: OUT, ease: "power2.in" }, OUT_START);
}
}
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines[compositionId] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</Accordion>
{/* hf:generated-footer */}
Tagged `motion-primitive` `overlay` `light` `sweep` `slots` `deterministic`.
## Related topics
- [Browse the complete Catalog](/catalog)
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
- [Build a richer composition](/go-further)