Skip to content

🎥 Make videos programmatically with React

call to action

JonnyBurger5ac2fe276f4b
diff --git a/packages/example/src/CallToAction/index.tsx b/packages/example/src/CallToAction/index.tsx
new file mode 100644
index 0000000000..7ae97a4563
--- /dev/null
+++ b/packages/example/src/CallToAction/index.tsx
@@ -0,0 +1,110 @@
+import {visualControl} from '@remotion/studio';
+import React, {useContext} from 'react';
+import {
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
+} from 'remotion';
+import {ExtrudeDiv} from '../3DContext/Div3D';
+import {
+ RotateX,
+ RotateY,
+ TranslateX,
+ TranslateY,
+} from '../3DContext/transformation-context';
+import {AtRemotionButton} from '../Compose/AtRemotionButton';
+import {DepthContext} from '../Compose/JumpThenDisappear';
+
+export const CallToAction: React.FC<{
+ cornerRadius: number;
+ children: React.ReactNode;
+ width: number;
+ height: number;
+}> = ({cornerRadius, children, width, height}) => {
+ const depth = useContext(DepthContext);
+
+ return (
+ <ExtrudeDiv
+ width={width}
+ height={height}
+ depth={depth}
+ cornerRadius={cornerRadius}
+ >
+ <AbsoluteFill
+ className="bg-white justify-center items-center"
+ style={{
+ borderRadius: cornerRadius,
+ border: '3px solid black',
+ overflow: 'hidden',
+ }}
+ >
+ {children}
+ </AbsoluteFill>
+ </ExtrudeDiv>
+ );
+};
+
+export const CTAEndCard: React.FC = () => {
+ const {height, width, fps} = useVideoConfig();
+ const frame = useCurrentFrame();
+
+ const stat = frame * 0.0005;
+
+ const jumpUp =
+ spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: 40,
+ }) + stat;
+
+ const progress =
+ spring({
+ fps,
+ frame,
+ durationInFrames: 25,
+ delay: 40,
+ config: {
+ damping: 14,
+ },
+ }) + stat;
+
+ const WIDTH = interpolate(progress, [0, 1], [350, 350 * 8]);
+ const HEIGHT = interpolate(progress, [0, 1], [100, 400 * 4]);
+
+ const up = interpolate(jumpUp, [0, 1], [600, 0]);
+
+ return (
+ <AbsoluteFill
+ style={{
+ borderRadius: 10,
+ }}
+ >
+ <div className="flex flex-row">
+ <div style={{position: 'absolute'}}>
+ <DepthContext value={50}>
+ <RotateX radians={visualControl('x', -0.4) * jumpUp + 0.1}>
+ <RotateY radians={visualControl('y', -0.8) * jumpUp}>
+ <TranslateX px={(width - WIDTH) / 2}>
+ <TranslateY px={(height - HEIGHT) / 2 + up + 200}>
+ <CallToAction
+ cornerRadius={HEIGHT / 2}
+ width={WIDTH}
+ height={HEIGHT}
+ >
+ <AtRemotionButton progress={progress} />
+ </CallToAction>
+ </TranslateY>
+ </TranslateX>
+ </RotateY>
+ </RotateX>
+ </DepthContext>
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/example/src/Compose/AtRemotionButton.tsx b/packages/example/src/Compose/AtRemotionButton.tsx
index 046f2e1205..6e9bf860d7 100644
--- a/packages/example/src/Compose/AtRemotionButton.tsx
+++ b/packages/example/src/Compose/AtRemotionButton.tsx
@@ -1,15 +1,16 @@
import {AbsoluteFill} from 'remotion';
-export const AtRemotionButton: React.FC = () => {
+export const AtRemotionButton: React.FC<{progress: number}> = ({progress}) => {
return (
- <AbsoluteFill className="bg-black justify-center items-center border-2 border-solid border-white rounded-full">
+ <AbsoluteFill className="bg-white justify-center items-center border-2 border-solid border-white rounded-full">
<div
- className="text-white text-3xl font-brand"
+ className="text-black text-3xl font-brand"
style={{
fontFamily: 'GT Planar',
+ opacity: 1.1 - progress * 3,
}}
>
- @remotion
+ Follow @JNYBGR
</div>
</AbsoluteFill>
);
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index f3b80c66ca..1ae099ffbb 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -122,6 +122,7 @@ import {ThreeDEngine} from './3DEngine';
import {ThreeDSvgContent} from './3DSvgContent';
import {AnimatedImages} from './AnimatedImage/Avif';
import Amplify from './AudioTesting/Amplify';
+import {CTAEndCard} from './CallToAction';
import {
WhatIsRemotion,
whatIsRemotionCalculateMetadata,
@@ -1755,6 +1756,17 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={500}
/>
+ <Composition
+ id="CallToAction"
+ component={CTAEndCard}
+ width={1920}
+ height={1080}
+ fps={30}
+ durationInFrames={90}
+ defaultProps={{
+ cornerRadius: 10,
+ }}
+ />
</>
);
};