fix(hook): Remotion overlay ignored the style picker, always rendered classic

d94e126 added the 6 hook styles to hooks.py (server FFmpeg path) and to the
HookModal picker, but never to the Remotion composition — which is what
renders both the modal preview and the final clip on the primary in-browser
render path. Picking dark/yellow/red/outline still produced the white
classic card.

- HookOverlay.tsx: HOOK_LOOKS map mirroring hooks.py HOOK_STYLES (box color,
  text color, outline stroke, shadow), applied via config.style.
- types.ts: HookStyle type on HookConfig and hookConfigSchema (default
  "classic" so older payloads keep validating).
This commit is contained in:
juancarlos.cavero 2026-08-19 14:12:10 +02:00
parent 3e8798f271
commit 8dbc6ce9bd
2 changed files with 40 additions and 4 deletions

View file

@ -26,6 +26,23 @@ const POSITION_STYLE: Record<string, React.CSSProperties> = {
bottom: { top: "68%", bottom: "auto" },
};
// Must mirror hooks.py HOOK_STYLES (the server-side FFmpeg fallback).
interface HookLook {
box: string | null;
text: string;
outlinePx: number;
shadow: boolean;
}
const HOOK_LOOKS: Record<string, HookLook> = {
classic: { box: "rgba(255, 255, 255, 0.94)", text: "#000000", outlinePx: 0, shadow: true },
dark: { box: "rgba(18, 18, 20, 0.92)", text: "#FFFFFF", outlinePx: 0, shadow: true },
yellow: { box: "rgba(255, 214, 0, 0.96)", text: "#000000", outlinePx: 0, shadow: true },
red: { box: "rgba(220, 38, 38, 0.96)", text: "#FFFFFF", outlinePx: 0, shadow: true },
outline: { box: null, text: "#FFFFFF", outlinePx: 8, shadow: false },
outline_yellow: { box: null, text: "#FFD600", outlinePx: 8, shadow: false },
};
export const HookOverlay: React.FC<HookOverlayProps> = ({ config }) => {
const { fps } = useVideoConfig();
const displayFrames = Math.round(config.displayDurationSec * fps);
@ -98,10 +115,12 @@ const HookBox: React.FC<HookBoxProps> = ({ config, displayFrames }) => {
}
const positionStyle = POSITION_STYLE[config.position] ?? POSITION_STYLE.top;
const look = HOOK_LOOKS[config.style ?? "classic"] ?? HOOK_LOOKS.classic;
// Base font size: 5% of 1080 width (matches hooks.py logic)
const baseFontSize = 1080 * 0.05;
const fontSize = Math.round(baseFontSize * scale);
const outlinePx = Math.round(look.outlinePx * scale);
return (
<div
@ -119,10 +138,10 @@ const HookBox: React.FC<HookBoxProps> = ({ config, displayFrames }) => {
opacity: animOpacity,
transform: `scale(${animScale}) translateY(${animTranslateY}px)`,
maxWidth: "90%",
backgroundColor: "rgba(255, 255, 255, 0.94)",
backgroundColor: look.box ?? "transparent",
borderRadius: 20,
padding: `${25 * scale}px ${30 * scale}px`,
boxShadow: "5px 5px 15px rgba(0, 0, 0, 0.25)",
padding: look.box ? `${25 * scale}px ${30 * scale}px` : 0,
boxShadow: look.shadow ? "5px 5px 15px rgba(0, 0, 0, 0.25)" : "none",
textAlign: "center",
}}
>
@ -131,9 +150,15 @@ const HookBox: React.FC<HookBoxProps> = ({ config, displayFrames }) => {
fontFamily: `'${NOTO_SERIF_FONT_FAMILY}', 'Noto Serif', Georgia, serif`,
fontSize,
fontWeight: 700,
color: "#000000",
color: look.text,
lineHeight: 1.4,
wordBreak: "break-word",
...(outlinePx > 0
? {
WebkitTextStroke: `${outlinePx}px #000000`,
paintOrder: "stroke fill",
}
: {}),
}}
>
{config.text}

View file

@ -36,11 +36,19 @@ export interface SubtitleConfig {
export type HookPosition = "top" | "center" | "bottom";
export type HookSize = "S" | "M" | "L";
export type HookEntrance = "spring" | "fade" | "slide-up" | "none";
export type HookStyle =
| "classic"
| "dark"
| "yellow"
| "red"
| "outline"
| "outline_yellow";
export interface HookConfig {
text: string;
position: HookPosition;
size: HookSize;
style?: HookStyle;
entranceAnimation: HookEntrance;
displayDurationSec: number;
}
@ -102,6 +110,9 @@ export const hookConfigSchema = z.object({
text: z.string(),
position: z.enum(["top", "center", "bottom"]),
size: z.enum(["S", "M", "L"]),
style: z
.enum(["classic", "dark", "yellow", "red", "outline", "outline_yellow"])
.default("classic"),
entranceAnimation: z.enum(["spring", "fade", "slide-up", "none"]),
displayDurationSec: z.number().positive(),
});