Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
"use client";
import {
type DropdownMenuState,
type DropdownMenuStyle,
dropdownMenuStyle,
dropdownMenuStyleContext,
} from "@/components/remocn/dropdown-menu";
import {
easings,
type RemocnTheme,
type Step,
useRemocnTheme,
useStateTransition,
} from "@/lib/remocn-ui";
export const DEFAULT_DURATION = 12;
export function tweenDropdownMenuStyle(
a: DropdownMenuStyle,
b: DropdownMenuStyle,
t: number,
): DropdownMenuStyle {
return {
panelOpacity: a.panelOpacity + (b.panelOpacity - a.panelOpacity) * t,
panelScale: a.panelScale + (b.panelScale - a.panelScale) * t,
panelTranslateY:
a.panelTranslateY + (b.panelTranslateY - a.panelTranslateY) * t,
chevronRotation:
a.chevronRotation + (b.chevronRotation - a.chevronRotation) * t,
};
}
export interface DropdownMenuTransitionOptions {
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
primary?: string;
speed?: number;
defaultDuration?: number;
}
export function useDropdownMenuTransition(
steps: Step<DropdownMenuState>[],
opts: DropdownMenuTransitionOptions = {},
): DropdownMenuStyle {
const {
theme: themeOverride,
mode,
primary,
speed = 1,
defaultDuration = DEFAULT_DURATION,
} = opts;
const theme = useRemocnTheme(
{ ...themeOverride, ...(primary ? { primary } : {}) },
mode,
);
const ctx = dropdownMenuStyleContext(theme);
const { from, to, progress } = useStateTransition(
steps,
"closed",
speed,
defaultDuration,
);
const t = easings.out(progress);
return tweenDropdownMenuStyle(
dropdownMenuStyle(from, ctx),
dropdownMenuStyle(to, ctx),
t,
);
}