Files
hyperframes/docs/catalog/components/gesture-tap.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

882 lines
31 KiB
Plaintext

---
title: "Gesture Tap"
description: "A contact circle taps a mobile pill button, releases it into a new labeled accent state, and lifts away."
---
import { InstallCommand } from "/snippets/install-command.jsx";
import { VariablesExplorer } from "/snippets/variables-explorer.jsx";
<VariablesExplorer
previewSrc="/public/catalog/components/gesture-tap.json"
compositionId="gesture-tap"
compositionSrc="compositions/components/gesture-tap.html"
variables={[{"id":"tap_label","type":"string","role":"content","label":"Tap label","description":"Button label shown before the tap response.","default":"Follow"},{"id":"response_label","type":"string","role":"content","label":"Response label","description":"Button label shown when the tap releases.","default":"Following"},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Color used for the completed button state and response pulse.","default":"green","options":[{"value":"green","label":"Green"},{"value":"blue","label":"Blue"},{"value":"violet","label":"Violet"}]}]}
>
```html gesture-tap.html
<!doctype html>
<!--
gesture-tap: HyperFrames video primitive (ui-props / interaction / demonstrate)
Concept: a contact circle appears directly over a real pill button, presses
it, releases it into a new state, then lifts away. One mechanic, one job:
showing a decisive mobile tap response.
Variables:
- tap_label (string, default "Follow"): button label before release.
- response_label (string, default "Following"): button label after release.
- accent (enum, green | blue | violet, default green): response color.
Envelope: fixed IN and OUT with elastic HOLD only.
IN_BASE = 1.35s. The stage fades in, contact fades up at the target,
presses, then releases. The label swap, accent response, and pulse share
one release timestamp.
HOLD = max(0, D - IN - OUT). Only this phase stretches for longer mounts.
A barely visible card drift keeps the held state alive.
OUT_BASE = 0.55s. The completed mobile state fades cleanly.
If D is shorter than IN_BASE + OUT_BASE, IN and OUT compress together.
Mount contract: the runtime clones only this template. #root fills the host
box, establishes the container query basis, carries no data-width or
data-height, and registers one paused timeline under the literal
gesture-tap key.
-->
<html
lang="en"
data-composition-id="gesture-tap"
data-composition-duration="3"
data-composition-variables='[
{ "id": "tap_label", "type": "string", "role": "content", "label": "Tap label", "description": "Button label shown before the tap response.", "default": "Follow" },
{ "id": "response_label", "type": "string", "role": "content", "label": "Response label", "description": "Button label shown when the tap releases.", "default": "Following" },
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Color used for the completed button state and response pulse.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Gesture Tap</title>
</head>
<body>
<template>
<div id="root" data-composition-id="gesture-tap" data-duration="3" data-fps="30">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
#root {
position: absolute;
inset: 0;
overflow: hidden;
container-type: size;
isolation: isolate;
color: #eef2ff;
font-family: Inter, system-ui, sans-serif;
pointer-events: none;
}
.gt-clip {
position: absolute;
inset: 0;
display: grid;
place-items: center;
overflow: hidden;
background: radial-gradient(circle at 50% 44%, #1c2537 0%, #101521 68%);
}
.gt-stage {
width: 100cqw;
height: 100cqh;
display: grid;
place-items: center;
opacity: 0;
will-change: transform, opacity;
}
.gt-phone {
position: relative;
width: 46cqw;
height: 78cqh;
overflow: hidden;
border: 0.18cqmin solid rgba(255, 255, 255, 0.24);
border-radius: 5cqmin;
background: #f7f8fb;
box-shadow: 0 4cqh 10cqh rgba(2, 6, 23, 0.44);
color: #111827;
will-change: transform;
}
.gt-status {
height: 9cqh;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 4cqw;
border-bottom: 0.12cqmin solid #e5e7eb;
color: #64748b;
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
font-size: 2.1cqh;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.gt-signal {
width: 4.8cqw;
height: 1.4cqh;
border-radius: 999cqw;
background: #cbd5e1;
}
.gt-profile {
height: 50cqh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2.2cqh;
padding: 0 5cqw;
text-align: center;
}
.gt-avatar {
width: 12cqmin;
aspect-ratio: 1;
border-radius: 50%;
background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
box-shadow: inset 0 0 0 0.8cqmin #ffffff;
}
.gt-name {
max-width: 34cqw;
overflow: hidden;
color: #0f172a;
font-size: 4.2cqh;
font-weight: 780;
line-height: 1.05;
letter-spacing: -0.035em;
text-overflow: ellipsis;
white-space: nowrap;
}
.gt-detail {
max-width: 34cqw;
color: #64748b;
font-size: 2.35cqh;
font-weight: 520;
line-height: 1.35;
}
.gt-button-shell {
position: relative;
width: 34cqw;
height: 11cqh;
margin: 0 auto;
}
.gt-button {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
border: 0.16cqmin solid #273449;
border-radius: 999cqw;
background: #172033;
color: #f8fafc;
font: inherit;
font-size: 2.9cqh;
font-weight: 760;
letter-spacing: -0.01em;
transform-origin: 50% 50%;
will-change: transform, background-color, border-color;
}
.gt-button-label {
display: block;
max-width: 28cqw;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.gt-response-pulse {
position: absolute;
inset: -1.7cqh -1.7cqw;
z-index: 1;
border: 0.28cqmin solid var(--gt-accent, #34d399);
border-radius: 999cqw;
opacity: 0;
will-change: transform, opacity;
}
.gt-contact {
position: absolute;
top: calc(50% - 7cqmin);
left: calc(50% - 7cqmin);
z-index: 4;
width: 14cqmin;
aspect-ratio: 1;
border: 0.24cqmin solid rgba(255, 255, 255, 0.78);
border-radius: 50%;
background: rgba(255, 255, 255, 0.34);
box-shadow:
inset 0 0 0 0.8cqmin rgba(255, 255, 255, 0.12),
0 1.2cqh 3cqh rgba(15, 23, 42, 0.28);
opacity: 0;
transform-origin: 50% 50%;
will-change: transform, opacity;
}
</style>
<div
id="gesture-tap-clip"
class="gt-clip clip"
data-start="0"
data-duration="3"
data-track-index="0"
>
<div class="gt-stage">
<article class="gt-phone" aria-label="Mobile profile card">
<div class="gt-status">
<span>Profile</span>
<span class="gt-signal" aria-hidden="true"></span>
</div>
<div class="gt-profile">
<div class="gt-avatar" aria-hidden="true"></div>
<div class="gt-name">Maya Chen</div>
<div class="gt-detail">Product designer sharing practical interaction notes.</div>
</div>
<div class="gt-button-shell">
<div class="gt-response-pulse" aria-hidden="true"></div>
<button class="gt-button" type="button" aria-pressed="false" tabindex="-1">
<span class="gt-button-label"></span>
</button>
<div class="gt-contact" aria-hidden="true"></div>
</div>
</article>
</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");
var stage = root.querySelector(".gt-stage");
var card = root.querySelector(".gt-phone");
var button = root.querySelector(".gt-button");
var label = root.querySelector(".gt-button-label");
var contact = root.querySelector(".gt-contact");
var pulse = root.querySelector(".gt-response-pulse");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
var tapLabel = vars.tap_label == null ? "Follow" : String(vars.tap_label);
var responseLabel =
vars.response_label == null ? "Following" : String(vars.response_label);
var accentName =
vars.accent === "blue" || vars.accent === "violet" ? vars.accent : "green";
var accentColors = {
green: "var(--brand, #34d399)",
blue: "var(--accent, #60a5fa)",
violet: "var(--accent-2, #a78bfa)",
};
var accentColor = accentColors[accentName];
label.textContent = tapLabel;
button.setAttribute("aria-label", tapLabel);
root.style.setProperty("--gt-accent", accentColor);
// GSAP interpolates colors numerically, so tween values need the
// substituted color rather than the var() form.
accentColor = getComputedStyle(root).getPropertyValue("--gt-accent").trim();
var IN_BASE = 1.35;
var OUT_BASE = 0.55;
var STAGE_IN_BASE = 0.24;
var CONTACT_AT_BASE = 0.28;
var CONTACT_IN_BASE = 0.18;
var PRESS_AT_BASE = 0.54;
var PRESS_DURATION_BASE = 0.18;
var RELEASE_AT_BASE = 0.72;
var RELEASE_DURATION_BASE = 0.28;
var CONTACT_OUT_BASE = 0.34;
var PULSE_DURATION_BASE = 0.56;
var parsedDuration = Number.parseFloat(root.dataset.duration);
var duration =
Number.isFinite(parsedDuration) && parsedDuration > 0 ? parsedDuration : 3;
var fixedBase = IN_BASE + OUT_BASE;
var phaseScale = duration < fixedBase ? duration / fixedBase : 1;
var IN = IN_BASE * phaseScale;
var OUT = OUT_BASE * phaseScale;
var HOLD = Math.max(0, duration - IN - OUT);
var HOLD_START = IN;
var OUT_START = IN + HOLD;
var STAGE_IN = STAGE_IN_BASE * phaseScale;
var CONTACT_AT = CONTACT_AT_BASE * phaseScale;
var CONTACT_IN = CONTACT_IN_BASE * phaseScale;
var PRESS_AT = PRESS_AT_BASE * phaseScale;
var PRESS_DURATION = PRESS_DURATION_BASE * phaseScale;
var RELEASE_AT = RELEASE_AT_BASE * phaseScale;
var RELEASE_DURATION = RELEASE_DURATION_BASE * phaseScale;
var CONTACT_OUT = CONTACT_OUT_BASE * phaseScale;
var PULSE_DURATION = PULSE_DURATION_BASE * phaseScale;
var tl = gsap.timeline({ paused: true });
tl.to(stage, { opacity: 1, duration: STAGE_IN, ease: "power2.out" }, 0);
// IN: the contact appears at the target. No x or y tween precedes the press.
tl.fromTo(
contact,
{ opacity: 0, scale: 0.82 },
{ opacity: 0.68, scale: 1, duration: CONTACT_IN, ease: "power2.out" },
CONTACT_AT,
);
tl.to(
button,
{
scale: 0.93,
backgroundColor: "#26324a",
duration: PRESS_DURATION,
ease: "power4.in",
},
PRESS_AT,
);
tl.to(contact, { scale: 0.78, duration: PRESS_DURATION, ease: "power4.in" }, PRESS_AT);
// Release owns the response. Label, state, accent fill, and pulse
// all begin at RELEASE_AT so the UI answers on the release frame.
tl.set(label, { innerText: responseLabel }, RELEASE_AT);
tl.set(
button,
{ attr: { "aria-label": responseLabel, "aria-pressed": "true" } },
RELEASE_AT,
);
tl.to(
button,
{
scale: 1,
backgroundColor: accentColor,
borderColor: accentColor,
color: "#071015",
duration: RELEASE_DURATION,
ease: "back.out(1.7)",
},
RELEASE_AT,
);
tl.set(pulse, { opacity: 0.58, scale: 0.76 }, RELEASE_AT);
tl.to(
pulse,
{ opacity: 0, scale: 1.14, duration: PULSE_DURATION, ease: "power2.out" },
RELEASE_AT,
);
tl.to(
contact,
{
opacity: 0,
scale: 1.04,
y: "-5cqh",
duration: CONTACT_OUT,
ease: "power2.in",
},
RELEASE_AT,
);
// HOLD: only this phase stretches. One slow yoyo returns the card
// to its resting position exactly when OUT starts.
if (HOLD > 0) {
tl.to(
card,
{
y: "-0.6cqh",
duration: HOLD / 2,
ease: "sine.inOut",
yoyo: true,
repeat: 1,
},
HOLD_START,
);
}
// OUT: the completed state remains intact while the stage exits.
tl.to(stage, { opacity: 0, y: "-1.4cqh", duration: OUT, ease: "power2.in" }, OUT_START);
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines["gesture-tap"] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</VariablesExplorer>
## Install
<InstallCommand command="npx hyperframes add gesture-tap" item="gesture-tap" />
That writes one file: `compositions/components/gesture-tap.html`.
## Paste it into your composition
Open `compositions/components/gesture-tap.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 |
| --- | --- | --- | --- |
| `tap_label` | `Follow` | string | Button label shown before the tap response. |
| `response_label` | `Following` | string | Button label shown when the tap releases. |
| `accent` | `green` | `green`, `blue`, `violet` | Color used for the completed button state and response pulse. |
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="gesture-tap"
data-composition-src="compositions/components/gesture-tap.html"
data-variable-values='{"tap_label":"Follow","response_label":"Following","accent":"green"}'
></div>
```
## Source
<Accordion title={`gesture-tap.html`}>
```html
<!doctype html>
<!--
gesture-tap: HyperFrames video primitive (ui-props / interaction / demonstrate)
Concept: a contact circle appears directly over a real pill button, presses
it, releases it into a new state, then lifts away. One mechanic, one job:
showing a decisive mobile tap response.
Variables:
- tap_label (string, default "Follow"): button label before release.
- response_label (string, default "Following"): button label after release.
- accent (enum, green | blue | violet, default green): response color.
Envelope: fixed IN and OUT with elastic HOLD only.
IN_BASE = 1.35s. The stage fades in, contact fades up at the target,
presses, then releases. The label swap, accent response, and pulse share
one release timestamp.
HOLD = max(0, D - IN - OUT). Only this phase stretches for longer mounts.
A barely visible card drift keeps the held state alive.
OUT_BASE = 0.55s. The completed mobile state fades cleanly.
If D is shorter than IN_BASE + OUT_BASE, IN and OUT compress together.
Mount contract: the runtime clones only this template. #root fills the host
box, establishes the container query basis, carries no data-width or
data-height, and registers one paused timeline under the literal
gesture-tap key.
-->
<html
lang="en"
data-composition-id="gesture-tap"
data-composition-duration="3"
data-composition-variables='[
{ "id": "tap_label", "type": "string", "role": "content", "label": "Tap label", "description": "Button label shown before the tap response.", "default": "Follow" },
{ "id": "response_label", "type": "string", "role": "content", "label": "Response label", "description": "Button label shown when the tap releases.", "default": "Following" },
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Color used for the completed button state and response pulse.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] }
]'
>
<head>
<meta charset="UTF-8" />
<title>Gesture Tap</title>
</head>
<body>
<template>
<div id="root" data-composition-id="gesture-tap" data-duration="3" data-fps="30">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
#root {
position: absolute;
inset: 0;
overflow: hidden;
container-type: size;
isolation: isolate;
color: #eef2ff;
font-family: Inter, system-ui, sans-serif;
pointer-events: none;
}
.gt-clip {
position: absolute;
inset: 0;
display: grid;
place-items: center;
overflow: hidden;
background: radial-gradient(circle at 50% 44%, #1c2537 0%, #101521 68%);
}
.gt-stage {
width: 100cqw;
height: 100cqh;
display: grid;
place-items: center;
opacity: 0;
will-change: transform, opacity;
}
.gt-phone {
position: relative;
width: 46cqw;
height: 78cqh;
overflow: hidden;
border: 0.18cqmin solid rgba(255, 255, 255, 0.24);
border-radius: 5cqmin;
background: #f7f8fb;
box-shadow: 0 4cqh 10cqh rgba(2, 6, 23, 0.44);
color: #111827;
will-change: transform;
}
.gt-status {
height: 9cqh;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 4cqw;
border-bottom: 0.12cqmin solid #e5e7eb;
color: #64748b;
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
font-size: 2.1cqh;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.gt-signal {
width: 4.8cqw;
height: 1.4cqh;
border-radius: 999cqw;
background: #cbd5e1;
}
.gt-profile {
height: 50cqh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2.2cqh;
padding: 0 5cqw;
text-align: center;
}
.gt-avatar {
width: 12cqmin;
aspect-ratio: 1;
border-radius: 50%;
background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
box-shadow: inset 0 0 0 0.8cqmin #ffffff;
}
.gt-name {
max-width: 34cqw;
overflow: hidden;
color: #0f172a;
font-size: 4.2cqh;
font-weight: 780;
line-height: 1.05;
letter-spacing: -0.035em;
text-overflow: ellipsis;
white-space: nowrap;
}
.gt-detail {
max-width: 34cqw;
color: #64748b;
font-size: 2.35cqh;
font-weight: 520;
line-height: 1.35;
}
.gt-button-shell {
position: relative;
width: 34cqw;
height: 11cqh;
margin: 0 auto;
}
.gt-button {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
border: 0.16cqmin solid #273449;
border-radius: 999cqw;
background: #172033;
color: #f8fafc;
font: inherit;
font-size: 2.9cqh;
font-weight: 760;
letter-spacing: -0.01em;
transform-origin: 50% 50%;
will-change: transform, background-color, border-color;
}
.gt-button-label {
display: block;
max-width: 28cqw;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.gt-response-pulse {
position: absolute;
inset: -1.7cqh -1.7cqw;
z-index: 1;
border: 0.28cqmin solid var(--gt-accent, #34d399);
border-radius: 999cqw;
opacity: 0;
will-change: transform, opacity;
}
.gt-contact {
position: absolute;
top: calc(50% - 7cqmin);
left: calc(50% - 7cqmin);
z-index: 4;
width: 14cqmin;
aspect-ratio: 1;
border: 0.24cqmin solid rgba(255, 255, 255, 0.78);
border-radius: 50%;
background: rgba(255, 255, 255, 0.34);
box-shadow:
inset 0 0 0 0.8cqmin rgba(255, 255, 255, 0.12),
0 1.2cqh 3cqh rgba(15, 23, 42, 0.28);
opacity: 0;
transform-origin: 50% 50%;
will-change: transform, opacity;
}
</style>
<div
id="gesture-tap-clip"
class="gt-clip clip"
data-start="0"
data-duration="3"
data-track-index="0"
>
<div class="gt-stage">
<article class="gt-phone" aria-label="Mobile profile card">
<div class="gt-status">
<span>Profile</span>
<span class="gt-signal" aria-hidden="true"></span>
</div>
<div class="gt-profile">
<div class="gt-avatar" aria-hidden="true"></div>
<div class="gt-name">Maya Chen</div>
<div class="gt-detail">Product designer sharing practical interaction notes.</div>
</div>
<div class="gt-button-shell">
<div class="gt-response-pulse" aria-hidden="true"></div>
<button class="gt-button" type="button" aria-pressed="false" tabindex="-1">
<span class="gt-button-label"></span>
</button>
<div class="gt-contact" aria-hidden="true"></div>
</div>
</article>
</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");
var stage = root.querySelector(".gt-stage");
var card = root.querySelector(".gt-phone");
var button = root.querySelector(".gt-button");
var label = root.querySelector(".gt-button-label");
var contact = root.querySelector(".gt-contact");
var pulse = root.querySelector(".gt-response-pulse");
var vars =
window.__hyperframes && window.__hyperframes.getVariables
? window.__hyperframes.getVariables()
: {};
var tapLabel = vars.tap_label == null ? "Follow" : String(vars.tap_label);
var responseLabel =
vars.response_label == null ? "Following" : String(vars.response_label);
var accentName =
vars.accent === "blue" || vars.accent === "violet" ? vars.accent : "green";
var accentColors = {
green: "var(--brand, #34d399)",
blue: "var(--accent, #60a5fa)",
violet: "var(--accent-2, #a78bfa)",
};
var accentColor = accentColors[accentName];
label.textContent = tapLabel;
button.setAttribute("aria-label", tapLabel);
root.style.setProperty("--gt-accent", accentColor);
// GSAP interpolates colors numerically, so tween values need the
// substituted color rather than the var() form.
accentColor = getComputedStyle(root).getPropertyValue("--gt-accent").trim();
var IN_BASE = 1.35;
var OUT_BASE = 0.55;
var STAGE_IN_BASE = 0.24;
var CONTACT_AT_BASE = 0.28;
var CONTACT_IN_BASE = 0.18;
var PRESS_AT_BASE = 0.54;
var PRESS_DURATION_BASE = 0.18;
var RELEASE_AT_BASE = 0.72;
var RELEASE_DURATION_BASE = 0.28;
var CONTACT_OUT_BASE = 0.34;
var PULSE_DURATION_BASE = 0.56;
var parsedDuration = Number.parseFloat(root.dataset.duration);
var duration =
Number.isFinite(parsedDuration) && parsedDuration > 0 ? parsedDuration : 3;
var fixedBase = IN_BASE + OUT_BASE;
var phaseScale = duration < fixedBase ? duration / fixedBase : 1;
var IN = IN_BASE * phaseScale;
var OUT = OUT_BASE * phaseScale;
var HOLD = Math.max(0, duration - IN - OUT);
var HOLD_START = IN;
var OUT_START = IN + HOLD;
var STAGE_IN = STAGE_IN_BASE * phaseScale;
var CONTACT_AT = CONTACT_AT_BASE * phaseScale;
var CONTACT_IN = CONTACT_IN_BASE * phaseScale;
var PRESS_AT = PRESS_AT_BASE * phaseScale;
var PRESS_DURATION = PRESS_DURATION_BASE * phaseScale;
var RELEASE_AT = RELEASE_AT_BASE * phaseScale;
var RELEASE_DURATION = RELEASE_DURATION_BASE * phaseScale;
var CONTACT_OUT = CONTACT_OUT_BASE * phaseScale;
var PULSE_DURATION = PULSE_DURATION_BASE * phaseScale;
var tl = gsap.timeline({ paused: true });
tl.to(stage, { opacity: 1, duration: STAGE_IN, ease: "power2.out" }, 0);
// IN: the contact appears at the target. No x or y tween precedes the press.
tl.fromTo(
contact,
{ opacity: 0, scale: 0.82 },
{ opacity: 0.68, scale: 1, duration: CONTACT_IN, ease: "power2.out" },
CONTACT_AT,
);
tl.to(
button,
{
scale: 0.93,
backgroundColor: "#26324a",
duration: PRESS_DURATION,
ease: "power4.in",
},
PRESS_AT,
);
tl.to(contact, { scale: 0.78, duration: PRESS_DURATION, ease: "power4.in" }, PRESS_AT);
// Release owns the response. Label, state, accent fill, and pulse
// all begin at RELEASE_AT so the UI answers on the release frame.
tl.set(label, { innerText: responseLabel }, RELEASE_AT);
tl.set(
button,
{ attr: { "aria-label": responseLabel, "aria-pressed": "true" } },
RELEASE_AT,
);
tl.to(
button,
{
scale: 1,
backgroundColor: accentColor,
borderColor: accentColor,
color: "#071015",
duration: RELEASE_DURATION,
ease: "back.out(1.7)",
},
RELEASE_AT,
);
tl.set(pulse, { opacity: 0.58, scale: 0.76 }, RELEASE_AT);
tl.to(
pulse,
{ opacity: 0, scale: 1.14, duration: PULSE_DURATION, ease: "power2.out" },
RELEASE_AT,
);
tl.to(
contact,
{
opacity: 0,
scale: 1.04,
y: "-5cqh",
duration: CONTACT_OUT,
ease: "power2.in",
},
RELEASE_AT,
);
// HOLD: only this phase stretches. One slow yoyo returns the card
// to its resting position exactly when OUT starts.
if (HOLD > 0) {
tl.to(
card,
{
y: "-0.6cqh",
duration: HOLD / 2,
ease: "sine.inOut",
yoyo: true,
repeat: 1,
},
HOLD_START,
);
}
// OUT: the completed state remains intact while the stage exits.
tl.to(stage, { opacity: 0, y: "-1.4cqh", duration: OUT, ease: "power2.in" }, OUT_START);
tl.seek(0);
window.__timelines = window.__timelines || {};
window.__timelines["gesture-tap"] = tl;
})();
</script>
</div>
</template>
</body>
</html>
```
</Accordion>
{/* hf:generated-footer */}
Tagged `motion-primitive` `gesture` `tap` `interaction` `ui-props`.
## Related topics
- [Browse the complete Catalog](/catalog)
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
- [Build a richer composition](/go-further)