Skip to content

Instantly share code, notes, and snippets.

@onion2k
Last active October 17, 2023 16:56
Show Gist options
  • Save onion2k/688c0b92269b481c8699c4c1841f15a0 to your computer and use it in GitHub Desktop.
Save onion2k/688c0b92269b481c8699c4c1841f15a0 to your computer and use it in GitHub Desktop.
A Remotion component to display a library of other components
import {getInputProps, Composition, Sequence, Img } from 'remotion';
import React from 'react';
import { Arid } from './components/arid/Arid'
import { BlurSwipe } from './components/blur-swipe/BlurSwipe'
import { CSSAnim } from './components/CSSAnim/CSSAnim'
import chrome from "./assets/chrome.png"
const props = getInputProps()
const scale = props.scale || 1
const duration = props.duration || 300
const fps = props.fps || 60
const width = 1920 * scale;
const height = 1080 * scale;
export const Library: React.FC = () => {
const library = [
{ id: "Arid", component: Arid, props: { color: "lime" } },
{ id: "BlurSwipe", component: BlurSwipe, props: { direction: "right", children: <Img src={chrome} /> } },
{ id: "CSSAnim", component: CSSAnim, props: {} }
]
return (
<>
{
library.map((component)=>{
const comp = React.createElement(component.component as any, component.props);
return (
<Composition
id={component.id}
component={()=>(<Sequence from={0} durationInFrames={duration}>{comp}</Sequence>)}
durationInFrames={duration}
fps={fps}
width={width}
height={height}
/>
)
})
}
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment