Setting the file. One moment.
Caption Skin · Hyperframes Creative · heygen-com/hyperframes · Skills Docs
ContentsBack to the top of the page 22.10
Narration
(opens in a new tab)
frame-presets/blockframe/ caption-skin.html
HTML · 224 lines · 8 KB
15
--cap-ink · --cap-canvas · --cap-accent · --cap-accent-2 · --font-display ·
16 --font-body · --cap-band-top · --cap-band-height
17 Hooks (do not rename): .caption-group / .caption-word + states .is-active / .is-spoken,
18 root data-composition-id="captions", timeline at window.__timelines["captions"].
19 State changes use gsap.set({className}) (applied on the engine's frame-by-frame seek);
20 never tl.call() callbacks (seek does not fire them → wrong state on render).
21
22 Visual: a white card carved by a 4px black border with an 8px hard offset shadow
23 (solid black, zero blur, bottom-right — blockframe's sacred depth), square corners.
24 Inter 900, UPPERCASE, negative-tracked. Upcoming words sit in faded ink; the current
25 word gets a saturated-yellow stamp-block — a hard square highlight (box-shadow spread,
26 no blur) with black ink reading on top, blockframe's signature stamp gesture; spoken
27 words settle to solid black ink, stamp cleared. The word pops in with a snappy
28 back.out overshoot — loud, a little crooked.
29 -->
30 < script src = "https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js" ></ script >
31
32 <!-- captions.mjs injects the project's :root tokens here -->
33 < style data-brand-tokens ></ style >
34
35 < style >
36 #captions-root {
37 position : absolute ;
38 inset : 0 ;
39 pointer-events : none ;
40 }
41 .caption-layer {
42 position : absolute ;
43 inset : 0 ;
44 z-index : 20 ;
45 pointer-events : none ;
46 }
47 /* the keep-out band, from captionBand(H) — frame content stays above it */
48 .caption-stage {
49 position : absolute ;
50 left : 0 ;
51 right : 0 ;
52 top : var ( --cap-band-top , 900 px );
53 height : var ( --cap-band-height , 180 px );
54 display : flex ;
55 align-items : center ;
56 justify-content : center ;
57 }
58 .caption-group {
59 /* every group is absolutely stacked over the SAME band — exactly one shown at a
60 time via opacity. Must be absolute: in-flow groups would lay out side-by-side. */
61 position : absolute ;
62 inset : 0 ;
63 display : flex ;
64 align-items : center ;
65 justify-content : center ;
66 opacity : 0 ;
67 }
68
69 /* THE bordered card — 4px black border + 8px hard offset shadow (solid black,
70 zero blur, bottom-right — blockframe's sacred depth), square corners */
71 .caption-pill {
72 max-width : 80 % ;
73 padding : 18 px 40 px 22 px ;
74 background : var ( --cap-canvas , #ffffff );
75 border : 4 px solid var ( --cap-ink , #000000 );
76 border-radius : 0 ;
77 box-shadow : 8 px 8 px 0 var ( --cap-ink , #000000 );
78 }
79 .caption-line {
80 display : flex ;
81 flex-wrap : wrap ;
82 justify-content : center ;
83 gap : 0.12 em 0.32 em ;
84 font-family : var ( --font-display , "Inter" ), system-ui , sans-serif ;
85 font-weight : 900 ;
86 text-transform : uppercase ;
87 font-size : clamp ( 38 px , 4.2 vw , 56 px );
88 line-height : 1.12 ;
89 letter-spacing : -0.02 em ;
90 }
91
92 /* upcoming — faded black ink, no stamp */
93 .caption-word {
94 display : inline-block ;
95 padding : 0 0.1 em ;
96 color : color-mix ( in srgb , var ( --cap-ink , #000000 ) 40 % , var ( --cap-canvas , #ffffff ));
97 }
98 /* current word — THE yellow stamp-block (box-shadow spread = a hard square block
99 w/o layout shift; no blur), black ink reading on top — blockframe's signature stamp */
100 .caption-word.is-active {
101 color : var ( --cap-ink , #000000 );
102 background : var ( --cap-accent , #f7cb46 );
103 box-shadow : 0 0 0 0.08 em var ( --cap-accent , #f7cb46 );
104 }
105 /* already spoken — solid black ink, stamp cleared */
106 .caption-word.is-spoken {
107 color : var ( --cap-ink , #000000 );
108 background : transparent ;
109 box-shadow : none ;
110 }
111
112 /* optional per-word accents (dormant until a word-classer tags them) */
113 /* brand / key term — heavier ink weight, blockframe's display is already 900 */
114 .caption-word.cap-brand {
115 color : var ( --cap-ink , #000000 );
116 }
117 /* numerals / data — the body voice, slightly recessed */
118 .caption-word.cap-num {
119 font-family : var ( --font-body , "Inter" ), ui-monospace , monospace ;
120 color : color-mix ( in srgb , var ( --cap-ink , #000000 ) 74 % , var ( --cap-canvas , #ffffff ));
121 }
122 /* emphasis — a cream hard underline bar (the second-chroma accent) */
123 .caption-word.cap-cta {
124 text-decoration : underline ;
125 text-decoration-thickness : 4 px ;
126 text-decoration-color : var ( --cap-accent-2 , #ffdc8b );
127 text-underline-offset : 0.12 em ;
128 }
129
130 @media ( max-aspect-ratio : 9 / 16 ) {
131 .caption-pill {
132 max-width : 92 % ;
133 }
134 .caption-line {
135 font-size : clamp ( 34 px , 5.4 vw , 48 px );
136 }
137 }
138 </ style >
139
140 < div
141 id = "captions-root"
142 data-composition-id = "captions"
143 data-timeline-locked
144 data-start = "0"
145 data-duration = "0"
146 data-fps = "30"
147 data-width = "0"
148 data-height = "0"
149 >
150 < div class = "caption-layer" aria-hidden = "true" >
151 < div id = "caption-stage" class = "caption-stage" ></ div >
152 </ div >
153 </ div >
154
155 < script >
156 // captions.mjs injects the engine's scene-aware groups + real duration here.
157 var GROUPS = [];
158 var DURATION = 0 ;
159
160 ( function () {
161 var stage = document. getElementById ( "caption-stage" );
162
163 // build DOM: one .caption-group per group, .caption-word per word
164 GROUPS . forEach ( function ( group , g ) {
165 var groupEl = document. createElement ( "div" );
166 groupEl.className = "caption-group" ;
167 groupEl.id = "caption-group-" + g;
168 var pill = document. createElement ( "div" );
169 pill.className = "caption-pill" ;
170 var line = document. createElement ( "div" );
171 line.className = "caption-line" ;
172 (group.words || []). forEach ( function ( w , i ) {
173 var span = document. createElement ( "span" );
174 span.className = "caption-word" ;
175 span.id = "caption-word-" + g + "-" + i;
176 span.textContent = String (w.text);
177 line. appendChild (span);
178 });
179 pill. appendChild (line);
180 groupEl. appendChild (pill);
181 stage. appendChild (groupEl);
182 });
183
184 window.__timelines = window.__timelines || {};
185 var tl = gsap. timeline ({ paused: true });
186
187 GROUPS . forEach ( function ( group , g ) {
188 var groupEl = document. getElementById ( "caption-group-" + g);
189 var words = group.words || [];
190 var next = GROUPS [g + 1 ];
191 var isLast = g === GROUPS . length - 1 ;
192 var start = Math. max ( 0 , Number (group.start));
193 var end = isLast ? DURATION : Math. min ( Number (next.start), Number (group.end) + 0.3 );
194 if (end <= start) end = start + 0.01 ;
195
196 // group on/off — exactly one group visible at a time
197 tl. set (groupEl, { opacity: 1 }, start);
198 tl. set (groupEl, { opacity: 0 }, end);
199
200 // 3-state karaoke via className SETS — seek-safe (gsap.set applies on the
201 // engine's frame-by-frame seek; .call callbacks would NOT fire).
202 words. forEach ( function ( w , i ) {
203 var el = document. getElementById ( "caption-word-" + g + "-" + i);
204 var at = Math. max (start, Number (w.start));
205 tl. set (el, { className: "caption-word" }, start); // upcoming (also resets on reverse-seek)
206 tl. set (el, { className: "caption-word is-active" }, at); // current
207 tl. fromTo (el, { scale: 0.86 }, { scale: 1 , duration: 0.2 , ease: "back.out(2.4)" }, at);
208 if (i + 1 < words. length ) {
209 var nextAt = Math. max (start, Number (words[i + 1 ].start));
210 tl. set (el, { className: "caption-word is-spoken" }, nextAt); // demote when next activates
211 }
212 });
213 if (words. length ) {
214 var lastEl = document. getElementById ( "caption-word-" + g + "-" + (words. length - 1 ));
215 var lastSpoken = Math. min (end, Number (words[words. length - 1 ].end) + 0.1 );
216 tl. set (lastEl, { className: "caption-word is-spoken" }, lastSpoken);
217 }
218 });
219
220 // full-span anchor so the sub-comp timeline spans the whole video
221 tl. to ({}, { duration: DURATION }, 0 );
222 window.__timelines[ "captions" ] = tl;
223 })();
224 </ script >