Last active
October 17, 2023 16:56
-
-
Save onion2k/688c0b92269b481c8699c4c1841f15a0 to your computer and use it in GitHub Desktop.
A Remotion component to display a library of other components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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