mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* docs(catalog): put each item page's title, description and Docs text in the server HTML Mintlify renders snippet components in the browser only, so everything inside CatalogDetail (title, standfirst, the Docs tab) was missing from the HTML search engines read: 448 catalog pages served Googlebot no body text. The generator now writes the H1 and standfirst as page markup above the component and the Docs tab as page markup after it, shown with that tab (docs/custom.css). The component no longer draws its own title. Pages patched structurally only; registry drift on 14 pages is left for a regeneration of its own. * docs(catalog): keep the title's top spacing the component gave it * fix(docs): catalog titles and descriptions keep markdown markers literal MDX reads text inside the static <h1> and <p> as inline markdown, so @_blue_sweater_ rendered as italic blue_sweater. mdxText now writes backslash, backtick, * _ [ ] ~ as character references too, with a unit test; the four affected pages are re-escaped.
235 lines
9.3 KiB
Plaintext
235 lines
9.3 KiB
Plaintext
---
|
|
title: "Badge Pop"
|
|
description: "A transitions.dev-inspired notification badge pop with elastic scale and count reveal"
|
|
mode: "frame"
|
|
---
|
|
|
|
import { CatalogDetail, CatalogSlot } from "/snippets/catalog-detail.jsx";
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
|
|
<div className="hf-ve-static-head not-prose">
|
|
<h1>Badge Pop</h1>
|
|
<p>A transitions.dev-inspired notification badge pop with elastic scale and count reveal</p>
|
|
</div>
|
|
|
|
<CatalogDetail
|
|
previewSrc="/public/catalog/components/badge-pop.json"
|
|
compositionId="badge-pop"
|
|
compositionSrc="compositions/components/badge-pop.html"
|
|
title="Badge Pop"
|
|
variables={[{"id":"count","type":"string","role":"style","label":"Count","description":"Text shown inside the notification badge, up to four characters.","default":"3","maxLength":4},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Colour family of the badge.","default":"red","options":[{"value":"red","label":"Red"},{"value":"blue","label":"Blue"},{"value":"green","label":"Green"},{"value":"violet","label":"Violet"}]},{"id":"surface","type":"enum","role":"style","label":"Surface","description":"Chrome of the button and the badge ring: light for bright frames, dark for dark ones.","default":"light","options":[{"value":"light","label":"Light"},{"value":"dark","label":"Dark"}]}]}
|
|
meta={{"category":"Motion Primitives","badge":"Stable","codeLines":148}}
|
|
attribution={{"path":"registry/components/badge-pop","tags":["video-primitive","transition-primitive","transitions-dev-port","badge","microinteraction"]}}
|
|
hasCode
|
|
rawUrl="https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry/components/badge-pop/badge-pop.html"
|
|
>
|
|
|
|
<CatalogSlot slot="code">
|
|
|
|
```html badge-pop.html
|
|
<!--
|
|
Badge Pop - transitions.dev-inspired primitive for HyperFrames.
|
|
|
|
Paste the markup, CSS and script into a composition. Use the timeline
|
|
integration note at the bottom as the starting point for deterministic GSAP
|
|
animation.
|
|
|
|
Variables. 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 below consumes, or as the badge text. The timeline recipe at the
|
|
bottom is untouched by them: it keeps popping the same badge, whatever the
|
|
badge says and however it is coloured.
|
|
|
|
- count (any text up to four characters, default "3"): what the badge
|
|
reads. Use it to say 1, 12, 99+ or NEW.
|
|
- accent (red | blue | green | violet, default red): the badge colour
|
|
family. red is the literal notification convention; the other three ride
|
|
the composition's own accent, brand and accent-2 tokens and fall back to
|
|
ink when the composition declares none. All four clear 3:1 against the
|
|
white count.
|
|
- surface (light | dark, default light): the chrome of the button and the
|
|
ring around the badge. light suits bright frames, dark suits dark ones.
|
|
|
|
On every default the result is identical to the original: a white bell tile
|
|
with a red 3 badge.
|
|
-->
|
|
|
|
<div
|
|
class="hf-transition-badge-pop"
|
|
data-composition-variables='[
|
|
{ "id": "count", "type": "string", "role": "style", "label": "Count", "description": "Text shown inside the notification badge, up to four characters.", "default": "3", "maxLength": 4 },
|
|
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Colour family of the badge.", "default": "red", "options": [{ "value": "red", "label": "Red" }, { "value": "blue", "label": "Blue" }, { "value": "green", "label": "Green" }, { "value": "violet", "label": "Violet" }] },
|
|
{ "id": "surface", "type": "enum", "role": "style", "label": "Surface", "description": "Chrome of the button and the badge ring: light for bright frames, dark for dark ones.", "default": "light", "options": [{ "value": "light", "label": "Light" }, { "value": "dark", "label": "Dark" }] }
|
|
]'
|
|
>
|
|
<button class="hf-transition-badge-button" type="button" aria-label="Notifications">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
<path d="M18 8a6 6 0 10-12 0c0 7-3 7-3 7h18s-3 0-3-7" />
|
|
<path d="M10 20a2 2 0 004 0" />
|
|
</svg>
|
|
</button>
|
|
<span class="hf-transition-badge-count">3</span>
|
|
</div>
|
|
|
|
<style>
|
|
.hf-transition-badge-pop {
|
|
--hf-badge-pop-accent: #ef4444;
|
|
--hf-badge-pop-surface: #ffffff;
|
|
--hf-badge-pop-border: #e4e4e7;
|
|
--hf-badge-pop-ink: #18181b;
|
|
position: relative;
|
|
display: inline-grid;
|
|
place-items: center;
|
|
font-family: Inter, system-ui, sans-serif;
|
|
}
|
|
.hf-transition-badge-button {
|
|
display: grid;
|
|
place-items: center;
|
|
width: 76px;
|
|
height: 76px;
|
|
border: 1px solid var(--hf-badge-pop-border);
|
|
border-radius: 22px;
|
|
background: var(--hf-badge-pop-surface);
|
|
color: var(--hf-badge-pop-ink);
|
|
box-shadow: 0 20px 58px rgba(0, 0, 0, 0.12);
|
|
}
|
|
.hf-transition-badge-button svg {
|
|
width: 30px;
|
|
height: 30px;
|
|
fill: none;
|
|
stroke: currentColor;
|
|
stroke-width: 2.2;
|
|
stroke-linecap: round;
|
|
stroke-linejoin: round;
|
|
}
|
|
.hf-transition-badge-count {
|
|
position: absolute;
|
|
right: -8px;
|
|
top: -8px;
|
|
display: grid;
|
|
place-items: center;
|
|
min-width: 30px;
|
|
height: 30px;
|
|
padding: 0 8px;
|
|
border: 3px solid var(--hf-badge-pop-surface);
|
|
border-radius: 999px;
|
|
background: var(--hf-badge-pop-accent);
|
|
color: #ffffff;
|
|
font-size: 13px;
|
|
font-weight: 900;
|
|
transform-origin: center;
|
|
}
|
|
</style>
|
|
|
|
<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;
|
|
}
|
|
|
|
// The badge is the one accent-carrying element here. red is the literal
|
|
// notification convention and stays; the decorative options ride the
|
|
// composition's own tokens and fall back to ink.
|
|
var accents = {
|
|
red: "#ef4444",
|
|
blue: "var(--accent, #18181b)",
|
|
green: "var(--brand, #18181b)",
|
|
violet: "var(--accent-2, #18181b)",
|
|
};
|
|
var surfaces = {
|
|
light: { surface: "#ffffff", border: "#e4e4e7", ink: "#18181b" },
|
|
dark: { surface: "#101014", border: "#2a2a32", ink: "#fafafa" },
|
|
};
|
|
|
|
var accent = accents[pick(accents, vars.accent, "red")];
|
|
var surface = surfaces[pick(surfaces, vars.surface, "light")];
|
|
var count =
|
|
typeof vars.count === "string" && vars.count.trim() ? vars.count.trim().slice(0, 4) : "3";
|
|
|
|
var roots = document.querySelectorAll(".hf-transition-badge-pop");
|
|
for (var i = 0; i < roots.length; i += 1) {
|
|
var root = roots[i];
|
|
root.style.setProperty("--hf-badge-pop-accent", accent);
|
|
root.style.setProperty("--hf-badge-pop-surface", surface.surface);
|
|
root.style.setProperty("--hf-badge-pop-border", surface.border);
|
|
root.style.setProperty("--hf-badge-pop-ink", surface.ink);
|
|
var label = root.querySelector(".hf-transition-badge-count");
|
|
if (label) {
|
|
label.textContent = count;
|
|
}
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<!--
|
|
Timeline integration:
|
|
tl.fromTo('.hf-transition-badge-button', { y: 18, opacity: 0 }, { y: 0, opacity: 1, duration: 0.34, ease: 'power2.out' }, 0.35);
|
|
tl.fromTo('.hf-transition-badge-count', { scale: 0, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.42, ease: 'back.out(2.4)' }, 0.7);
|
|
tl.to('.hf-transition-badge-count', { scale: 1.18, duration: 0.12, yoyo: true, repeat: 1, ease: 'power1.inOut' }, 1.15);
|
|
-->
|
|
```
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="install">
|
|
|
|
<InstallCommand command="npx hyperframes add badge-pop" item="badge-pop" />
|
|
|
|
That writes one file: `compositions/components/badge-pop.html`.
|
|
|
|
</CatalogSlot>
|
|
|
|
</CatalogDetail>
|
|
|
|
<div data-static-slot="docs" className="prose prose-gray dark:prose-invert">
|
|
|
|
## Paste it into your composition
|
|
|
|
Open `compositions/components/badge-pop.html` and copy what is inside into your own composition.
|
|
The file opens with a comment header that walks you through it.
|
|
|
|
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 |
|
|
| --- | --- | --- | --- |
|
|
| `count` | `3` | string | Text shown inside the notification badge, up to four characters. |
|
|
| `accent` | `red` | `red`, `blue`, `green`, `violet` | Colour family of the badge. |
|
|
| `surface` | `light` | `light`, `dark` | Chrome of the button and the badge ring: light for bright frames, dark for dark ones. |
|
|
|
|
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="badge-pop"
|
|
data-composition-src="compositions/components/badge-pop.html"
|
|
data-variable-values='{"count":"3","accent":"red","surface":"light"}'
|
|
></div>
|
|
```
|
|
|
|
{/* hf:generated-footer */}
|
|
|
|
Tagged `video-primitive` `transition-primitive` `transitions-dev-port` `badge` `microinteraction`.
|
|
|
|
## Related topics
|
|
|
|
- [Browse the complete Catalog](/catalog)
|
|
- [Add assets and Catalog items in the browser editor](/studio/assets-and-blocks)
|
|
- [Put blocks together into one video](/concepts/compositions)
|
|
|
|
</div>
|