Skip to content

πŸŽ₯ Make videos programmatically with React

Remove code examples and overhaul UI

ASchwad96fcea92dbc2
diff --git a/bun.lock b/bun.lock
index 0e69f466c9..792414223c 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1409,7 +1409,7 @@
},
"packages/template-code-generation": {
"name": "template-code-generation",
- "version": "0.1.0",
+ "version": "4.0.379",
"dependencies": {
"@ai-sdk/openai": "^2.0.74",
"@ai-sdk/react": "^2.0.104",
@@ -1417,6 +1417,7 @@
"@monaco-editor/react": "^4.7.0",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-select": "^2.2.6",
+ "@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tooltip": "^1.2.8",
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
@@ -9159,6 +9160,8 @@
"template-code-generation/@radix-ui/react-select": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/number": "1.1.1", "@radix-ui/primitive": "1.1.3", "@radix-ui/react-collection": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-direction": "1.1.1", "@radix-ui/react-dismissable-layer": "1.1.11", "@radix-ui/react-focus-guards": "1.1.3", "@radix-ui/react-focus-scope": "1.1.7", "@radix-ui/react-id": "1.1.1", "@radix-ui/react-popper": "1.2.8", "@radix-ui/react-portal": "1.1.9", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-slot": "1.2.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-controllable-state": "1.2.2", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-previous": "1.1.1", "@radix-ui/react-visually-hidden": "1.2.3", "aria-hidden": "^1.2.4", "react-remove-scroll": "^2.6.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ=="],
+ "template-code-generation/@radix-ui/react-slot": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Jl+bCv8HxKnlTLVrcDE8zTMJ09R9/ukw4qBs/oZClOfoQk/cOTbDn+NceXfV7j09YPVQUryJPHurafcSg6EVKA=="],
+
"template-code-generation/@typescript-eslint/eslint-plugin": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/type-utils": "8.46.0", "@typescript-eslint/utils": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.46.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA=="],
"template-code-generation/@typescript-eslint/parser": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-n1H6IcDhmmUEG7TNVSspGmiHHutt7iVKtZwRppD7e04wha5MrkV1h3pti9xQLcCMt6YWsncpoT0HMjkH1FNwWQ=="],
@@ -11101,6 +11104,8 @@
"template-code-generation/@radix-ui/react-dialog/@radix-ui/react-primitive": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ=="],
+ "template-code-generation/@radix-ui/react-dialog/@radix-ui/react-slot": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
+
"template-code-generation/@radix-ui/react-dialog/@radix-ui/react-use-controllable-state": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-use-effect-event": "0.0.2", "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg=="],
"template-code-generation/@radix-ui/react-select/@radix-ui/number": ["@radix-ui/[email protected]", "", {}, "sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g=="],
@@ -11123,6 +11128,8 @@
"template-code-generation/@radix-ui/react-select/@radix-ui/react-primitive": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ=="],
+ "template-code-generation/@radix-ui/react-select/@radix-ui/react-slot": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
+
"template-code-generation/@radix-ui/react-select/@radix-ui/react-use-callback-ref": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg=="],
"template-code-generation/@radix-ui/react-select/@radix-ui/react-use-controllable-state": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-use-effect-event": "0.0.2", "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg=="],
@@ -11133,6 +11140,8 @@
"template-code-generation/@radix-ui/react-select/@radix-ui/react-visually-hidden": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.3" }, "peerDependencies": { "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "react": "19.0.0", "react-dom": "19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-pzJq12tEaaIhqjbzpCuv/OypJY/BPavOofm+dbab+MHLajy277+1lLm6JFcGgF5eskJ6mquGirhXY2GD/8u8Ug=="],
+ "template-code-generation/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],
+
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0" } }, "sha512-lWETPa9XGcBes4jqAMYD9fW0j4n6hrPtTJwWDmtqgFO/4HF4jmdH/Q6wggTw5qIT5TXjKzbt7GsZUBnWoO3dqw=="],
"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hy+lvYV1lZpVs2jRaEYvgCblZxUoJiPyCemwbQZ+NGulWkQRy0HRPYAoef/CNSzaLt+MLvMptZsHXHlkEilaeg=="],
diff --git a/packages/template-code-generation/package.json b/packages/template-code-generation/package.json
index 44e61af17a..5b22bc4484 100644
--- a/packages/template-code-generation/package.json
+++ b/packages/template-code-generation/package.json
@@ -22,6 +22,7 @@
"@monaco-editor/react": "^4.7.0",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-select": "^2.2.6",
+ "@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tooltip": "^1.2.8",
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
diff --git a/packages/template-code-generation/public/logo.png b/packages/template-code-generation/public/logo.png
new file mode 100644
index 0000000000..a35f38446a
Binary files /dev/null and b/packages/template-code-generation/public/logo.png differ
diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsx
index e634e566bb..d62b07ab13 100644
--- a/packages/template-code-generation/src/app/page.tsx
+++ b/packages/template-code-generation/src/app/page.tsx
@@ -2,22 +2,19 @@
import { useState, useCallback, useEffect, useRef } from "react";
import type { NextPage } from "next";
-import { ExampleSelector } from "../components/ExampleSelector";
+import Image from "next/image";
import { CodeEditor } from "../components/CodeEditor";
import { AnimationPlayer } from "../components/AnimationPlayer";
import { PromptInput } from "../components/PromptInput";
import { SettingsModal } from "../components/SettingsModal";
-import { examples, RemotionExample } from "../templates";
+import { examples } from "../templates";
import { useAnimationState } from "../hooks/useAnimationState";
const Home: NextPage = () => {
- const [selectedExample, setSelectedExample] =
- useState<RemotionExample | null>(examples[0] || null);
const [durationInFrames, setDurationInFrames] = useState(
examples[0]?.durationInFrames || 150,
);
const [fps, setFps] = useState(examples[0]?.fps || 30);
- const [isEditorOpen, setIsEditorOpen] = useState(true);
const [isStreaming, setIsStreaming] = useState(false);
const { code, Component, error, isCompiling, setCode, compileCode } =
@@ -65,22 +62,6 @@ const Home: NextPage = () => {
[setCode, compileCode],
);
- const handleExampleSelect = useCallback(
- (example: RemotionExample) => {
- setSelectedExample(example);
- setCode(example.code);
- setDurationInFrames(example.durationInFrames);
- setFps(example.fps);
-
- // Immediately compile the example code
- if (debounceRef.current) {
- clearTimeout(debounceRef.current);
- }
- compileCode(example.code);
- },
- [setCode, compileCode],
- );
-
// Cleanup debounce on unmount
useEffect(() => {
return () => {
@@ -92,33 +73,28 @@ const Home: NextPage = () => {
return (
<div className="flex h-screen w-screen overflow-hidden bg-[#0a0a0a]">
- <ExampleSelector
- selectedExampleId={selectedExample?.id || null}
- onSelectExample={handleExampleSelect}
- />
-
- <div className="flex-1 flex flex-col min-w-0">
- <div className="flex justify-between items-center px-6 py-3 bg-[#0f0f0f] border-b border-[#2a2a2a]">
- <div className="text-xl font-bold text-white font-sans">
- Remotion Playground
- </div>
- <div className="flex items-center gap-2">
- <SettingsModal
- durationInFrames={durationInFrames}
- onDurationChange={setDurationInFrames}
- fps={fps}
- onFpsChange={setFps}
- />
- <button
- className="px-4 py-2 rounded border-none bg-indigo-500 text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-indigo-600"
- onClick={() => setIsEditorOpen(!isEditorOpen)}
- >
- {isEditorOpen ? "Hide Editor" : "Show Editor"}
- </button>
+ <div className="flex-1 flex flex-col min-w-0 py-8 px-12 rounded-md gap-8">
+ <div className="flex justify-between items-center">
+ <div className="flex items-center gap-3">
+ <Image src="/logo.png" alt="Remotion" width={32} height={32} />
+ <span className="text-xl font-bold text-white font-sans">
+ Remotion Code Generation
+ </span>
</div>
+ <SettingsModal
+ durationInFrames={durationInFrames}
+ onDurationChange={setDurationInFrames}
+ fps={fps}
+ onFpsChange={setFps}
+ />
</div>
- <div className="flex-1 flex overflow-hidden">
+ <div className="flex-1 flex overflow-hidden gap-8">
+ <CodeEditor
+ code={code}
+ onChange={handleCodeChange}
+ isStreaming={isStreaming}
+ />
<AnimationPlayer
Component={Component}
durationInFrames={durationInFrames}
@@ -126,14 +102,6 @@ const Home: NextPage = () => {
isCompiling={isCompiling}
error={error}
/>
-
- {isEditorOpen && (
- <CodeEditor
- code={code}
- onChange={handleCodeChange}
- isStreaming={isStreaming}
- />
- )}
</div>
<PromptInput
diff --git a/packages/template-code-generation/src/components/AnimationPlayer.tsx b/packages/template-code-generation/src/components/AnimationPlayer.tsx
index a4173a33af..4cebf93fd7 100644
--- a/packages/template-code-generation/src/components/AnimationPlayer.tsx
+++ b/packages/template-code-generation/src/components/AnimationPlayer.tsx
@@ -35,9 +35,12 @@ export const AnimationPlayer: React.FC<AnimationPlayerProps> = ({
}) => {
if (isCompiling) {
return (
- <div className="flex-1 flex flex-col justify-center items-center p-6 bg-[#0a0a0a] min-w-0">
- <div className="w-full max-w-[800px] aspect-video flex justify-center items-center bg-[#1a1a1a] rounded-lg">
- <div className="w-12 h-12 border-4 border-[#333] border-t-[#6366f1] rounded-full animate-spin" />
+ <div className="flex flex-3 flex-col items-center bg-[#0a0a0a] min-w-0">
+ <div className="w-full max-w-[1200px]">
+ <h2 className="text-sm font-medium text-[#888] mb-3">Video Preview</h2>
+ <div className="w-full aspect-video flex justify-center items-center bg-[#1a1a1a] rounded-lg overflow-hidden shadow-[0_0_60px_rgba(0,0,0,0.5)]">
+ <div className="w-12 h-12 border-4 border-[#333] border-t-[#6366f1] rounded-full animate-spin" />
+ </div>
</div>
</div>
);
@@ -45,13 +48,18 @@ export const AnimationPlayer: React.FC<AnimationPlayerProps> = ({
if (error) {
return (
- <div className="flex-1 flex flex-col justify-center items-center p-6 bg-[#0a0a0a] min-w-0">
- <div className="w-full max-w-[800px] p-6 bg-[#2a1a1a] rounded-lg border border-[#dc2626]">
- <div className="text-[#dc2626] text-base font-semibold mb-2 font-sans">
- Compilation Error
- </div>
- <div className="text-[#f87171] text-sm font-mono whitespace-pre-wrap break-words">
- {error}
+ <div className="flex flex-3 flex-col items-center bg-[#0a0a0a] min-w-0">
+ <div className="w-full max-w-[1200px]">
+ <h2 className="text-sm font-medium text-[#888] mb-3">Video Preview</h2>
+ <div className="w-full aspect-video flex justify-center items-center bg-[#2a1a1a] rounded-lg overflow-hidden shadow-[0_0_60px_rgba(0,0,0,0.5)] border border-[#dc2626]">
+ <div className="text-center max-w-[80%]">
+ <div className="text-[#dc2626] text-base font-semibold mb-2 font-sans">
+ Compilation Error
+ </div>
+ <div className="text-[#f87171] text-sm font-mono whitespace-pre-wrap break-words">
+ {error}
+ </div>
+ </div>
</div>
</div>
</div>
@@ -60,35 +68,41 @@ export const AnimationPlayer: React.FC<AnimationPlayerProps> = ({
if (!Component) {
return (
- <div className="flex-1 flex flex-col justify-center items-center p-6 bg-[#0a0a0a] min-w-0">
- <div className="w-full max-w-[800px] aspect-video flex justify-center items-center bg-[#1a1a1a] rounded-lg text-[#666] text-lg font-sans">
- Select an example to get started
+ <div className="flex flex-3 flex-col items-center bg-[#0a0a0a] min-w-0">
+ <div className="w-full max-w-[1200px]">
+ <h2 className="text-sm font-medium text-[#888] mb-3">Video Preview</h2>
+ <div className="w-full aspect-video flex justify-center items-center bg-[#1a1a1a] rounded-lg overflow-hidden shadow-[0_0_60px_rgba(0,0,0,0.5)] text-[#666] text-lg font-sans">
+ Select an example to get started
+ </div>
</div>
</div>
);
}
return (
- <div className="flex-1 flex flex-col justify-center items-center p-6 bg-[#0a0a0a] min-w-0">
- <div className="w-full max-w-[800px] aspect-video rounded-lg overflow-hidden shadow-[0_0_60px_rgba(0,0,0,0.5)]">
- <Player
- key={Component.toString()}
- component={Component}
- durationInFrames={durationInFrames}
- fps={fps}
- compositionHeight={1080}
- compositionWidth={1920}
- style={{
- width: "100%",
- height: "100%",
- }}
- controls
- autoPlay
- loop
- errorFallback={renderErrorFallback}
- spaceKeyToPlayOrPause={false}
- clickToPlay={false}
- />
+ <div className="flex flex-3 flex-col items-center bg-[#0a0a0a] min-w-0">
+ <div className="w-full max-w-[1200px]">
+ <h2 className="text-sm font-medium text-[#888] mb-3">Video Preview</h2>
+ <div className="w-full aspect-video rounded-lg overflow-hidden shadow-[0_0_60px_rgba(0,0,0,0.5)]">
+ <Player
+ key={Component.toString()}
+ component={Component}
+ durationInFrames={durationInFrames}
+ fps={fps}
+ compositionHeight={1080}
+ compositionWidth={1920}
+ style={{
+ width: "100%",
+ height: "100%",
+ }}
+ controls
+ autoPlay
+ loop
+ errorFallback={renderErrorFallback}
+ spaceKeyToPlayOrPause={false}
+ clickToPlay={false}
+ />
+ </div>
</div>
</div>
);
diff --git a/packages/template-code-generation/src/components/Button.tsx b/packages/template-code-generation/src/components/Button.tsx
deleted file mode 100644
index bbd1ec1f8e..0000000000
--- a/packages/template-code-generation/src/components/Button.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import React, { forwardRef } from "react";
-import { Spinner } from "./ui/spinner";
-import { cn } from "../lib/utils";
-
-const ButtonForward: React.ForwardRefRenderFunction<
- HTMLButtonElement,
- {
- onClick?: () => void;
- disabled?: boolean;
- children: React.ReactNode;
- loading?: boolean;
- secondary?: boolean;
- }
-> = ({ onClick, disabled, children, loading, secondary }, ref) => {
- return (
- <button
- ref={ref}
- className={cn(
- "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
- secondary
- ? "bg-background text-foreground border-unfocused-border-color"
- : undefined,
- )}
- onClick={onClick}
- disabled={disabled}
- >
- {loading && <Spinner className="mr-geist-quarter size-5" />}
- {children}
- </button>
- );
-};
-
-export const Button = forwardRef(ButtonForward);
diff --git a/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx b/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx
index 66d28c0a5e..2acd4d59ac 100644
--- a/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx
+++ b/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx
@@ -101,7 +101,6 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
options: {
isWholeLine: true,
className: "readonly-line",
- glyphMarginClassName: "readonly-glyph",
},
});
}
@@ -114,7 +113,6 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
options: {
isWholeLine: true,
className: "readonly-line",
- glyphMarginClassName: "readonly-glyph",
},
});
}
@@ -283,8 +281,10 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
};
return (
- <div className="w-[600px] h-full flex flex-col bg-[#1e1e1e] border-l border-[#2a2a2a]">
- <EditorHeader filename="MyAnimation.tsx" code={displayCode} />
+ <div className="flex-2 h-full flex flex-col">
+ <h2 className="text-sm font-medium text-[#888] mb-3">Remotion Code</h2>
+ <div className="flex-1 flex flex-col bg-[#1e1e1e] rounded-lg overflow-hidden">
+ <EditorHeader filename="MyAnimation.tsx" code={displayCode} />
<style>{EDITOR_STYLES}</style>
<div className="flex-1 overflow-hidden relative">
<StreamingOverlay visible={isStreaming} />
@@ -305,10 +305,13 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
tabSize: 2,
wordWrap: "on",
padding: { top: 16 },
- glyphMargin: true,
+ glyphMargin: false,
+ lineNumbersMinChars: 3,
+ folding: false,
}}
/>
</div>
+ </div>
</div>
);
};
diff --git a/packages/template-code-generation/src/components/DownloadButton.tsx b/packages/template-code-generation/src/components/DownloadButton.tsx
index d759719cc2..786623a2d0 100644
--- a/packages/template-code-generation/src/components/DownloadButton.tsx
+++ b/packages/template-code-generation/src/components/DownloadButton.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { State } from "../helpers/use-rendering";
-import { Button } from "./Button";
+import { Button } from "@/components/ui/button";
const Megabytes: React.FC<{
sizeInBytes: number;
@@ -28,7 +28,7 @@ export const DownloadButton: React.FC<{
return (
<div className="flex gap-geist-quarter">
- <Button secondary onClick={undo}>
+ <Button variant="secondary" onClick={undo}>
<UndoIcon></UndoIcon>
</Button>
<a href={state.url}>
diff --git a/packages/template-code-generation/src/components/ExampleSelector.tsx b/packages/template-code-generation/src/components/ExampleSelector.tsx
deleted file mode 100644
index 5746a2c590..0000000000
--- a/packages/template-code-generation/src/components/ExampleSelector.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-"use client";
-
-import React, { useState } from "react";
-import { examples, RemotionExample } from "../templates";
-
-interface ExampleSelectorProps {
- selectedExampleId: string | null;
- onSelectExample: (example: RemotionExample) => void;
-}
-
-const getCategoryColor = (category: RemotionExample["category"]) => {
- switch (category) {
- case "Text":
- return { bg: "bg-blue-800", text: "text-blue-300" };
- case "Charts":
- return { bg: "bg-emerald-800", text: "text-emerald-300" };
- case "Other":
- return { bg: "bg-violet-800", text: "text-violet-300" };
- }
-};
-
-export const ExampleSelector: React.FC<ExampleSelectorProps> = ({
- selectedExampleId,
- onSelectExample,
-}) => {
- const [hoveredId, setHoveredId] = useState<string | null>(null);
-
- return (
- <div className="w-80 h-full bg-[#0f0f0f] border-r border-[#2a2a2a] overflow-y-auto p-4">
- <h2 className="text-lg font-bold text-white mb-4 font-sans">Examples</h2>
- {examples.map((example) => {
- const isSelected = selectedExampleId === example.id;
- const isHovered = hoveredId === example.id;
- const colors = getCategoryColor(example.category);
-
- return (
- <div
- key={example.id}
- className={`
- rounded-lg p-4 mb-3 cursor-pointer transition-all duration-200
- ${
- isSelected
- ? "border border-indigo-500 bg-[#1e1e2e]"
- : isHovered
- ? "border border-[#444] bg-[#1a1a1a]"
- : "border border-transparent bg-[#1a1a1a]"
- }
- `}
- onClick={() => onSelectExample(example)}
- onMouseEnter={() => setHoveredId(example.id)}
- onMouseLeave={() => setHoveredId(null)}
- >
- <div className="text-base font-semibold text-white mb-1 font-sans">
- {example.name}
- </div>
- <div className="text-sm text-[#888] mb-2 font-sans">
- {example.description}
- </div>
- <span
- className={`inline-block text-xs px-2 py-0.5 rounded font-sans ${colors.bg} ${colors.text}`}
- >
- {example.category}
- </span>
- </div>
- );
- })}
- </div>
- );
-};
diff --git a/packages/template-code-generation/src/components/PromptInput.tsx b/packages/template-code-generation/src/components/PromptInput.tsx
index bd0968e2d1..585f1a3695 100644
--- a/packages/template-code-generation/src/components/PromptInput.tsx
+++ b/packages/template-code-generation/src/components/PromptInput.tsx
@@ -30,7 +30,10 @@ interface PromptInputProps {
onStreamingChange?: (isStreaming: boolean) => void;
}
-export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputProps) {
+export function PromptInput({
+ onCodeGenerated,
+ onStreamingChange,
+}: PromptInputProps) {
const { apiKey, hasApiKey, isLoaded } = useApiKeyContext();
const [prompt, setPrompt] = useState("");
const [model, setModel] = useState<ModelId>("gpt-5-mini");
@@ -94,14 +97,19 @@ export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputP
};
return (
- <form onSubmit={handleSubmit} className="flex gap-2 p-4 bg-[#1a1a1a] border-t border-[#2a2a2a]">
+ <div className="flex flex-col gap-2">
+ <h2 className="text-sm font-medium text-[#888]">Prompt</h2>
+ <form
+ onSubmit={handleSubmit}
+ className="flex gap-2 p-4 bg-[#1a1a1a] rounded-md"
+ >
<textarea
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Describe your animation... (e.g., 'A bouncing ball')"
rows={3}
- className="flex-1 px-4 py-2 rounded border border-[#333] bg-[#0f0f0f] text-white text-sm font-sans placeholder:text-[#666] focus:outline-none focus:border-indigo-500 resize-none min-h-[4.5rem] max-h-[9rem]"
+ className="flex-1 px-4 py-2 rounded-lg border border-[#333] bg-[#0f0f0f] text-white text-sm font-sans placeholder:text-[#666] focus:outline-none focus:border-[#555] resize-none min-h-[4.5rem] max-h-[9rem]"
disabled={isLoading}
/>
<div className="flex flex-col gap-2">
@@ -110,7 +118,7 @@ export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputP
onValueChange={(value) => setModel(value as ModelId)}
disabled={isLoading}
>
- <SelectTrigger className="w-[140px] bg-[#0f0f0f] border-[#333] text-white">
+ <SelectTrigger className="w-[160px] bg-[#0f0f0f] border-[#333] text-white">
<SelectValue />
</SelectTrigger>
<SelectContent className="bg-[#1a1a1a] border-[#333]">
@@ -140,9 +148,13 @@ export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputP
<>
<span>Generate</span>
<span className="flex items-center gap-0.5 text-[10px] text-indigo-200/70">
- <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">⌘</kbd>
+ <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">
+ ⌘
+ </kbd>
<span>+</span>
- <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">Enter</kbd>
+ <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">
+ Enter
+ </kbd>
</span>
</>
)}
@@ -157,6 +169,7 @@ export function PromptInput({ onCodeGenerated, onStreamingChange }: PromptInputP
</Tooltip>
</TooltipProvider>
</div>
- </form>
+ </form>
+ </div>
);
}
diff --git a/packages/template-code-generation/src/components/RenderControls.tsx b/packages/template-code-generation/src/components/RenderControls.tsx
index f1154534b3..abdd636afe 100644
--- a/packages/template-code-generation/src/components/RenderControls.tsx
+++ b/packages/template-code-generation/src/components/RenderControls.tsx
@@ -1,5 +1,5 @@
import { z } from "zod";
-import { Button } from "./Button";
+import { Button } from "@/components/ui/button";
import { InputContainer } from "./Container";
import { DownloadButton } from "./DownloadButton";
import { ErrorComp } from "./Error";
diff --git a/packages/template-code-generation/src/components/SettingsModal.tsx b/packages/template-code-generation/src/components/SettingsModal.tsx
index 6ae13b9c96..0b52f60c53 100644
--- a/packages/template-code-generation/src/components/SettingsModal.tsx
+++ b/packages/template-code-generation/src/components/SettingsModal.tsx
@@ -12,6 +12,7 @@ import {
} from "@/components/ui/dialog";
import { Settings, Eye, EyeOff, ExternalLink } from "lucide-react";
import { useApiKeyContext } from "@/context/ApiKeyContext";
+import { Button } from "@/components/ui/button";
interface SettingsModalProps {
durationInFrames: number;
@@ -54,12 +55,10 @@ export function SettingsModal({
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
- <button
- className="px-3 py-2 rounded border-none bg-[#1a1a1a] text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-[#2a2a2a] flex items-center gap-2 border border-[#333]"
- aria-label="Settings"
- >
+ <Button variant="outline">
<Settings className="w-4 h-4" />
- </button>
+ Settings
+ </Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px] bg-[#1a1a1a] border-[#333] text-white">
<DialogHeader>
@@ -100,7 +99,7 @@ export function SettingsModal({
value={fps}
onChange={(e) =>
onFpsChange(
- Math.max(1, Math.min(60, parseInt(e.target.value) || 30))
+ Math.max(1, Math.min(60, parseInt(e.target.value) || 30)),
)
}
className="w-full px-3 py-2 rounded border border-[#333] bg-[#0f0f0f] text-white text-sm font-sans focus:outline-none focus:border-indigo-500"
@@ -108,7 +107,8 @@ export function SettingsModal({
</div>
</div>
<p className="text-xs text-[#666]">
- Video length: {(durationInFrames / fps).toFixed(2)}s ({durationInFrames} frames / {fps} FPS)
+ Video length: {(durationInFrames / fps).toFixed(2)}s (
+ {durationInFrames} frames / {fps} FPS)
</p>
</div>
@@ -144,7 +144,8 @@ export function SettingsModal({
</p>
)}
<p className="text-xs text-[#666]">
- Your API key is stored locally in your browser and only sent to OpenAI for generation requests.
+ Your API key is stored locally in your browser and only sent to
+ OpenAI for generation requests.
</p>
<a
href="https://platform.openai.com/api-keys"
@@ -159,27 +160,24 @@ export function SettingsModal({
</div>
<DialogFooter className="flex gap-2 sm:justify-between">
{hasApiKey && (
- <button
+ <Button
onClick={handleClear}
- className="px-4 py-2 rounded border-none bg-red-600 text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-red-700 mr-auto"
+ variant="destructive"
+ className="mr-auto"
>
Clear Key
- </button>
+ </Button>
)}
<div className="flex gap-2">
- <button
- onClick={() => setOpen(false)}
- className="px-4 py-2 rounded border border-[#333] bg-transparent text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-[#2a2a2a]"
- >
+ <Button variant="outline" onClick={() => setOpen(false)}>
Cancel
- </button>
- <button
+ </Button>
+ <Button
onClick={handleSave}
disabled={!inputValue.trim() || !isValidFormat}
- className="px-4 py-2 rounded border-none bg-indigo-500 text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-indigo-600 disabled:opacity-50 disabled:cursor-not-allowed"
>
Save
- </button>
+ </Button>
</div>
</DialogFooter>
</DialogContent>
diff --git a/packages/template-code-generation/src/components/ui/button.tsx b/packages/template-code-generation/src/components/ui/button.tsx
new file mode 100644
index 0000000000..9f8975b07d
--- /dev/null
+++ b/packages/template-code-generation/src/components/ui/button.tsx
@@ -0,0 +1,65 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+import { Spinner } from "./spinner"
+
+const buttonVariants = cva(
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
+ {
+ variants: {
+ variant: {
+ default: "bg-indigo-500 text-white hover:bg-indigo-600",
+ destructive: "bg-red-600 text-white hover:bg-red-700",
+ outline:
+ "border border-[#333] bg-transparent text-white hover:bg-[#2a2a2a]",
+ secondary: "bg-[#333] text-white hover:bg-[#444]",
+ ghost: "text-white hover:bg-[#2a2a2a]",
+ link: "text-indigo-400 underline-offset-4 hover:underline",
+ },
+ size: {
+ default: "h-10 px-4 py-2",
+ sm: "h-8 rounded-md gap-1.5 px-3",
+ lg: "h-11 rounded-md px-6",
+ icon: "size-10",
+ "icon-sm": "size-8",
+ "icon-lg": "size-11",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ }
+)
+
+function Button({
+ className,
+ variant,
+ size,
+ asChild = false,
+ loading = false,
+ children,
+ ...props
+}: React.ComponentProps<"button"> &
+ VariantProps<typeof buttonVariants> & {
+ asChild?: boolean
+ loading?: boolean
+ }) {
+ const Comp = asChild ? Slot : "button"
+
+ return (
+ <Comp
+ data-slot="button"
+ className={cn(buttonVariants({ variant, size, className }))}
+ disabled={loading || props.disabled}
+ {...props}
+ >
+ {loading && <Spinner className="size-4" />}
+ {children}
+ </Comp>
+ )
+}
+
+export { Button, buttonVariants }