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:
parent
3e8798f271
commit
8dbc6ce9bd
2 changed files with 40 additions and 4 deletions
|
|
@ -26,6 +26,23 @@ const POSITION_STYLE: Record<string, React.CSSProperties> = {
|
||||||
bottom: { top: "68%", bottom: "auto" },
|
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 }) => {
|
export const HookOverlay: React.FC<HookOverlayProps> = ({ config }) => {
|
||||||
const { fps } = useVideoConfig();
|
const { fps } = useVideoConfig();
|
||||||
const displayFrames = Math.round(config.displayDurationSec * fps);
|
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 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)
|
// Base font size: 5% of 1080 width (matches hooks.py logic)
|
||||||
const baseFontSize = 1080 * 0.05;
|
const baseFontSize = 1080 * 0.05;
|
||||||
const fontSize = Math.round(baseFontSize * scale);
|
const fontSize = Math.round(baseFontSize * scale);
|
||||||
|
const outlinePx = Math.round(look.outlinePx * scale);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -119,10 +138,10 @@ const HookBox: React.FC<HookBoxProps> = ({ config, displayFrames }) => {
|
||||||
opacity: animOpacity,
|
opacity: animOpacity,
|
||||||
transform: `scale(${animScale}) translateY(${animTranslateY}px)`,
|
transform: `scale(${animScale}) translateY(${animTranslateY}px)`,
|
||||||
maxWidth: "90%",
|
maxWidth: "90%",
|
||||||
backgroundColor: "rgba(255, 255, 255, 0.94)",
|
backgroundColor: look.box ?? "transparent",
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
padding: `${25 * scale}px ${30 * scale}px`,
|
padding: look.box ? `${25 * scale}px ${30 * scale}px` : 0,
|
||||||
boxShadow: "5px 5px 15px rgba(0, 0, 0, 0.25)",
|
boxShadow: look.shadow ? "5px 5px 15px rgba(0, 0, 0, 0.25)" : "none",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
@ -131,9 +150,15 @@ const HookBox: React.FC<HookBoxProps> = ({ config, displayFrames }) => {
|
||||||
fontFamily: `'${NOTO_SERIF_FONT_FAMILY}', 'Noto Serif', Georgia, serif`,
|
fontFamily: `'${NOTO_SERIF_FONT_FAMILY}', 'Noto Serif', Georgia, serif`,
|
||||||
fontSize,
|
fontSize,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
color: "#000000",
|
color: look.text,
|
||||||
lineHeight: 1.4,
|
lineHeight: 1.4,
|
||||||
wordBreak: "break-word",
|
wordBreak: "break-word",
|
||||||
|
...(outlinePx > 0
|
||||||
|
? {
|
||||||
|
WebkitTextStroke: `${outlinePx}px #000000`,
|
||||||
|
paintOrder: "stroke fill",
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{config.text}
|
{config.text}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,19 @@ export interface SubtitleConfig {
|
||||||
export type HookPosition = "top" | "center" | "bottom";
|
export type HookPosition = "top" | "center" | "bottom";
|
||||||
export type HookSize = "S" | "M" | "L";
|
export type HookSize = "S" | "M" | "L";
|
||||||
export type HookEntrance = "spring" | "fade" | "slide-up" | "none";
|
export type HookEntrance = "spring" | "fade" | "slide-up" | "none";
|
||||||
|
export type HookStyle =
|
||||||
|
| "classic"
|
||||||
|
| "dark"
|
||||||
|
| "yellow"
|
||||||
|
| "red"
|
||||||
|
| "outline"
|
||||||
|
| "outline_yellow";
|
||||||
|
|
||||||
export interface HookConfig {
|
export interface HookConfig {
|
||||||
text: string;
|
text: string;
|
||||||
position: HookPosition;
|
position: HookPosition;
|
||||||
size: HookSize;
|
size: HookSize;
|
||||||
|
style?: HookStyle;
|
||||||
entranceAnimation: HookEntrance;
|
entranceAnimation: HookEntrance;
|
||||||
displayDurationSec: number;
|
displayDurationSec: number;
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +110,9 @@ export const hookConfigSchema = z.object({
|
||||||
text: z.string(),
|
text: z.string(),
|
||||||
position: z.enum(["top", "center", "bottom"]),
|
position: z.enum(["top", "center", "bottom"]),
|
||||||
size: z.enum(["S", "M", "L"]),
|
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"]),
|
entranceAnimation: z.enum(["spring", "fade", "slide-up", "none"]),
|
||||||
displayDurationSec: z.number().positive(),
|
displayDurationSec: z.number().positive(),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue