π₯ Make videos programmatically with React
Docs: Rewrite Figma import guide (#9699)
Jonny Burgerc7911c34ab08
diff --git a/packages/docs/docs/figma.mdx b/packages/docs/docs/figma.mdxindex 575b23ccd0..279374d947 100644--- a/packages/docs/docs/figma.mdx+++ b/packages/docs/docs/figma.mdx@@ -2,131 +2,32 @@image: /generated/articles-docs-figma.pngid: figmatitle: Import from Figma-crumb: "The best of both"+crumb: 'The best of both'----You can export a design from Figma as an SVG file and import it as a React component in Remotion and then animate it.+# Import from Figma<AvailableFrom v="4.0.495" />-## Open the Figma design+There are two ways to import layers from Figma into Remotion Studio.-We are going to use a copy of [Streamline's Vector illustrations](https://www.figma.com/community/file/1118919399684035468).+## Copy as SVG-+This is the more reliable method. Right-click a layer and select **Copy/Paste as** β **Copy as SVG**.-## Grouping vector elements in Figma+-If not already done, group the items you want to export together or frame them in Figma.+Paste the copied layer into Remotion Studio.-+## Copy layer directly-Groups will be represented as `<g>` elements in SVG and if you want to animate multiple items together, it can be useful to group them.+You can also copy a layer directly and paste it into Remotion Studio.-## Export as SVG+Only some layer types are supported. Images are a notable exclusion.-You can export any design by copying it as SVG markup — you can do that by right-clicking on the design itself and selecting the **Copy/Paste as** option.+## Copy into code-+You can also copy SVG into Remotion markup.-Next, you need to convert the SVG into a React component. Often, you can just paste the SVG into React markup and it will work.--Alternatively, use the [SVGR playground](https://react-svgr.com/playground/) to reliably convert SVG into React components.--## Importing SVG in Remotion--Paste the component into a Remotion project and [register a `<Composition>`](/docs/composition).-An example can be found in this [repository](https://github.com/kaf-lamed-beyt/remo-sample).----## Animate SVG markup--Locate the element that you want to animate and add a style property to it.-In this case, let's animate the `<g>` element that contains the rocket.--```tsx twoslash-import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";--export const Rocket: React.FC = () => {- const frame = useCurrentFrame();- const { fps } = useVideoConfig();-- return (- <AbsoluteFill- style={{- backgroundColor: "pink",- justifyContent: "center",- alignItems: "center",- }}- >- <svg- width="800"- height="800"- viewBox="0 0 394 394"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <g- id="vehicle"- style={{- transformOrigin: "center center",- transformBox: "fill-box",- }}- >- // vehicle's paths- </g>- </svg>- </AbsoluteFill>- );-};-```--Adding `{transformOrigin: "center center", transformBox: "fill-box"}` will ensure that the transformations center is it's own center.--Let's create two spring animations, one for scale and one for transformation:--```tsx twoslash-import { interpolate, spring } from "remotion";-const fps = 30;-const frame = 0;-// ---cut----const up = spring({- fps,- frame: frame - 20,- config: {- damping: 20,- mass: 15,- },-});--const scale = spring({- fps,- frame,- config: {- stiffness: 200,- },-});--const launch = `translateY(${interpolate(up, [0, 1], [0, -3000])}px)`;-```--The `scale` will go from 0 to 1 and `launch` animates from `0` to `-3000px`. Apply the styles to the element:--```tsx {3}-<g- id="vehicle"- style={{- transform: `scale(${scale}) ${launch}`,- transformOrigin: "center center",- transformBox: "fill-box",- }}->- {/* ... */}-</g>-```----You have animated a rocket! π+Copy SVG as described above and run it through an [SVG to JSX converter](https://react-svgr.com/playground/). Then paste the result into the React markup that powers your Remotion video.## See alsodiff --git a/packages/docs/static/img/export-figma/banner.png b/packages/docs/static/img/export-figma/banner.pngdeleted file mode 100644index 1ac2dfa08b..0000000000Binary files a/packages/docs/static/img/export-figma/banner.png and /dev/null differdiff --git a/packages/docs/static/img/export-figma/copy-as-svg.png b/packages/docs/static/img/export-figma/copy-as-svg.pngindex efb085e0f4..a3654701b3 100644Binary files a/packages/docs/static/img/export-figma/copy-as-svg.png and b/packages/docs/static/img/export-figma/copy-as-svg.png differdiff --git a/packages/docs/static/img/export-figma/editor-pink.png b/packages/docs/static/img/export-figma/editor-pink.pngdeleted file mode 100644index 4ee6dedb65..0000000000Binary files a/packages/docs/static/img/export-figma/editor-pink.png and /dev/null differdiff --git a/packages/docs/static/img/export-figma/figma-grouping.gif b/packages/docs/static/img/export-figma/figma-grouping.gifdeleted file mode 100644index 6303096687..0000000000Binary files a/packages/docs/static/img/export-figma/figma-grouping.gif and /dev/null differdiff --git a/packages/docs/static/img/export-figma/rocket.gif b/packages/docs/static/img/export-figma/rocket.gifdeleted file mode 100644index 45a146e18f..0000000000Binary files a/packages/docs/static/img/export-figma/rocket.gif and /dev/null differ