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/editorial-forest/ caption-skin.html
HTML · 223 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: an oat-cream card on a single 2px green hairline border — the system's only
23 separator — with a 6px card radius and NO shadow (editorial-forest is flat, paper-based;
24 depth is color-block + hairline, never cast). Source Serif 4 weight 500, sentence case,
25 warm-ink glyphs. Upcoming words sit in faint ink; the current word gets a quiet
26 dusty-rose panel (a soft 6px-radius block, no blur — editorial restraint, not a loud
27 block) with ink reading on top; spoken words settle to solid ink, panel cleared. The
28 per-word emphasis accent is a 2px green hairline underline, never heavy.
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 oat-cream card — single 2px green hairline border (the system's only
70 separator), 6px card radius, NO shadow (flat, paper-based) */
71 .caption-pill {
72 max-width : 78 % ;
73 padding : 20 px 44 px 24 px ;
74 background : var ( --cap-canvas , #efe7d4 );
75 border : 2 px solid var ( --cap-accent , #d27e96 );
76 border-radius : 6 px ;
77 }
78 .caption-line {
79 display : flex ;
80 flex-wrap : wrap ;
81 justify-content : center ;
82 gap : 0.1 em 0.34 em ;
83 font-family : var ( --font-display , "Source Serif 4" ), Georgia , serif ;
84 font-weight : 500 ;
85 font-size : clamp ( 40 px , 4.4 vw , 58 px );
86 line-height : 1.16 ;
87 letter-spacing : -0.02 em ;
88 }
89
90 /* upcoming — faint warm ink, no panel */
91 .caption-word {
92 display : inline-block ;
93 padding : 0 0.06 em ;
94 color : color-mix ( in srgb , var ( --cap-ink , #1a1a17 ) 42 % , var ( --cap-canvas , #efe7d4 ));
95 }
96 /* current word — a quiet dusty-rose panel (box-shadow spread = a soft 6px block w/o
97 layout shift; no blur — editorial restraint, not a loud block), warm ink on top */
98 .caption-word.is-active {
99 color : var ( --cap-ink , #1a1a17 );
100 background : var ( --cap-accent , #d27e96 );
101 box-shadow : 0 0 0 0.05 em var ( --cap-accent , #d27e96 );
102 border-radius : 6 px ;
103 }
104 /* already spoken — solid warm ink, panel cleared */
105 .caption-word.is-spoken {
106 color : var ( --cap-ink , #1a1a17 );
107 background : transparent ;
108 box-shadow : none ;
109 }
110
111 /* optional per-word accents (dormant until a word-classer tags them) */
112 /* brand / key term — heavier serif weight, editorial-forest's only display inflection */
113 .caption-word.cap-brand {
114 font-weight : 600 ;
115 }
116 /* numerals / data — the mono chrome voice, slightly recessed */
117 .caption-word.cap-num {
118 font-family : var ( --font-body , "JetBrains Mono" ), ui-monospace , monospace ;
119 color : color-mix ( in srgb , var ( --cap-ink , #1a1a17 ) 72 % , var ( --cap-canvas , #efe7d4 ));
120 }
121 /* emphasis — a 2px green hairline underline (the system's only separator, never heavy) */
122 .caption-word.cap-cta {
123 text-decoration : underline ;
124 text-decoration-thickness : 2 px ;
125 text-decoration-color : var ( --cap-accent-2 , #e89cb1 );
126 text-underline-offset : 0.1 em ;
127 }
128
129 @media ( max-aspect-ratio : 9 / 16 ) {
130 .caption-pill {
131 max-width : 92 % ;
132 }
133 .caption-line {
134 font-size : clamp ( 34 px , 5.4 vw , 48 px );
135 }
136 }
137 </ style >
138
139 < div
140 id = "captions-root"
141 data-composition-id = "captions"
142 data-timeline-locked
143 data-start = "0"
144 data-duration = "0"
145 data-fps = "30"
146 data-width = "0"
147 data-height = "0"
148 >
149 < div class = "caption-layer" aria-hidden = "true" >
150 < div id = "caption-stage" class = "caption-stage" ></ div >
151 </ div >
152 </ div >
153
154 < script >
155 // captions.mjs injects the engine's scene-aware groups + real duration here.
156 var GROUPS = [];
157 var DURATION = 0 ;
158
159 ( function () {
160 var stage = document. getElementById ( "caption-stage" );
161
162 // build DOM: one .caption-group per group, .caption-word per word
163 GROUPS . forEach ( function ( group , g ) {
164 var groupEl = document. createElement ( "div" );
165 groupEl.className = "caption-group" ;
166 groupEl.id = "caption-group-" + g;
167 var pill = document. createElement ( "div" );
168 pill.className = "caption-pill" ;
169 var line = document. createElement ( "div" );
170 line.className = "caption-line" ;
171 (group.words || []). forEach ( function ( w , i ) {
172 var span = document. createElement ( "span" );
173 span.className = "caption-word" ;
174 span.id = "caption-word-" + g + "-" + i;
175 span.textContent = String (w.text);
176 line. appendChild (span);
177 });
178 pill. appendChild (line);
179 groupEl. appendChild (pill);
180 stage. appendChild (groupEl);
181 });
182
183 window.__timelines = window.__timelines || {};
184 var tl = gsap. timeline ({ paused: true });
185
186 GROUPS . forEach ( function ( group , g ) {
187 var groupEl = document. getElementById ( "caption-group-" + g);
188 var words = group.words || [];
189 var next = GROUPS [g + 1 ];
190 var isLast = g === GROUPS . length - 1 ;
191 var start = Math. max ( 0 , Number (group.start));
192 var end = isLast ? DURATION : Math. min ( Number (next.start), Number (group.end) + 0.3 );
193 if (end <= start) end = start + 0.01 ;
194
195 // group on/off — exactly one group visible at a time
196 tl. set (groupEl, { opacity: 1 }, start);
197 tl. set (groupEl, { opacity: 0 }, end);
198
199 // 3-state karaoke via className SETS — seek-safe (gsap.set applies on the
200 // engine's frame-by-frame seek; .call callbacks would NOT fire).
201 words. forEach ( function ( w , i ) {
202 var el = document. getElementById ( "caption-word-" + g + "-" + i);
203 var at = Math. max (start, Number (w.start));
204 tl. set (el, { className: "caption-word" }, start); // upcoming (also resets on reverse-seek)
205 tl. set (el, { className: "caption-word is-active" }, at); // current
206 tl. fromTo (el, { scale: 0.985 }, { scale: 1 , duration: 0.18 , ease: "power1.out" }, at);
207 if (i + 1 < words. length ) {
208 var nextAt = Math. max (start, Number (words[i + 1 ].start));
209 tl. set (el, { className: "caption-word is-spoken" }, nextAt); // demote when next activates
210 }
211 });
212 if (words. length ) {
213 var lastEl = document. getElementById ( "caption-word-" + g + "-" + (words. length - 1 ));
214 var lastSpoken = Math. min (end, Number (words[words. length - 1 ].end) + 0.1 );
215 tl. set (lastEl, { className: "caption-word is-spoken" }, lastSpoken);
216 }
217 });
218
219 // full-span anchor so the sub-comp timeline spans the whole video
220 tl. to ({}, { duration: DURATION }, 0 );
221 window.__timelines[ "captions" ] = tl;
222 })();
223 </ script >