Skip to content

Commit f693c8d

Browse files
Talha Jubair Siamtsensei
authored andcommitted
fix(captions): address code review findings
- Fix duplicate JSDoc opener in caption-utils.ts - Fix BoxHighlight borderRadius snap (spring-animate radius for active, settle to 4px for spoken, instead of binary 0/8 threshold) - Merge duplicate CaptionWrapper import in OpenReelsVideo.tsx - Add missing test for empty-after-linger chunk path
1 parent fbb8337 commit f693c8d

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/remotion/captions/BoxHighlight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const BoxHighlight: React.FC<CaptionStyleProps> = ({ wordStates, accentCo
3535
: ws.state === "spoken"
3636
? "rgba(255,255,255,0.08)"
3737
: "transparent",
38-
borderRadius: ws.springProgress > 0 ? 8 : 0,
38+
borderRadius: isActive ? 8 * ws.springProgress : ws.state === "spoken" ? 4 : 0,
3939
padding: `4px ${pad}px`,
4040
opacity: ws.state === "unspoken" ? 0.4 : 1,
4141
textShadow: ws.state === "unspoken" ? "0 2px 8px rgba(0,0,0,0.6)" : "none",

src/remotion/captions/caption-utils.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,12 @@ describe("getWordChunk", () => {
114114
const { chunkStart } = getWordChunk(gapped, 0.8, 2, 0.3);
115115
expect(chunkStart).toBe(0);
116116
});
117+
118+
it("returns empty chunk after voiceover ends plus linger", () => {
119+
// After the last word ends + lingerS, captions should fade out
120+
// instead of showing stale text during a musical outro.
121+
const { chunk, chunkStart } = getWordChunk(words, 5.0, 3, 0.3);
122+
expect(chunk).toEqual([]);
123+
expect(chunkStart).toBe(words.length);
124+
});
117125
});

src/remotion/captions/caption-utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export function getWordState(word: WordTimestamp, currentTime: number): WordStat
6262
}
6363

6464
/**
65-
/**
6665
* Compute WordRenderState[] for a chunk of words. Pure function, no React hooks.
6766
*
6867
* springFn receives a globalIndex and returns the spring progress (0-1) for that

src/remotion/compositions/OpenReelsVideo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import { TextCardBeat } from "../beats/TextCardBeat";
1414
import { BlockImpact } from "../captions/BlockImpact";
1515
import { BoldOutline } from "../captions/BoldOutline";
1616
import { BoxHighlight } from "../captions/BoxHighlight";
17-
import { CaptionWrapper, type SpringConfig } from "../captions/CaptionWrapper";
17+
import { CaptionWrapper, type SpringConfig, type CaptionStyleProps } from "../captions/CaptionWrapper";
1818
import { Clean } from "../captions/Clean";
1919
import { ColorHighlight } from "../captions/ColorHighlight";
2020
import { GradientRise } from "../captions/GradientRise";
2121
import { KaraokeSweep } from "../captions/KaraokeSweep";
22-
import type { CaptionStyleProps } from "../captions/CaptionWrapper";
2322
import type { CompositionProps, SceneProps } from "../lib/score-to-props";
2423

2524
const BEAT_COMPONENTS: Record<string, React.FC<SceneProps>> = {

0 commit comments

Comments
 (0)