🎥 Make videos programmatically with React
Add separate pages for Landing and Editor
ASchwada9ab339c3453
diff --git a/packages/template-code-generation/src/app/generate/page.tsx b/packages/template-code-generation/src/app/generate/page.tsxnew file mode 100644index 0000000000..f795cd35d7--- /dev/null+++ b/packages/template-code-generation/src/app/generate/page.tsx@@ -0,0 +1,169 @@+"use client";++import { useState, useCallback, useEffect, useRef, Suspense } from "react";+import type { NextPage } from "next";+import { useSearchParams } from "next/navigation";+import { Loader2 } from "lucide-react";+import { CodeEditor } from "../../components/CodeEditor";+import { AnimationPlayer } from "../../components/AnimationPlayer";+import { PageLayout } from "../../components/PageLayout";+import {+ PromptInput,+ type StreamPhase,+ type PromptInputRef,+} from "../../components/PromptInput";+import { SettingsModal } from "../../components/SettingsModal";+import { examples } from "../../templates";+import { useAnimationState } from "../../hooks/useAnimationState";++function GeneratePageContent() {+ const searchParams = useSearchParams();+ const initialPrompt = searchParams.get("prompt") || "";++ // If we have an initial prompt from URL, start in streaming state+ // so syntax highlighting is disabled from the beginning+ const willAutoStart = Boolean(initialPrompt);++ const [durationInFrames, setDurationInFrames] = useState(+ examples[0]?.durationInFrames || 150,+ );+ const [fps, setFps] = useState(examples[0]?.fps || 30);+ const [isStreaming, setIsStreaming] = useState(willAutoStart);+ const [streamPhase, setStreamPhase] = useState<StreamPhase>(+ willAutoStart ? "reasoning" : "idle",+ );+ const [prompt, setPrompt] = useState(initialPrompt);+ const [hasAutoStarted, setHasAutoStarted] = useState(false);+ const [hasGeneratedOnce, setHasGeneratedOnce] = useState(false);++ const { code, Component, error, isCompiling, setCode, compileCode } =+ useAnimationState(examples[0]?.code || "");++ // Debounce compilation+ const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);++ const isStreamingRef = useRef(isStreaming);+ const codeRef = useRef(code);++ useEffect(() => {+ codeRef.current = code;+ }, [code]);++ useEffect(() => {+ const wasStreaming = isStreamingRef.current;+ isStreamingRef.current = isStreaming;++ // Compile when streaming ends+ if (wasStreaming && !isStreaming) {+ compileCode(codeRef.current);+ }+ }, [isStreaming, compileCode]);++ const handleCodeChange = useCallback(+ (newCode: string) => {+ setCode(newCode);+ setHasGeneratedOnce(true);++ // Clear existing debounce+ if (debounceRef.current) {+ clearTimeout(debounceRef.current);+ }++ // Skip compilation while streaming - will compile when streaming ends+ if (isStreamingRef.current) {+ return;+ }++ // Set new debounce+ debounceRef.current = setTimeout(() => {+ compileCode(newCode);+ }, 500);+ },+ [setCode, compileCode],+ );++ // Cleanup debounce on unmount+ useEffect(() => {+ return () => {+ if (debounceRef.current) {+ clearTimeout(debounceRef.current);+ }+ };+ }, []);++ const handleStreamingChange = useCallback((streaming: boolean) => {+ setIsStreaming(streaming);+ }, []);++ // Auto-trigger generation if prompt came from URL+ const promptInputRef = useRef<PromptInputRef>(null);++ useEffect(() => {+ if (initialPrompt && !hasAutoStarted && promptInputRef.current) {+ setHasAutoStarted(true);+ // Small delay to ensure component is mounted+ setTimeout(() => {+ promptInputRef.current?.triggerGeneration();+ }, 100);+ }+ }, [initialPrompt, hasAutoStarted]);++ return (+ <PageLayout+ showLogoAsLink+ rightContent={+ <SettingsModal+ durationInFrames={durationInFrames}+ onDurationChange={setDurationInFrames}+ fps={fps}+ onFpsChange={setFps}+ />+ }+ >+ <div className="flex-1 flex flex-col min-w-0 px-12 pb-8 gap-8 overflow-hidden">+ <div className="flex-1 flex overflow-hidden gap-8">+ <CodeEditor+ code={hasGeneratedOnce ? code : ""}+ onChange={handleCodeChange}+ isStreaming={isStreaming}+ streamPhase={streamPhase}+ />+ <AnimationPlayer+ Component={Component}+ durationInFrames={durationInFrames}+ fps={fps}+ isCompiling={isCompiling}+ error={error}+ />+ </div>++ <PromptInput+ ref={promptInputRef}+ onCodeGenerated={handleCodeChange}+ onStreamingChange={handleStreamingChange}+ onStreamPhaseChange={setStreamPhase}+ prompt={prompt}+ onPromptChange={setPrompt}+ />+ </div>+ </PageLayout>+ );+}++function LoadingFallback() {+ return (+ <div className="flex h-screen w-screen items-center justify-center bg-[#0a0a0a]">+ <Loader2 className="w-8 h-8 animate-spin text-white" />+ </div>+ );+}++const GeneratePage: NextPage = () => {+ return (+ <Suspense fallback={<LoadingFallback />}>+ <GeneratePageContent />+ </Suspense>+ );+};++export default GeneratePage;diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsxindex e45bf5bfeb..d86c0a74b1 100644--- a/packages/template-code-generation/src/app/page.tsx+++ b/packages/template-code-generation/src/app/page.tsx@@ -1,155 +1,138 @@"use client";-import { useState, useCallback, useEffect, useRef } from "react";+import { useState } from "react";import type { NextPage } from "next";-import Image from "next/image";-import { CodeEditor } from "../components/CodeEditor";-import { AnimationPlayer } from "../components/AnimationPlayer";-import { PromptInput, type StreamPhase } from "../components/PromptInput";-import { SettingsModal } from "../components/SettingsModal";-import { examples } from "../templates";-import { useAnimationState } from "../hooks/useAnimationState";+import { useRouter } from "next/navigation";+import {+ ArrowUp,+ Loader2,+ Type,+ MessageCircle,+ Hash,+ BarChart3,+ Disc,+ type LucideIcon,+} from "lucide-react";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { examplePrompts } from "@/data/examplePrompts";+import { MODELS, type ModelId } from "@/components/PromptInput";+import { PageLayout } from "@/components/PageLayout";++const iconMap: Record<string, LucideIcon> = {+ Type,+ MessageCircle,+ Hash,+ BarChart3,+ Disc,+};const Home: NextPage = () => {- const [durationInFrames, setDurationInFrames] = useState(- examples[0]?.durationInFrames || 150,- );- const [fps, setFps] = useState(examples[0]?.fps || 30);- const [isStreaming, setIsStreaming] = useState(false);- const [streamPhase, setStreamPhase] = useState<StreamPhase>("idle");- const [hasStartedGeneration, setHasStartedGeneration] = useState(false);+ const router = useRouter();const [prompt, setPrompt] = useState("");-- const { code, Component, error, isCompiling, setCode, compileCode } =- useAnimationState(examples[0]?.code || "");-- // Debounce compilation- const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);-- const isStreamingRef = useRef(isStreaming);- const codeRef = useRef(code);-- useEffect(() => {- codeRef.current = code;- }, [code]);-- useEffect(() => {- const wasStreaming = isStreamingRef.current;- isStreamingRef.current = isStreaming;-- // Compile when streaming ends- if (wasStreaming && !isStreaming) {- compileCode(codeRef.current);+ const [model, setModel] = useState<ModelId>("gpt-5.1:low");+ const [isNavigating, setIsNavigating] = useState(false);++ const handleSubmit = (e: React.FormEvent) => {+ e.preventDefault();+ if (!prompt.trim()) return;++ setIsNavigating(true);+ const params = new URLSearchParams({ prompt, model });+ router.push(`/generate?${params.toString()}`);+ };++ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {+ e.preventDefault();+ handleSubmit(e);}- }, [isStreaming, compileCode]);-- const handleCodeChange = useCallback(- (newCode: string) => {- setCode(newCode);-- // Clear existing debounce- if (debounceRef.current) {- clearTimeout(debounceRef.current);- }-- // Skip compilation while streaming - will compile when streaming ends- if (isStreamingRef.current) {- return;- }-- // Set new debounce- debounceRef.current = setTimeout(() => {- compileCode(newCode);- }, 500);- },- [setCode, compileCode],- );-- // Cleanup debounce on unmount- useEffect(() => {- return () => {- if (debounceRef.current) {- clearTimeout(debounceRef.current);- }- };- }, []);-- const handleStreamingChange = useCallback(- (streaming: boolean) => {- setIsStreaming(streaming);- if (streaming && !hasStartedGeneration) {- setHasStartedGeneration(true);- }- },- [hasStartedGeneration],- );-- if (!hasStartedGeneration) {- return (- <div className="h-screen w-screen bg-[#0a0a0a] flex flex-col">- <div className="flex items-center py-6 px-12">- <div className="flex items-center gap-3">- <Image src="/logo-white.svg" alt="Remotion" width={32} height={32} />- <span className="text-xl font-bold text-white font-sans">- Remotion Code Generation- </span>- </div>- </div>- <PromptInput- variant="landing"- onCodeGenerated={handleCodeChange}- onStreamingChange={handleStreamingChange}- onStreamPhaseChange={setStreamPhase}- prompt={prompt}- onPromptChange={setPrompt}- />- </div>- );- }+ };return (- <div className="flex h-screen w-screen overflow-hidden bg-[#0a0a0a]">- <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-white.svg" alt="Remotion" width={32} height={32} />- <span className="text-xl font-bold text-white font-sans">- Remotion Code Generation- </span>+ <PageLayout>+ <div className="flex flex-col items-center justify-center flex-1 px-4">+ <h1 className="text-5xl font-bold text-white mb-10 text-center">+ What do you want to create?+ </h1>++ <form onSubmit={handleSubmit} className="w-full max-w-3xl">+ <div className="bg-[#1a1a1a] rounded-xl border border-[#333] p-4">+ <textarea+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder="Describe your animation..."+ className="w-full bg-transparent text-white placeholder:text-[#666] focus:outline-none resize-none overflow-y-auto text-base min-h-[60px] max-h-[200px]"+ style={{ fieldSizing: "content" } as React.CSSProperties}+ disabled={isNavigating}+ />++ <div className="flex justify-between items-center mt-3 pt-3 border-t border-[#333]">+ <Select+ value={model}+ onValueChange={(value) => setModel(value as ModelId)}+ disabled={isNavigating}+ >+ <SelectTrigger className="w-auto bg-transparent border-none text-[#888] hover:text-white transition-colors">+ <SelectValue />+ </SelectTrigger>+ <SelectContent className="bg-[#1a1a1a] border-[#333]">+ {MODELS.map((m) => (+ <SelectItem+ key={m.id}+ value={m.id}+ className="text-white focus:bg-[#333] focus:text-white"+ >+ {m.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>++ <button+ type="submit"+ disabled={isNavigating || !prompt.trim()}+ className="p-2 rounded-lg bg-white text-black hover:bg-gray-200 disabled:opacity-30 disabled:cursor-not-allowed transition-all"+ >+ {isNavigating ? (+ <Loader2 className="w-5 h-5 animate-spin" />+ ) : (+ <ArrowUp className="w-5 h-5" />+ )}+ </button>+ </div></div>- <SettingsModal- durationInFrames={durationInFrames}- onDurationChange={setDurationInFrames}- fps={fps}- onFpsChange={setFps}- />- </div>- <div className="flex-1 flex overflow-hidden gap-8">- <CodeEditor- code={code}- onChange={handleCodeChange}- isStreaming={isStreaming}- streamPhase={streamPhase}- />- <AnimationPlayer- Component={Component}- durationInFrames={durationInFrames}- fps={fps}- isCompiling={isCompiling}- error={error}- />- </div>-- <PromptInput- onCodeGenerated={handleCodeChange}- onStreamingChange={handleStreamingChange}- onStreamPhaseChange={setStreamPhase}- prompt={prompt}- onPromptChange={setPrompt}- />+ <div className="flex flex-wrap items-center justify-center mt-6 gap-2">+ <span className="text-[#666] text-xs mr-1">Try</span>+ {examplePrompts.map((example) => {+ const Icon = iconMap[example.icon];+ return (+ <button+ key={example.id}+ type="button"+ onClick={() => setPrompt(example.prompt)}+ style={{+ borderColor: `${example.color}40`,+ color: example.color,+ }}+ className="rounded-full bg-[#1a1a1a] border hover:brightness-125 transition-all flex items-center gap-1 px-1.5 py-0.5 text-[11px]"+ >+ {Icon && <Icon className="w-3 h-3" />}+ {example.headline}+ </button>+ );+ })}+ </div>+ </form></div>- </div>+ </PageLayout>);};diff --git a/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx b/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsxindex cae7c7918b..e797afc87b 100644--- a/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx+++ b/packages/template-code-generation/src/components/CodeEditor/CodeEditor.tsx@@ -65,14 +65,8 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({isStreamingRef.current = isStreaming;}, [isStreaming]);- // Switch language based on streaming state- useEffect(() => {- const model = editorRef.current?.getModel();- if (model && monacoRef.current) {- const language = isStreaming ? "plaintext" : "javascript";- monacoRef.current.editor.setModelLanguage(model, language);- }- }, [isStreaming]);+ // Derive language from streaming state+ const editorLanguage = isStreaming ? "plaintext" : "javascript";// Continuously clear markers while streaminguseEffect(() => {@@ -298,7 +292,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({<ReadOnlyToast visible={showReadOnlyToast} /><MonacoEditorheight="100%"- defaultLanguage="javascript"+ language={editorLanguage}theme="vs-dark"value={displayCode}onChange={handleChange}diff --git a/packages/template-code-generation/src/components/Logo.tsx b/packages/template-code-generation/src/components/Logo.tsxnew file mode 100644index 0000000000..5b9625aa87--- /dev/null+++ b/packages/template-code-generation/src/components/Logo.tsx@@ -0,0 +1,27 @@+import Image from "next/image";+import Link from "next/link";++interface LogoProps {+ asLink?: boolean;+}++export function Logo({ asLink = false }: LogoProps) {+ const content = (+ <div className="flex items-center gap-3">+ <Image src="/logo-white.svg" alt="Remotion" width={32} height={32} />+ <span className="text-xl font-bold text-white font-sans">+ Remotion Code Generator+ </span>+ </div>+ );++ if (asLink) {+ return (+ <Link href="/" className="flex items-center hover:opacity-80 transition-opacity">+ {content}+ </Link>+ );+ }++ return content;+}diff --git a/packages/template-code-generation/src/components/PageLayout.tsx b/packages/template-code-generation/src/components/PageLayout.tsxnew file mode 100644index 0000000000..0f9a420f45--- /dev/null+++ b/packages/template-code-generation/src/components/PageLayout.tsx@@ -0,0 +1,25 @@+"use client";++import { Logo } from "./Logo";++interface PageLayoutProps {+ children: React.ReactNode;+ rightContent?: React.ReactNode;+ showLogoAsLink?: boolean;+}++export function PageLayout({+ children,+ rightContent,+ showLogoAsLink = false,+}: PageLayoutProps) {+ return (+ <div className="h-screen w-screen bg-[#0a0a0a] flex flex-col">+ <header className="flex justify-between items-start py-8 px-12 shrink-0">+ <Logo asLink={showLogoAsLink} />+ {rightContent}+ </header>+ {children}+ </div>+ );+}diff --git a/packages/template-code-generation/src/components/PromptInput.tsx b/packages/template-code-generation/src/components/PromptInput.tsxindex edc31575b0..e7e362f207 100644--- a/packages/template-code-generation/src/components/PromptInput.tsx+++ b/packages/template-code-generation/src/components/PromptInput.tsx@@ -1,8 +1,9 @@"use client";-import { useState } from "react";+import { useState, forwardRef, useImperativeHandle } from "react";import {ArrowUp,+ Loader2,Type,MessageCircle,Hash,@@ -47,6 +48,10 @@ export type ModelId = (typeof MODELS)[number]["id"];export type StreamPhase = "idle" | "reasoning" | "generating";+export interface PromptInputRef {+ triggerGeneration: () => void;+}+interface PromptInputProps {onCodeGenerated: (code: string) => void;onStreamingChange?: (isStreaming: boolean) => void;@@ -56,213 +61,231 @@ interface PromptInputProps {onPromptChange?: (prompt: string) => void;}-export function PromptInput({- onCodeGenerated,- onStreamingChange,- onStreamPhaseChange,- variant = "editor",- prompt: controlledPrompt,- onPromptChange,-}: PromptInputProps) {- const { apiKey, hasApiKey, isLoaded } = useApiKeyContext();- const [uncontrolledPrompt, setUncontrolledPrompt] = useState("");- const [model, setModel] = useState<ModelId>("gpt-5.1:low");-- // Support both controlled and uncontrolled modes- const prompt =- controlledPrompt !== undefined ? controlledPrompt : uncontrolledPrompt;- const setPrompt = onPromptChange || setUncontrolledPrompt;- const [isLoading, setIsLoading] = useState(false);-- const handleSubmit = async (e: React.FormEvent) => {- e.preventDefault();- if (!prompt.trim() || isLoading || !hasApiKey) return;-- setIsLoading(true);- onStreamingChange?.(true);- onStreamPhaseChange?.("reasoning");- try {- const response = await fetch("/api/generate", {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({ prompt, model, apiKey }),- });-- if (!response.ok) {- throw new Error(`API error: ${response.status}`);- }+export const PromptInput = forwardRef<PromptInputRef, PromptInputProps>(+ function PromptInput(+ {+ onCodeGenerated,+ onStreamingChange,+ onStreamPhaseChange,+ variant = "editor",+ prompt: controlledPrompt,+ onPromptChange,+ },+ ref,+ ) {+ const { apiKey, hasApiKey, isLoaded } = useApiKeyContext();+ const [uncontrolledPrompt, setUncontrolledPrompt] = useState("");+ const [model, setModel] = useState<ModelId>("gpt-5.1:low");- const reader = response.body?.getReader();- if (!reader) {- throw new Error("No response body");- }+ // Support both controlled and uncontrolled modes+ const prompt =+ controlledPrompt !== undefined ? controlledPrompt : uncontrolledPrompt;+ const setPrompt = onPromptChange || setUncontrolledPrompt;+ const [isLoading, setIsLoading] = useState(false);++ const runGeneration = async () => {+ if (!prompt.trim() || isLoading || !hasApiKey) return;++ setIsLoading(true);+ onStreamingChange?.(true);+ onStreamPhaseChange?.("reasoning");+ try {+ const response = await fetch("/api/generate", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ prompt, model, apiKey }),+ });++ if (!response.ok) {+ throw new Error(`API error: ${response.status}`);+ }++ const reader = response.body?.getReader();+ if (!reader) {+ throw new Error("No response body");+ }- const decoder = new TextDecoder();- let accumulatedText = "";- let buffer = "";+ const decoder = new TextDecoder();+ let accumulatedText = "";+ let buffer = "";- while (true) {- const { done, value } = await reader.read();- if (done) break;+ while (true) {+ const { done, value } = await reader.read();+ if (done) break;- buffer += decoder.decode(value, { stream: true });+ buffer += decoder.decode(value, { stream: true });- // Parse SSE events from the buffer- const lines = buffer.split("\n");- buffer = lines.pop() || ""; // Keep incomplete line in buffer+ // Parse SSE events from the buffer+ const lines = buffer.split("\n");+ buffer = lines.pop() || ""; // Keep incomplete line in buffer- for (const line of lines) {- if (!line.startsWith("data: ")) continue;- const data = line.slice(6); // Remove "data: " prefix+ for (const line of lines) {+ if (!line.startsWith("data: ")) continue;+ const data = line.slice(6); // Remove "data: " prefix- if (data === "[DONE]") continue;+ if (data === "[DONE]") continue;- try {- const event = JSON.parse(data);+ try {+ const event = JSON.parse(data);- // Track phase changes- if (event.type === "reasoning-start") {- onStreamPhaseChange?.("reasoning");- } else if (event.type === "text-start") {- onStreamPhaseChange?.("generating");- } else if (event.type === "text-delta") {- accumulatedText += event.delta;+ // Track phase changes+ if (event.type === "reasoning-start") {+ onStreamPhaseChange?.("reasoning");+ } else if (event.type === "text-start") {+ onStreamPhaseChange?.("generating");+ } else if (event.type === "text-delta") {+ accumulatedText += event.delta;- // Strip markdown code block markers and show raw code during streaming- let codeToShow = accumulatedText;- codeToShow = codeToShow.replace(/^```(?:tsx?|jsx?)?\n?/, "");- codeToShow = codeToShow.replace(/\n?```\s*$/, "");+ // Strip markdown code block markers and show raw code during streaming+ let codeToShow = accumulatedText;+ codeToShow = codeToShow.replace(/^```(?:tsx?|jsx?)?\n?/, "");+ codeToShow = codeToShow.replace(/\n?```\s*$/, "");- onCodeGenerated(codeToShow.trim());+ onCodeGenerated(codeToShow.trim());+ }+ } catch {+ // Ignore parse errors for malformed JSON}- } catch {- // Ignore parse errors for malformed JSON}}+ } catch (error) {+ console.error("Error generating code:", error);+ } finally {+ setIsLoading(false);+ onStreamingChange?.(false);+ onStreamPhaseChange?.("idle");}- } catch (error) {- console.error("Error generating code:", error);- } finally {- setIsLoading(false);- onStreamingChange?.(false);- onStreamPhaseChange?.("idle");- }- };-- const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {- // Submit on Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {+ };++ // Expose triggerGeneration via ref+ useImperativeHandle(ref, () => ({+ triggerGeneration: runGeneration,+ }));++ const handleSubmit = async (e: React.FormEvent) => {e.preventDefault();- handleSubmit(e);- }- };-- const isLanding = variant === "landing";-- return (- <div- className={- isLanding- ? "flex flex-col items-center justify-center flex-1 px-4"- : "flex flex-col gap-2"+ await runGeneration();+ };++ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {+ // Submit on Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {+ e.preventDefault();+ handleSubmit(e);}- >- {isLanding && (- <h1 className="text-5xl font-bold text-white mb-10 text-center">- What do you want to create?- </h1>- )}-- <form- onSubmit={handleSubmit}- className={isLanding ? "w-full max-w-3xl" : ""}+ };++ const isLanding = variant === "landing";++ return (+ <div+ className={+ isLanding+ ? "flex flex-col items-center justify-center flex-1 px-4"+ : "flex flex-col gap-2"+ }>- <div className="bg-[#1a1a1a] rounded-xl border border-[#333] p-4">- <textarea- value={prompt}- onChange={(e) => setPrompt(e.target.value)}- onKeyDown={handleKeyDown}- placeholder="Describe your animation..."- className={`w-full bg-transparent text-white placeholder:text-[#666] focus:outline-none resize-none overflow-y-auto ${- isLanding- ? "text-base min-h-[60px] max-h-[200px]"- : "text-sm min-h-[40px] max-h-[150px]"- }`}- style={{ fieldSizing: "content" } as React.CSSProperties}- disabled={isLoading}- />-- <div className="flex justify-between items-center mt-3 pt-3 border-t border-[#333]">- <Select- value={model}- onValueChange={(value) => setModel(value as ModelId)}- disabled={isLoading}- >- <SelectTrigger className="w-auto bg-transparent border-none text-[#888] hover:text-white transition-colors">- <SelectValue />- </SelectTrigger>- <SelectContent className="bg-[#1a1a1a] border-[#333]">- {MODELS.map((m) => (- <SelectItem- key={m.id}- value={m.id}- className="text-white focus:bg-[#333] focus:text-white"- >- {m.name}- </SelectItem>- ))}- </SelectContent>- </Select>-- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <button- type="submit"- disabled={isLoading || !prompt.trim() || !hasApiKey}- className="p-2 rounded-lg bg-white text-black hover:bg-gray-200 disabled:opacity-30 disabled:cursor-not-allowed transition-all"- >- <ArrowUp className="w-5 h-5" />- </button>- </TooltipTrigger>- {!hasApiKey && isLoaded && (- <TooltipContent>- <p>- Add your OpenAI API key in Settings to enable generation- </p>- </TooltipContent>- )}- </Tooltip>- </TooltipProvider>- </div>- </div>+ {isLanding && (+ <h1 className="text-5xl font-bold text-white mb-10 text-center">+ What do you want to create?+ </h1>+ )}- <div- className={`flex flex-wrap items-center gap-1.5 mt-3 ${- isLanding ? "justify-center mt-6 gap-2" : ""- }`}+ <form+ onSubmit={handleSubmit}+ className={isLanding ? "w-full max-w-3xl" : ""}>- <span className="text-[#666] text-xs mr-1">Try</span>- {examplePrompts.map((example) => {- const Icon = iconMap[example.icon];- return (- <button- key={example.id}- type="button"- onClick={() => setPrompt(example.prompt)}- style={{- borderColor: `${example.color}40`,- color: example.color,- }}- className={`rounded-full bg-[#1a1a1a] border hover:brightness-125 transition-all flex items-center gap-1 px-1.5 py-0.5 text-[11px]`}+ <div className="bg-[#1a1a1a] rounded-xl border border-[#333] p-4">+ <textarea+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder="Describe your animation..."+ className={`w-full bg-transparent text-white placeholder:text-[#666] focus:outline-none resize-none overflow-y-auto ${+ isLanding+ ? "text-base min-h-[60px] max-h-[200px]"+ : "text-sm min-h-[40px] max-h-[150px]"+ }`}+ style={{ fieldSizing: "content" } as React.CSSProperties}+ disabled={isLoading}+ />++ <div className="flex justify-between items-center mt-3 pt-3 border-t border-[#333]">+ <Select+ value={model}+ onValueChange={(value) => setModel(value as ModelId)}+ disabled={isLoading}>- {Icon && <Icon className={isLanding ? "w-3 h-3" : "w-3 h-3"} />}- {example.headline}- </button>- );- })}- </div>- </form>- </div>- );-}+ <SelectTrigger className="w-auto bg-transparent border-none text-[#888] hover:text-white transition-colors">+ <SelectValue />+ </SelectTrigger>+ <SelectContent className="bg-[#1a1a1a] border-[#333]">+ {MODELS.map((m) => (+ <SelectItem+ key={m.id}+ value={m.id}+ className="text-white focus:bg-[#333] focus:text-white"+ >+ {m.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>++ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <button+ type="submit"+ disabled={isLoading || !prompt.trim() || !hasApiKey}+ className="p-2 rounded-lg bg-white text-black hover:bg-gray-200 disabled:opacity-30 disabled:cursor-not-allowed transition-all"+ >+ {isLoading ? (+ <Loader2 className="w-5 h-5 animate-spin" />+ ) : (+ <ArrowUp className="w-5 h-5" />+ )}+ </button>+ </TooltipTrigger>+ {!hasApiKey && isLoaded && (+ <TooltipContent>+ <p>+ Add your OpenAI API key in Settings to enable generation+ </p>+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>+ </div>+ </div>++ <div+ className={`flex flex-wrap items-center gap-1.5 mt-3 ${+ isLanding ? "justify-center mt-6 gap-2" : ""+ }`}+ >+ <span className="text-[#666] text-xs mr-1">Try</span>+ {examplePrompts.map((example) => {+ const Icon = iconMap[example.icon];+ return (+ <button+ key={example.id}+ type="button"+ onClick={() => setPrompt(example.prompt)}+ style={{+ borderColor: `${example.color}40`,+ color: example.color,+ }}+ className={`rounded-full bg-[#1a1a1a] border hover:brightness-125 transition-all flex items-center gap-1 px-1.5 py-0.5 text-[11px]`}+ >+ {Icon && <Icon className={isLanding ? "w-3 h-3" : "w-3 h-3"} />}+ {example.headline}+ </button>+ );+ })}+ </div>+ </form>+ </div>+ );+ },+);