mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-08 07:46:59 +00:00
The generated catalog pages rendered the "Source" accordion title as a
JSX expression, `<Accordion title={`name.html`}>`. Mintlify's search
indexer stringifies expression attribute nodes rather than evaluating
them, so every one of the 399 catalog pages surfaced its Source section
in search results as "[object Object]" (visible on the Scroll Feed page,
among others).
The template literal carried no escaping benefit: every title is a
single-segment `name.html` path, and a double-quoted JSX string handles
it directly. Introduce `mdxStringAttribute`, which emits a plain
`name="value"` attribute and escapes `& " < { }` as HTML character
references (MDX decodes references inside quoted attribute values, and
unlike JSON.stringify it does not rely on backslash escapes, which JSX
strings do not honour). Use it for both the Source accordion title and
the preview iframe title, and regenerate the catalog pages.
Regenerated with `npx tsx scripts/generate-catalog-pages.ts`; the only
change across the 399 pages is the one Accordion title line each.
Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com>
263 lines
11 KiB
Plaintext
263 lines
11 KiB
Plaintext
---
|
|
title: "Fade Through"
|
|
description: "A calm transition primitive that fades one layer out, passes through a wash, and reveals the next layer"
|
|
---
|
|
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
import { VariablesExplorer } from "/snippets/variables-explorer.jsx";
|
|
|
|
## Install
|
|
|
|
<InstallCommand command="npx hyperframes add fade-through" item="fade-through" />
|
|
|
|
That writes one file: `compositions/components/fade-through.html`.
|
|
|
|
<VariablesExplorer
|
|
previewSrc="/public/catalog/components/fade-through.json"
|
|
compositionId="fade-through"
|
|
compositionSrc="compositions/components/fade-through.html"
|
|
variables={[{"id":"wash","type":"enum","role":"style","label":"Wash","description":"Colour of the mid-transition frame. Paper resolves through --hf-fade-through-wash, accent rides --accent.","default":"paper","options":[{"value":"paper","label":"Paper"},{"value":"white","label":"White"},{"value":"ink","label":"Ink"},{"value":"accent","label":"Accent"}]},{"id":"strength","type":"number","role":"style","label":"Strength","description":"How far the wash covers at its peak. 1 is a full flash, 0.3 a light veil.","default":1,"min":0.1,"max":1,"step":0.05},{"id":"shape","type":"enum","role":"style","label":"Shape","description":"Flat fills the frame evenly, bloom concentrates the wash in the centre.","default":"flat","options":[{"value":"flat","label":"Flat"},{"value":"bloom","label":"Bloom"}]}]}
|
|
>
|
|
|
|
```html fade-through.html
|
|
<!--
|
|
Fade Through - scene transition primitive.
|
|
|
|
Put class="hf-fade-through-out" on the outgoing layer and
|
|
class="hf-fade-through-in" on the incoming layer. Add the optional wash
|
|
overlay below when you want a brighter mid-transition frame.
|
|
|
|
Variables. The wash is the only surface this primitive paints, so all three
|
|
describe it. The script reads each one, falls back to the declared default on
|
|
anything missing or unrecognised, and writes the result as a custom property
|
|
the CSS above consumes. The timeline recipe below is untouched by them.
|
|
|
|
- wash (paper | white | ink | accent, default paper): the colour of the
|
|
mid-transition frame. paper still resolves through
|
|
--hf-fade-through-wash, so an existing override keeps working; accent
|
|
rides --accent.
|
|
- strength (number 0.1 to 1, default 1): how far the wash is allowed to
|
|
cover at its peak. 1 is a full flash, 0.3 a light veil over the cut.
|
|
- shape (flat | bloom, default flat): flat fills the frame evenly, bloom
|
|
concentrates the wash in the centre and falls off to the edges.
|
|
|
|
On every default the result is identical to the original: a flat, fully
|
|
opaque #f8f5ec wash.
|
|
-->
|
|
|
|
<div
|
|
class="hf-fade-through-wash"
|
|
aria-hidden="true"
|
|
data-composition-variables='[
|
|
{ "id": "wash", "type": "enum", "role": "style", "label": "Wash", "description": "Colour of the mid-transition frame. Paper resolves through --hf-fade-through-wash, accent rides --accent.", "default": "paper", "options": [{ "value": "paper", "label": "Paper" }, { "value": "white", "label": "White" }, { "value": "ink", "label": "Ink" }, { "value": "accent", "label": "Accent" }] },
|
|
{ "id": "strength", "type": "number", "role": "style", "label": "Strength", "description": "How far the wash covers at its peak. 1 is a full flash, 0.3 a light veil.", "default": 1, "min": 0.1, "max": 1, "step": 0.05 },
|
|
{ "id": "shape", "type": "enum", "role": "style", "label": "Shape", "description": "Flat fills the frame evenly, bloom concentrates the wash in the centre.", "default": "flat", "options": [{ "value": "flat", "label": "Flat" }, { "value": "bloom", "label": "Bloom" }] }
|
|
]'
|
|
></div>
|
|
|
|
<style>
|
|
.hf-fade-through-in {
|
|
opacity: 0;
|
|
}
|
|
.hf-fade-through-wash {
|
|
position: absolute;
|
|
inset: 0;
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
background: var(--hf-fade-through-paint, var(--hf-fade-through-wash, #f8f5ec));
|
|
filter: opacity(var(--hf-fade-through-strength, 1));
|
|
z-index: 900;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
// Unrecognised overrides return to their declared defaults.
|
|
var washes = {
|
|
paper: "var(--hf-fade-through-wash, #f8f5ec)",
|
|
white: "#ffffff",
|
|
ink: "#0b0b0f",
|
|
accent: "var(--accent, #38bdf8)",
|
|
};
|
|
|
|
var wash = Object.prototype.hasOwnProperty.call(washes, vars.wash) ? vars.wash : "paper";
|
|
var shape = vars.shape === "bloom" ? "bloom" : "flat";
|
|
|
|
var strength = parseFloat(vars.strength);
|
|
if (!isFinite(strength)) strength = 1;
|
|
strength = Math.min(1, Math.max(0.1, strength));
|
|
|
|
var colour = washes[wash];
|
|
var paint =
|
|
shape === "bloom"
|
|
? "radial-gradient(circle at 50% 50%, " + colour + " 0%, transparent 72%)"
|
|
: colour;
|
|
|
|
var overlays = document.querySelectorAll(".hf-fade-through-wash");
|
|
for (var i = 0; i < overlays.length; i += 1) {
|
|
overlays[i].style.setProperty("--hf-fade-through-paint", paint);
|
|
overlays[i].style.setProperty("--hf-fade-through-strength", String(strength));
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<!--
|
|
Timeline integration:
|
|
|
|
tl.to(".hf-fade-through-out", { opacity: 0, duration: 0.45, ease: "power2.inOut" }, startTime);
|
|
tl.to(".hf-fade-through-wash", { opacity: 1, duration: 0.35, ease: "power2.inOut" }, startTime);
|
|
tl.to(".hf-fade-through-wash", { opacity: 0, duration: 0.45, ease: "power2.inOut" }, startTime + 0.35);
|
|
tl.to(".hf-fade-through-in", { opacity: 1, duration: 0.55, ease: "power2.out" }, startTime + 0.35);
|
|
-->
|
|
```
|
|
|
|
</VariablesExplorer>
|
|
|
|
## 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 |
|
|
| --- | --- | --- | --- |
|
|
| `wash` | `paper` | `paper`, `white`, `ink`, `accent` | Colour of the mid-transition frame. Paper resolves through --hf-fade-through-wash, accent rides --accent. |
|
|
| `strength` | `1` | 0.1 to 1, step 0.05 | How far the wash covers at its peak. 1 is a full flash, 0.3 a light veil. |
|
|
| `shape` | `flat` | `flat`, `bloom` | Flat fills the frame evenly, bloom concentrates the wash in the centre. |
|
|
|
|
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="fade-through"
|
|
data-composition-src="compositions/components/fade-through.html"
|
|
data-variable-values='{"wash":"paper","strength":1,"shape":"flat"}'
|
|
></div>
|
|
```
|
|
|
|
## Source
|
|
|
|
<Accordion title="fade-through.html">
|
|
|
|
```html
|
|
<!--
|
|
Fade Through - scene transition primitive.
|
|
|
|
Put class="hf-fade-through-out" on the outgoing layer and
|
|
class="hf-fade-through-in" on the incoming layer. Add the optional wash
|
|
overlay below when you want a brighter mid-transition frame.
|
|
|
|
Variables. The wash is the only surface this primitive paints, so all three
|
|
describe it. The script reads each one, falls back to the declared default on
|
|
anything missing or unrecognised, and writes the result as a custom property
|
|
the CSS above consumes. The timeline recipe below is untouched by them.
|
|
|
|
- wash (paper | white | ink | accent, default paper): the colour of the
|
|
mid-transition frame. paper still resolves through
|
|
--hf-fade-through-wash, so an existing override keeps working; accent
|
|
rides --accent.
|
|
- strength (number 0.1 to 1, default 1): how far the wash is allowed to
|
|
cover at its peak. 1 is a full flash, 0.3 a light veil over the cut.
|
|
- shape (flat | bloom, default flat): flat fills the frame evenly, bloom
|
|
concentrates the wash in the centre and falls off to the edges.
|
|
|
|
On every default the result is identical to the original: a flat, fully
|
|
opaque #f8f5ec wash.
|
|
-->
|
|
|
|
<div
|
|
class="hf-fade-through-wash"
|
|
aria-hidden="true"
|
|
data-composition-variables='[
|
|
{ "id": "wash", "type": "enum", "role": "style", "label": "Wash", "description": "Colour of the mid-transition frame. Paper resolves through --hf-fade-through-wash, accent rides --accent.", "default": "paper", "options": [{ "value": "paper", "label": "Paper" }, { "value": "white", "label": "White" }, { "value": "ink", "label": "Ink" }, { "value": "accent", "label": "Accent" }] },
|
|
{ "id": "strength", "type": "number", "role": "style", "label": "Strength", "description": "How far the wash covers at its peak. 1 is a full flash, 0.3 a light veil.", "default": 1, "min": 0.1, "max": 1, "step": 0.05 },
|
|
{ "id": "shape", "type": "enum", "role": "style", "label": "Shape", "description": "Flat fills the frame evenly, bloom concentrates the wash in the centre.", "default": "flat", "options": [{ "value": "flat", "label": "Flat" }, { "value": "bloom", "label": "Bloom" }] }
|
|
]'
|
|
></div>
|
|
|
|
<style>
|
|
.hf-fade-through-in {
|
|
opacity: 0;
|
|
}
|
|
.hf-fade-through-wash {
|
|
position: absolute;
|
|
inset: 0;
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
background: var(--hf-fade-through-paint, var(--hf-fade-through-wash, #f8f5ec));
|
|
filter: opacity(var(--hf-fade-through-strength, 1));
|
|
z-index: 900;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
// Unrecognised overrides return to their declared defaults.
|
|
var washes = {
|
|
paper: "var(--hf-fade-through-wash, #f8f5ec)",
|
|
white: "#ffffff",
|
|
ink: "#0b0b0f",
|
|
accent: "var(--accent, #38bdf8)",
|
|
};
|
|
|
|
var wash = Object.prototype.hasOwnProperty.call(washes, vars.wash) ? vars.wash : "paper";
|
|
var shape = vars.shape === "bloom" ? "bloom" : "flat";
|
|
|
|
var strength = parseFloat(vars.strength);
|
|
if (!isFinite(strength)) strength = 1;
|
|
strength = Math.min(1, Math.max(0.1, strength));
|
|
|
|
var colour = washes[wash];
|
|
var paint =
|
|
shape === "bloom"
|
|
? "radial-gradient(circle at 50% 50%, " + colour + " 0%, transparent 72%)"
|
|
: colour;
|
|
|
|
var overlays = document.querySelectorAll(".hf-fade-through-wash");
|
|
for (var i = 0; i < overlays.length; i += 1) {
|
|
overlays[i].style.setProperty("--hf-fade-through-paint", paint);
|
|
overlays[i].style.setProperty("--hf-fade-through-strength", String(strength));
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<!--
|
|
Timeline integration:
|
|
|
|
tl.to(".hf-fade-through-out", { opacity: 0, duration: 0.45, ease: "power2.inOut" }, startTime);
|
|
tl.to(".hf-fade-through-wash", { opacity: 1, duration: 0.35, ease: "power2.inOut" }, startTime);
|
|
tl.to(".hf-fade-through-wash", { opacity: 0, duration: 0.45, ease: "power2.inOut" }, startTime + 0.35);
|
|
tl.to(".hf-fade-through-in", { opacity: 1, duration: 0.55, ease: "power2.out" }, startTime + 0.35);
|
|
-->
|
|
```
|
|
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
Open `compositions/components/fade-through.html` and paste its contents into your composition. See the comment header in the file for detailed instructions.
|
|
|
|
{/* hf:generated-footer */}
|
|
|
|
Tagged `motion-primitive` `transition` `fade` `scene`.
|
|
|
|
## Related topics
|
|
|
|
- [Browse the complete Catalog](/catalog)
|
|
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
|
|
- [Build a richer composition](/go-further)
|