🎥 Make videos programmatically with React
Docs: Explain assets in Element contributions (#11530)
Igor Samokhovets8cde86bf9856
diff --git a/packages/docs/docs/studio-protocol/component-library-integration.mdx b/packages/docs/docs/studio-protocol/component-library-integration.mdxindex b12350be8d..12bd4d3297 100644--- a/packages/docs/docs/studio-protocol/component-library-integration.mdx+++ b/packages/docs/docs/studio-protocol/component-library-integration.mdx@@ -27,15 +27,21 @@ Show each component in a [`<Player>`](/docs/player). The preview lets users examImport the component normally for the preview. The website bundler then compiles the component.-Use the same dimensions and duration in the Player and the Element payload. For replaceable starter content in either installation mode, set [`initialProps`](/docs/studio-protocol/create-element-payload#initialprops) in the payload and pass the corresponding values to the Player as `inputProps`.+Use the same dimensions and duration in the Player and the Element payload.-### Preview installed assets+### Preview installed assets<AvailableFrom v="4.0.528" />-Accept asset URLs as component props. Pass hosted URLs to the Player, and use [`staticFileRef()`](/docs/studio-protocol/static-file-ref) in the payload's `initialProps` for assets that should be installed. Declare each referenced path in [`assets`](/docs/studio-protocol/create-element-payload#assets).+Accept image, audio, and video URLs as component props, rather than hardcoding preview URLs or installed file paths in the source.-Studio installs the assets and generates [`staticFile()`](/docs/staticfile) expressions on the component invocation. The Element source stays unchanged. This works in both installation modes.+Pass normal URL strings to the Player. These may point to assets served by your preview website or, if you prefer, hosted elsewhere. The preview location does not need to match the installed asset path.-Assets that should remain remote after installation can use URL strings directly in `initialProps`.+For assets that should be copied into the user's project, declare them in the payload's [`assets`](/docs/studio-protocol/create-element-payload#assets). Choose public-relative paths scoped to the component, such as `my-element/logo.png`, to reduce collisions with other components.++In the payload's `initialProps`, replace each corresponding URL with [`staticFileRef()`](/docs/studio-protocol/static-file-ref), referencing the declared asset path. Keep these references out of the Player's `inputProps`: they are installation metadata, not runtime URLs. See the [`staticFileRef()` example](/docs/studio-protocol/static-file-ref#example) for the complete payload and generated code.++Studio saves the assets into the public directory and generates [`staticFile()`](/docs/staticfile) expressions on the component invocation. The Element source stays unchanged. This works in both installation modes.++For assets that should remain remote after installation, keep URL strings in `initialProps` instead of using references. Those assets continue to depend on the remote host.## Reuse component code@@ -100,7 +106,8 @@ When Studio embeds the library through Browse Elements, use [`isInsideStudio()`]- Compare the Player preview with the installed Element.- Validate each payload with `createElementPayload()`.- Test installation and cross-tab drag-and-drop from the production website.-- Install the Element in a clean Remotion project. Check for unresolved imports, package dependencies, and assets.+- Install the Element in a clean Remotion project. Check for unresolved imports and package dependencies.+- Verify that installed assets appear in the public directory and render or play from local files. Confirm that assets intended to stay remote still use their URLs.- Treat the source code as public. The browser receives it, and Studio shows it.- Serve the production website through HTTPS. HTTP is supported only on `localhost` and `127.0.0.1`.diff --git a/packages/docs/elements/contributing.mdx b/packages/docs/elements/contributing.mdxindex b7e20f6fdf..1990c79a6a 100644--- a/packages/docs/elements/contributing.mdx+++ b/packages/docs/elements/contributing.mdx@@ -51,7 +51,7 @@ Include:- A working PNG and MP4 preview- Links to inspiration, if any-Keep “Allow edits from maintainers” enabled on the pull request. After approval, a repository maintainer uploads the assets to static storage.+Keep “Allow edits from maintainers” enabled on the pull request. After approval, a repository maintainer uploads the gallery previews to static storage.## Element Guidelines@@ -74,7 +74,7 @@ The caption Elements show the distinction: moving a pill between words, popping- Keep the implementation self-contained, using HTML, CSS, and React where possible.- Avoid global styles, layout side effects, and fullscreen assumptions unless the Element is a background.- Set explicit defaults for inherited visual properties. In particular, set text colors on the Element root or the nearest visual surface instead of relying on browser or host-page defaults. Ensure every use of `currentColor` resolves from an ancestor with an explicit color so the Element looks the same under light and dark host themes.-- Use stable remote asset URLs and Google Fonts for non-websafe fonts.+- [Include assets](#include-assets) that should be copied into the user's project. Use Google Fonts for non-websafe fonts.- Avoid project-specific branding or footage, and make colors easy to change.- Minimize dependencies. [Remotion Effects](/docs/effects) are an acceptable exception.- Declare every external dependency in the central Element definition, except `react`, `react-dom`, and `remotion`. Every non-Remotion package must use an exact semantic version; version ranges and tags are not accepted. Remotion packages use `version: null` and are installed at the project's Remotion version.@@ -110,15 +110,17 @@ Export the schema-enabled component directly, without a forwarding wrapper. SeeCheck in Studio that the exported instance appears as one layer and can be moved and trimmed. Do not use `component-owned-sequence` only to remove markup. Do not add padding only for the gallery preview.-##### Initial props+### Initial props-[`Interactive.withSchema()`](/docs/interactive-with-schema) makes a component's props editable in Studio. Content declared inside the component is not a prop, so users cannot edit it per instance.+If the Element needs starter props, put them in `initial-props.ts`, type them with `satisfies ComponentProps<typeof YourComponent>`, and register them as [`initialProps`](/docs/studio-protocol/create-element-payload#initialprops) in `element-definitions.ts`. For `component-owned-sequence`, this can provide defaults for Inspector controls. Otherwise, users can edit the installed source directly.-For a `component-owned-sequence` Element with replaceable starter content, put those values in `initial-props.ts`. Register them as `initialProps` with the component in `element-definitions.ts`, and type them with `satisfies ComponentProps<typeof YourComponent>`.+### Include assets-Pass these props to the previews too. Studio writes them onto the installed component, and Inspector edits them there. Keep rendering and animation in the copied Element file.+Follow the [asset integration guidance](/docs/studio-protocol/component-library-integration#preview-installed-assets). Installed assets are separate from the PNG and MP4 gallery previews in [Prepare previews](#2-prepare-previews).-Studio supplies `from`, `durationInFrames`, and `name`. Pass `width` and `height` in `initialProps` when the component needs them. Element dimension metadata is not passed as component props.+In `element-definitions.ts`, declare `assets` and put [`staticFileRef()`](/docs/studio-protocol/static-file-ref) references in `installationProps`. Keep preview URLs in `initialProps`.++`installationProps` shallowly overrides `initialProps` only for installation; an overridden object or array replaces that entire prop. For Elements without installed assets, use `assets: []` and `installationProps: null`.### Animate temporary Elements in and out