Skip to content

πŸŽ₯ Make videos programmatically with React

Remove pre-compose demos from example

JonnyBurgerfbc80f4e1d37
diff --git a/packages/example/src/BarChart.tsx b/packages/example/src/BarChart.tsx
index a414868297..1dff1dda25 100644
--- a/packages/example/src/BarChart.tsx
+++ b/packages/example/src/BarChart.tsx
@@ -2,7 +2,6 @@ import {
AbsoluteFill,
Easing,
Interactive,
- Sequence,
interpolate,
useCurrentFrame,
useVideoConfig,
@@ -132,13 +131,46 @@ export const BarChart: React.FC = () => {
overflow: 'hidden',
}}
>
- <Sequence layout="none" name="Ambient glow">
- <AmbientGlow frame={frame} durationInFrames={durationInFrames} />
- </Sequence>
+ <Interactive.Div
+ name="Ambient glow"
+ style={{
+ position: 'absolute',
+ width: 520,
+ height: 520,
+ right: -150,
+ top: -230,
+ borderRadius: 999,
+ background: 'rgba(115, 91, 255, 0.18)',
+ filter: 'blur(90px)',
+ scale: interpolate(frame, [0, durationInFrames - 1], [0.92, 1.08], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ easing: Easing.inOut(Easing.sin),
+ output: 'perceptual-scale',
+ }),
+ }}
+ />
- <Sequence layout="none" name={'Eyebrow'}>
- <Eyebrow frame={frame} />
- </Sequence>
+ <Interactive.Div
+ name="Eyebrow"
+ style={{
+ position: 'absolute',
+ left: 86,
+ top: 66,
+ color: '#8E9AB8',
+ fontSize: 20,
+ fontWeight: 750,
+ letterSpacing: 4.4,
+ textTransform: 'uppercase',
+ opacity: interpolate(frame, [3, 20], [0, 1], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ easing: Easing.bezier(0.16, 1, 0.3, 1),
+ }),
+ }}
+ >
+ Performance overview
+ </Interactive.Div>
<Interactive.Div
name="Title"
@@ -251,58 +283,6 @@ export const BarChart: React.FC = () => {
</Interactive.Div>
</Interactive.Div>
- <Sequence layout="none" name={'Peak badge'}>
- <PeakBadge frame={frame} />
- </Sequence>
- </AbsoluteFill>
- );
-};
-
-export function AmbientGlow({
- frame: parentFrame,
- durationInFrames: parentDurationInFrames,
-}: {
- frame?: number | null;
- durationInFrames?: number | null;
-}) {
- const standaloneFrame = useCurrentFrame();
- const {durationInFrames: standaloneDurationInFrames} = useVideoConfig();
- const frame = parentFrame ?? standaloneFrame;
- const durationInFrames = parentDurationInFrames ?? standaloneDurationInFrames;
- return (
- <>
- <Interactive.Div
- name="Ambient glow"
- style={{
- position: 'absolute',
- width: 520,
- height: 520,
- right: -150,
- top: -230,
- borderRadius: 999,
- background: 'rgba(115, 91, 255, 0.18)',
- filter: 'blur(90px)',
- scale: interpolate(frame, [0, durationInFrames - 1], [0.92, 1.08], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- easing: Easing.inOut(Easing.sin),
- output: 'perceptual-scale',
- }),
- }}
- />
- </>
- );
-}
-
-export function PeakBadge({
- frame: precomposeParentFrame,
-}: {
- frame?: number | null;
-}) {
- const precomposeStandaloneFrame = useCurrentFrame();
- const frame = precomposeParentFrame ?? precomposeStandaloneFrame;
- return (
- <>
<Interactive.Div
name="Peak badge"
style={{
@@ -334,39 +314,6 @@ export function PeakBadge({
>
<span style={{fontSize: 13}}>●</span> West leads at 87%
</Interactive.Div>
- </>
- );
-}
-
-export function Eyebrow({
- frame: precomposeParentFrame2,
-}: {
- frame?: number | null;
-}) {
- const precomposeStandaloneFrame2 = useCurrentFrame();
- const frame = precomposeParentFrame2 ?? precomposeStandaloneFrame2;
- return (
- <>
- <Interactive.Div
- name="Eyebrow"
- style={{
- position: 'absolute',
- left: 86,
- top: 66,
- color: '#8E9AB8',
- fontSize: 20,
- fontWeight: 750,
- letterSpacing: 4.4,
- textTransform: 'uppercase',
- opacity: interpolate(frame, [3, 20], [0, 1], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- easing: Easing.bezier(0.16, 1, 0.3, 1),
- }),
- }}
- >
- Performance overview
- </Interactive.Div>
- </>
+ </AbsoluteFill>
);
-}
+};
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index c821ebc0a6..bec6c7f339 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -11,7 +11,7 @@ import {
import {z} from 'zod';
import {TwentyTwoKHzAudio} from './22KhzAudio';
import {UseanimatedEmojis} from './AnimatedEmojis';
-import {AmbientGlow, BarChart, PeakBadge, Eyebrow} from './BarChart';
+import {BarChart} from './BarChart';
import BetaText, {betaTextSchema} from './BetaText';
import {NativeBufferStateForImage} from './BufferState/Image';
import {NativeBufferState} from './BufferState/Simple';
@@ -469,14 +469,6 @@ export const Index: React.FC = () => {
width={1280}
height={720}
/>
- <Composition
- id="AmbientGlow"
- component={AmbientGlow}
- durationInFrames={180}
- fps={30}
- width={1280}
- height={720}
- />
<Folder name="maptiler">
<Composition
id="switzerland-map"
@@ -3248,22 +3240,6 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={180}
/>
- <Composition
- id="PeakBadge"
- component={PeakBadge}
- durationInFrames={180}
- fps={30}
- width={1280}
- height={720}
- />
- <Composition
- id="Eyebrow"
- component={Eyebrow}
- durationInFrames={180}
- fps={30}
- width={1280}
- height={720}
- />
</>
);
};