import React from "react"; import { AbsoluteFill, Img, interpolate, spring, staticFile, useCurrentFrame, useVideoConfig } from "remotion"; import { FONT } from "../../lib/fonts"; import { hexToRgba, mixHex } from "../../lib/anim"; import { ThreeBackdrop, Grain, Vignette, ProgressDots, Kicker, useSceneTransition } from "../chrome"; import type { BlockProps, SceneBlock } from "../types"; const resolveSrc = (u: string) => (/^https?:\/\//.test(u) ? u : staticFile(u)); const ImageCaption: React.FC = ({ data, colors, L, index, total, durationInFrames }) => { const frame = useCurrentFrame(); const { fps } = useVideoConfig(); const { opacity, slide } = useSceneTransition(durationInFrames, L); const cardSp = spring({ frame: frame - 2, fps, config: { damping: 18, stiffness: 90 } }); const cardScale = interpolate(cardSp, [0, 1], [0.9, 1]); const float = Math.sin(frame / 26) * L.vmin(8); const textSp = spring({ frame: frame - 10, fps, config: { damping: 18, stiffness: 110 } }); const textX = interpolate(textSp, [0, 1], [L.vmin(40), 0]); const cardW = L.pick(L.vmin(820), L.vmin(720), L.vmin(820)); const cardH = L.pick(L.vmin(520), L.vmin(470), L.vmin(560)); const Card = (
{data.imageUrl ? ( ) : (
🖼
)}
); const Text = (
{data.title}
{data.caption}
); return ( {Card} {Text} ); }; export const ImageCaptionBlock: SceneBlock = { id: "ImageCaption", label: "تصویر و توضیح", component: ImageCaption, fields: [ { key: "imageUrl", label: "تصویر", type: "image", default: "" }, { key: "title", label: "عنوان", type: "text", default: "ویژگی شما" }, { key: "caption", label: "توضیح", type: "text", default: "توضیح کوتاه دربارهٔ این تصویر یا ویژگی", multiline: true }, ], defaultDurationSec: 4, minDurationSec: 2, maxDurationSec: 8, };