Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "hook-punch",
"title": "Hook Punch",
"description": "A two-beat hook stops the scroll, then a gradient payoff lands: 'This video took 1 day.'.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/hook-punch/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport type React from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n spring,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst { fontFamily: grotesk } = loadFont(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: serifItalic } = loadSerif(\"italic\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\n\nexport interface HookPunchProps {\n /** First beat, set in the grotesk. */\n stop?: string;\n /** Second word of the first beat, set in the serif italic. */\n scroll?: string;\n /** Lead-in of the second beat. */\n lead?: string;\n /** The payoff, slammed huge. */\n payoff?: string;\n /** Kept for the shared draft API; the colour comes from the ground. */\n accent?: string;\n theme?: \"dark\" | \"light\";\n /** gradients.sh preset id for the ground. */\n ground?: GshPresetId;\n /** Overrides for the ground shader. */\n groundParams?: Partial<GradientParams>;\n speed?: number;\n}\n\nconst BEATS = {\n stop: 0,\n scroll: 6,\n whip: 30,\n whipLen: 8,\n lead: 33,\n pay: 42,\n rise: 43,\n} as const;\n\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst LIGHT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n dark: {\n stage: \"#03040A\",\n ink: \"#F2F3F8\",\n preset: \"cobalt-rise\" as GshPresetId,\n params: undefined as Partial<GradientParams> | undefined,\n veilFrom: 0.86,\n veilTo: 0.34,\n },\n light: {\n stage: \"#EEF0F6\",\n ink: \"#0E1230\",\n preset: \"paper-crease\" as GshPresetId,\n params: undefined as Partial<GradientParams> | undefined,\n veilFrom: 0.8,\n veilTo: 0.22,\n },\n} as const;\n\nfunction ramp(t: number, from: number, len: number) {\n return interpolate(t, [from, from + len], [0, 1], CLAMP);\n}\n\nfunction kick(d: number) {\n if (d < 0) return 0;\n if (d < 2) return d / 2;\n const k = Math.max(0, 1 - (d - 2) / 8);\n return k * k;\n}\n\nfunction shake(d: number, amp: number, seed: number) {\n if (d < 0 || d > 7) return { x: 0, y: 0 };\n const k = (1 - d / 7) ** 2;\n return {\n x: amp * k * Math.sin(d * 2.7 + seed),\n y: amp * 0.7 * k * Math.cos(d * 3.3 + seed * 1.7),\n };\n}\n\nexport function HookPunch({\n stop = \"Stop\",\n scroll = \"scrolling.\",\n lead = \"This video took\",\n payoff = \"1 day.\",\n theme = \"dark\",\n ground,\n groundParams,\n speed = 1,\n}: HookPunchProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H, fps } = useVideoConfig();\n const c = THEMES[theme];\n const tall = H > W;\n const base = tall ? W * 0.56 : H;\n const u = Math.min(W / 1280, H / 720);\n\n const slam = (at: number, from: number) => {\n const p = spring({ frame: t - at, fps, config: CARD });\n return {\n scale: from + (1 - from) * p,\n blur: Math.max(0, 1 - p) ** 2 * 18,\n opacity: ramp(t, at - 1, 2),\n };\n };\n\n const bump = Math.max(\n kick(t - BEATS.stop - 4),\n kick(t - BEATS.scroll - 4),\n 1.3 * kick(t - BEATS.pay - 4),\n );\n const s1 = shake(t - BEATS.stop - 4, 6 * u, 0.4);\n const s2 = shake(t - BEATS.scroll - 4, 5 * u, 2.1);\n const s3 = shake(t - BEATS.pay - 4, 8 * u, 4.2);\n const camScale = 1 + 0.03 * bump;\n\n const pStop = slam(BEATS.stop, 1.5);\n const pScroll = slam(BEATS.scroll, 1.5);\n const shove = 1 - spring({ frame: t - BEATS.scroll, fps, config: HEAVY });\n const creep1 = interpolate(t, [BEATS.scroll + 6, BEATS.whip], [1, 1.04], {\n ...CLAMP,\n easing: CAMERA,\n });\n const whip = EXIT(ramp(t, BEATS.whip, BEATS.whipLen));\n const line1Scale = creep1 * (1 + 1.6 * whip);\n const line1Blur = 22 * whip;\n const line1Opacity = 1 - ramp(t, BEATS.whip + 3, BEATS.whipLen - 3);\n\n const lead2 = spring({ frame: t - BEATS.lead, fps, config: HEAVY });\n const leadScale = 0.6 + 0.4 * lead2;\n const leadBlur = Math.max(0, 1 - lead2) * 16;\n const leadOpacity = ramp(t, BEATS.lead, 3);\n const pPay = slam(BEATS.pay, 1.6);\n const creep2 = interpolate(t, [BEATS.pay + 6, BEATS.pay + 62], [1, 1.035], {\n ...CLAMP,\n easing: CAMERA,\n });\n\n const rise = LIGHT(ramp(t, BEATS.rise, 26));\n const veil = c.veilFrom + (c.veilTo - c.veilFrom) * rise;\n const groundShift = (0.06 + (1 - rise) * 0.14) * H;\n\n const bigFs = 0.43 * base;\n const leadFs = 0.11 * base;\n const payFs = 0.56 * base;\n\n const word = (\n text: string,\n family: string,\n fs: number,\n p: { scale: number; blur: number; opacity: number },\n extra: React.CSSProperties = {},\n ) => (\n <div\n style={{\n fontFamily: family,\n fontSize: fs,\n lineHeight: 0.86,\n whiteSpace: \"nowrap\",\n transform: `scale(${p.scale})`,\n filter: p.blur > 0.2 ? `blur(${p.blur * u}px)` : undefined,\n opacity: p.opacity,\n ...extra,\n }}\n >\n {text}\n </div>\n );\n\n return (\n <AbsoluteFill style={{ background: c.stage, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n top: -0.3 * H,\n height: 1.55 * H,\n transform: `translateY(${groundShift - 0.25 * H}px) scale(1.06)`,\n }}\n >\n <GshGround\n preset={ground ?? c.preset}\n params={groundParams ?? c.params}\n timeOffset={3}\n timeScale={0.5}\n />\n </AbsoluteFill>\n <AbsoluteFill style={{ background: c.stage, opacity: veil }} />\n\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translate(${s1.x + s2.x + s3.x}px, ${s1.y + s2.y + s3.y}px) scale(${camScale})`,\n transformOrigin: \"50% 50%\",\n color: c.ink,\n }}\n >\n {t < BEATS.whip + BEATS.whipLen ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 0.01 * base,\n transform: `scale(${line1Scale})`,\n filter: line1Blur > 0.2 ? `blur(${line1Blur * u}px)` : undefined,\n opacity: line1Opacity,\n }}\n >\n <div\n style={{\n transform: `translateY(${shove * 0.5 * (bigFs * 1.06 * 0.86 + 0.01 * base)}px)`,\n }}\n >\n {word(stop, grotesk, bigFs, pStop, {\n fontWeight: 400,\n letterSpacing: \"-0.05em\",\n paddingRight: 0.02 * W,\n })}\n </div>\n {word(scroll, serifItalic, bigFs * 1.06, pScroll, {\n fontStyle: \"italic\",\n fontWeight: 400,\n letterSpacing: \"-0.03em\",\n paddingLeft: (tall ? 0.03 : 0.06) * W,\n })}\n </div>\n ) : null}\n\n {t >= BEATS.lead ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${creep2})`,\n }}\n >\n <div\n style={{\n fontFamily: grotesk,\n fontWeight: 300,\n fontSize: leadFs,\n lineHeight: 1,\n letterSpacing: \"-0.03em\",\n whiteSpace: \"nowrap\",\n transform: `scale(${leadScale})`,\n filter: leadBlur > 0.2 ? `blur(${leadBlur * u}px)` : undefined,\n opacity: leadOpacity,\n marginBottom: 0.02 * base,\n }}\n >\n {lead}\n </div>\n <div style={{ height: payFs * 0.92 }}>\n {t >= BEATS.pay - 1\n ? word(payoff, grotesk, payFs, pPay, {\n fontWeight: 400,\n lineHeight: 1,\n letterSpacing: \"-0.055em\",\n paddingRight: 0.03 * payFs,\n })\n : null}\n </div>\n </div>\n ) : null}\n </div>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/hook-punch.tsx"
}
],
"type": "registry:component"
}