Skip to content

🎥 Make videos programmatically with React

fix conflict

kaf-lamed-beytce28982809b2
diff --cc packages/docs/docs/exporting-from-figma.md
index 7e3bcf2494,352bc57897..27920af748
--- a/packages/docs/docs/exporting-from-figma.md
+++ b/packages/docs/docs/exporting-from-figma.md
@@@ -9,65 -9,62 +9,65 @@@ You can export a design from Figma as a
## Open the Figma design
- The design we'll consider here is a suite of 2D graphics made by [Streamline](https://www.figma.com/@05466272_9382_4) for the design community. You can get a copy [here](https://www.figma.com/community/file/1118919399684035468). When you click the link to the design, you can select from the list of designs available — in the sidebar
- ![Thumbnail](/static/img/export-figma/banner.png)
-The design we'll consider here is a suite of 3D graphics made by [Alzea Arafat](https://dribbble.com/alzea) for the design community. You can find them [here](<https://www.figma.com/file/VCoVolpndRmxkSd5AvctYZ/SALY---3D-Illustration-Pack-(Community)?node-id=7%3A4>). When you click the link to the design, click on the **"Library"** &mdash; in the sidebar &mdash; text to access all 3D graphics
-
++The design we'll consider here is a suite of 3D graphics made by [Alzea Arafat](https://dribbble.com/alzea) for the design community. You can find them [here](<https://www.figma.com/file/VCoVolpndRmxkSd5AvctYZ/SALY---3D-Illustration-Pack-(Community)?node-id=7%3A4>). When you click the link to the design, click on the **"Library"** &mdash; in the sidebar
+ ![Thumbnail](/img/export-figma/banner.png)
-Click on any of the vector graphics. Make sure you're selecting the 3D element alone. Don't select the whole container, the image below illustrates this.
+You do not necessarily have to use this specific design set. But, you should crosscheck to know if the type of SVG you want to export or copy is a pure SVG file, not one that exports an image file as SVG, a typical example would be similar to the snippet below.
+
+```jsx
+ <svg
+ width="2160"
+ height="2160"
+ viewBox="0 0 2160 2160"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlnsXlink="http://www.w3.org/1999/xlink"
+ >
+ <rect width="2160" height="2160" fill="url(#pattern0)" />
+ <defs>
+ <pattern
+ id="pattern0"
+ patternContentUnits="objectBoundingBox"
+ width="1"
+ height="1"
+ >
+ <use xlinkHref="#image0_11_37" transform="scale(0.000462963)" />
+ </pattern>
+ <image
+ id="image0_11_37"
+ width="2160"
+ height="2160"
+ xlinkHref="data:image/png;base64"
+ />
+ <defs>
+</svg>
+```
-When you select the vector element, a border will be around it to indicate that it is currently in focus. Looking at the image below, you'll notice on the right, there's a "right sidebar" component with different tabs namely, **Design**, **Prototype**, **Inspect**
+The snippet above does not represent a pure SVG file, because it literally just exports an image and wraps in the `<svg>` element. A proper SVG file would have all the corresponding `<path />` elements that we can animate conveniently.
- You can any design by copying it as an SVG file &mdash; you can do that by right-clicking on the design itself and selecting the **Copy/Paste as** option
-![exporting as SVG](/img/export-figma/export-as-svg.png)
++You can export any design by copying it as an SVG file &mdash; you can do that by right-clicking on the design itself and selecting the **Copy/Paste as** option
-Stay on the **Design** tab, then scroll down till you see the **Export** text, click on the plus sign next to it, select the **SVG** format from the file type dropdown menu, then click the export button
+![exporting as SVG](/static/img/export-figma/copy-as-svg.png)
-## Using the file in Remotion.
+With that out of the way, you'll need a way to represent this SVG as a react component, because of the camelCase attributes naming convention in React, the [react-svgr playground](https://react-svgr.com/playground/) eases the burden of this process for us.
-Now that you have exported the SVG file, it should be in your downloads folder. You can copy and paste the file into your remotion project or move the file(s) into the project to avoid duplicates.
+## Grouping vector elements in Figma
-When you open the SVG file, it'll look like the image below.
+This part is a bit important if you really want to get a seamless representation of the animations you're trying to create with Remotion.
-![svg file example](/img/export-figma/svg-file.png)
+By default, and sometimes, the designs you want to export as an SVG file will have scattered vector elements, you'd need to group these elements into independent structures.
-You should take note of attributes like `xmlns:xlink` or `xlink:href` because TypeScript will throw an error due to how html attributes are used in React, these attributes have to be in `camelCase` form.
+Take for example the Rocket SVG that we'll animate. When you take a look at the illustration below, you'll see various parts of the Rocket already grouped into primary components **Vehicle**, **smoke** and the **launchpad**.
-With that out of the way, you can go ahead to create a React component that serves as a wrapper for the SVG element.
+![figma-grouping](/static/img/export-figma/figma-grouping.gif)
-```tsx
-export const BikerSVG: React.FC = () => {
- return (
- <svg
- width="2160"
- height="2160"
- viewBox="0 0 2160 2160"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- xmlnsXlink="http://www.w3.org/1999/xlink"
- >
- <rect width="2160" height="2160" fill="url(#pattern0)" />
- <defs>
- <pattern
- id="pattern0"
- patternContentUnits="objectBoundingBox"
- width="1"
- height="1"
- >
- <use xlinkHref="#image0_11_37" transform="scale(0.000462963)" />
- </pattern>
- <image
- id="image0_11_37"
- width="2160"
- height="2160"
- xlinkHref="data:image/png;base64"
- />
- <defs>
- </svg>
- )
-}
-```
+You can select elements that you want to animate and group them with these key combinations `Ctrl + G` if you're on a Windows machine or `Command key + G` if you're on a Mac.
+
+When you group the SVG by adding smaller chunks of the elements to a larger component or structure, you make it easy for it to be animated or styled individually.
+
+## Using the file in Remotion.
+
+Now that you have exported the SVG file and retrieved it in the appropriate JSX syntax from [react-svgr playground](https://react-svgr.com/playground/). You can copy and paste the file into your remotion project or create reusable components from it.
When you're done with that, you can use the component alongside Remotion's built-in `Composition` component. You can look at the result in this [repo](https://github.com/kaf-lamed-beyt/remo-sample).