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/daisy-days/ caption-skin.html
HTML · 230 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 cheerful picture-book card — a cream surface inside a 3px charcoal outline
23 with a hard 6px charcoal offset shadow (no blur) and a generous 24px radius, the
24 sticker-on-paper signature. Fredoka One glyphs, sentence case, charcoal ink. Upcoming
25 words sit in muted charcoal; the current word pops into a rounded sunny-pastel candy
26 block (coral fill, 3px charcoal outline, hard 3px offset shadow, 12px radius) with a
27 bouncy scale pop; spoken words settle to solid charcoal, the candy block cleared.
28 -->
29 < script src = "https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js" ></ script >
30
31 <!-- captions.mjs injects the project's :root tokens here -->
32 < style data-brand-tokens ></ style >
33
34 < style >
35 #captions-root {
36 position : absolute ;
37 inset : 0 ;
38 pointer-events : none ;
39 }
40 .caption-layer {
41 position : absolute ;
42 inset : 0 ;
43 z-index : 20 ;
44 pointer-events : none ;
45 }
46 /* the keep-out band, from captionBand(H) — frame content stays above it */
47 .caption-stage {
48 position : absolute ;
49 left : 0 ;
50 right : 0 ;
51 top : var ( --cap-band-top , 900 px );
52 height : var ( --cap-band-height , 180 px );
53 display : flex ;
54 align-items : center ;
55 justify-content : center ;
56 }
57 .caption-group {
58 /* every group is absolutely stacked over the SAME band — exactly one shown at a
59 time via opacity. Must be absolute: in-flow groups would lay out side-by-side. */
60 position : absolute ;
61 inset : 0 ;
62 display : flex ;
63 align-items : center ;
64 justify-content : center ;
65 opacity : 0 ;
66 }
67
68 /* THE picture-book card — cream surface, 3px charcoal outline, generous 24px radius,
69 a hard 6px charcoal offset shadow (no blur): the sticker-on-paper signature */
70 .caption-pill {
71 max-width : 80 % ;
72 padding : 18 px 40 px 22 px ;
73 background : var ( --cap-canvas , #f5f0e6 );
74 border : 3 px solid var ( --cap-ink , #2d2d2d );
75 border-radius : 24 px ;
76 box-shadow : 6 px 6 px 0 var ( --cap-ink , #2d2d2d );
77 }
78 .caption-line {
79 display : flex ;
80 flex-wrap : wrap ;
81 justify-content : center ;
82 gap : 0.18 em 0.32 em ;
83 font-family : var ( --font-display , "Fredoka One" ), "Baloo 2" , sans-serif ;
84 font-weight : 600 ;
85 font-size : clamp ( 38 px , 4.2 vw , 56 px );
86 line-height : 1.22 ;
87 letter-spacing : 0.02 em ;
88 }
89
90 /* upcoming — muted charcoal, no candy block */
91 .caption-word {
92 display : inline-block ;
93 padding : 0.02 em 0.16 em ;
94 border-radius : 12 px ;
95 color : color-mix ( in srgb , var ( --cap-ink , #2d2d2d ) 52 % , var ( --cap-canvas , #f5f0e6 ));
96 }
97 /* current word — THE sunny-pastel candy block: a rounded coral chip with a 3px
98 charcoal outline + a hard 3px charcoal offset shadow (no blur), charcoal on top */
99 .caption-word.is-active {
100 color : var ( --cap-ink , #2d2d2d );
101 background : var ( --cap-accent , #f8635f );
102 border-radius : 12 px ;
103 box-shadow :
104 0 0 0 3 px var ( --cap-ink , #2d2d2d ),
105 3 px 5 px 0 0 var ( --cap-ink , #2d2d2d );
106 }
107 /* already spoken — solid charcoal, candy block cleared */
108 .caption-word.is-spoken {
109 color : var ( --cap-ink , #2d2d2d );
110 background : transparent ;
111 box-shadow : none ;
112 }
113
114 /* optional per-word accents (dormant until a word-classer tags them) */
115 /* brand / key term — a butter candy chip, the cheerful second pastel */
116 .caption-word.cap-brand {
117 color : var ( --cap-ink , #2d2d2d );
118 background : var ( --cap-accent-2 , #fde68a );
119 border-radius : 12 px ;
120 box-shadow : 0 0 0 3 px var ( --cap-ink , #2d2d2d );
121 }
122 /* numerals / data — Quicksand, slightly recessed */
123 .caption-word.cap-num {
124 font-family : var ( --font-body , "Quicksand" ), system-ui , sans-serif ;
125 font-weight : 700 ;
126 color : color-mix ( in srgb , var ( --cap-ink , #2d2d2d ) 78 % , var ( --cap-canvas , #f5f0e6 ));
127 }
128 /* emphasis — a butter underline rule (the second sunny pastel) */
129 .caption-word.cap-cta {
130 text-decoration : underline ;
131 text-decoration-thickness : 3 px ;
132 text-decoration-color : var ( --cap-accent-2 , #fde68a );
133 text-underline-offset : 0.12 em ;
134 }
135
136 @media ( max-aspect-ratio : 9 / 16 ) {
137 .caption-pill {
138 max-width : 92 % ;
139 }
140 .caption-line {
141 font-size : clamp ( 32 px , 5.2 vw , 46 px );
142 }
143 }
144 </ style >
145
146 < div
147 id = "captions-root"
148 data-composition-id = "captions"
149 data-timeline-locked
150 data-start = "0"
151 data-duration = "0"
152 data-fps = "30"
153 data-width = "0"
154 data-height = "0"
155 >
156 < div class = "caption-layer" aria-hidden = "true" >
157 < div id = "caption-stage" class = "caption-stage" ></ div >
158 </ div >
159 </ div >
160
161 < script >
162 // captions.mjs injects the engine's scene-aware groups + real duration here.
163 var GROUPS = [];
164 var DURATION = 0 ;
165
166 ( function () {
167 var stage = document. getElementById ( "caption-stage" );
168
169 // build DOM: one .caption-group per group, .caption-word per word
170 GROUPS . forEach ( function ( group , g ) {
171 var groupEl = document. createElement ( "div" );
172 groupEl.className = "caption-group" ;
173 groupEl.id = "caption-group-" + g;
174 var pill = document. createElement ( "div" );
175 pill.className = "caption-pill" ;
176 var line = document. createElement ( "div" );
177 line.className = "caption-line" ;
178 (group.words || []). forEach ( function ( w , i ) {
179 var span = document. createElement ( "span" );
180 span.className = "caption-word" ;
181 span.id = "caption-word-" + g + "-" + i;
182 span.textContent = String (w.text);
183 line. appendChild (span);
184 });
185 pill. appendChild (line);
186 groupEl. appendChild (pill);
187 stage. appendChild (groupEl);
188 });
189
190 window.__timelines = window.__timelines || {};
191 var tl = gsap. timeline ({ paused: true });
192
193 GROUPS . forEach ( function ( group , g ) {
194 var groupEl = document. getElementById ( "caption-group-" + g);
195 var words = group.words || [];
196 var next = GROUPS [g + 1 ];
197 var isLast = g === GROUPS . length - 1 ;
198 var start = Math. max ( 0 , Number (group.start));
199 var end = isLast ? DURATION : Math. min ( Number (next.start), Number (group.end) + 0.3 );
200 if (end <= start) end = start + 0.01 ;
201
202 // group on/off — exactly one group visible at a time
203 tl. set (groupEl, { opacity: 1 }, start);
204 tl. set (groupEl, { opacity: 0 }, end);
205
206 // 3-state karaoke via className SETS — seek-safe (gsap.set applies on the
207 // engine's frame-by-frame seek; .call callbacks would NOT fire).
208 words. forEach ( function ( w , i ) {
209 var el = document. getElementById ( "caption-word-" + g + "-" + i);
210 var at = Math. max (start, Number (w.start));
211 tl. set (el, { className: "caption-word" }, start); // upcoming (also resets on reverse-seek)
212 tl. set (el, { className: "caption-word is-active" }, at); // current
213 tl. fromTo (el, { scale: 0.82 }, { scale: 1 , duration: 0.2 , ease: "back.out(2.6)" }, at);
214 if (i + 1 < words. length ) {
215 var nextAt = Math. max (start, Number (words[i + 1 ].start));
216 tl. set (el, { className: "caption-word is-spoken" }, nextAt); // demote when next activates
217 }
218 });
219 if (words. length ) {
220 var lastEl = document. getElementById ( "caption-word-" + g + "-" + (words. length - 1 ));
221 var lastSpoken = Math. min (end, Number (words[words. length - 1 ].end) + 0.1 );
222 tl. set (lastEl, { className: "caption-word is-spoken" }, lastSpoken);
223 }
224 });
225
226 // full-span anchor so the sub-comp timeline spans the whole video
227 tl. to ({}, { duration: DURATION }, 0 );
228 window.__timelines[ "captions" ] = tl;
229 })();
230 </ script >