π₯ Make videos programmatically with React
Add example prompts
ASchwad0a8bdda857db
diff --git a/packages/template-code-generation/src/components/AnimationPlayer.tsx b/packages/template-code-generation/src/components/AnimationPlayer.tsxindex 4cebf93fd7..064695e06e 100644--- a/packages/template-code-generation/src/components/AnimationPlayer.tsx+++ b/packages/template-code-generation/src/components/AnimationPlayer.tsx@@ -94,6 +94,7 @@ export const AnimationPlayer: React.FC<AnimationPlayerProps> = ({style={{width: "100%",height: "100%",+ backgroundColor: "white",}}controlsautoPlaydiff --git a/packages/template-code-generation/src/components/PromptInput.tsx b/packages/template-code-generation/src/components/PromptInput.tsxindex 585f1a3695..ce79116c46 100644--- a/packages/template-code-generation/src/components/PromptInput.tsx+++ b/packages/template-code-generation/src/components/PromptInput.tsx@@ -15,6 +15,7 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import { useApiKeyContext } from "@/context/ApiKeyContext";+import { examplePrompts } from "@/data/examplePrompts";const MODELS = [{ id: "gpt-5-mini", name: "GPT-5 Mini" },@@ -101,74 +102,95 @@ export function PromptInput({<h2 className="text-sm font-medium text-[#888]">Prompt</h2><formonSubmit={handleSubmit}- className="flex gap-2 p-4 bg-[#1a1a1a] rounded-md"+ className="flex flex-col gap-3 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-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">- <Select- value={model}- onValueChange={(value) => setModel(value as ModelId)}- disabled={isLoading}- >- <SelectTrigger className="w-[160px] bg-[#0f0f0f] border-[#333] text-white">- <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>- <div className="w-full">- <button- type="submit"- disabled={isLoading || !prompt.trim() || !hasApiKey}- className="w-full 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 flex flex-col items-center gap-1"- >- {isLoading ? (- "Generating..."- ) : (- <>- <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>- <span>+</span>- <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">- Enter- </kbd>- </span>- </>- )}- </button>- </div>- </TooltipTrigger>- {!hasApiKey && isLoaded && (- <TooltipContent>- <p>Add your OpenAI API key in Settings to enable generation</p>- </TooltipContent>- )}- </Tooltip>- </TooltipProvider>- </div>+ <div className="flex gap-2">+ <textarea+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder="Describe your animation... (e.g., 'A bouncing ball')"+ 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-[200px] overflow-y-auto"+ style={{ fieldSizing: "content" } as React.CSSProperties}+ disabled={isLoading}+ />+ <div className="flex flex-col gap-2">+ <Select+ value={model}+ onValueChange={(value) => setModel(value as ModelId)}+ disabled={isLoading}+ >+ <SelectTrigger className="w-[160px] bg-[#0f0f0f] border-[#333] text-white">+ <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>+ <div className="w-full">+ <button+ type="submit"+ disabled={isLoading || !prompt.trim() || !hasApiKey}+ className="w-full 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 flex flex-col items-center gap-1"+ >+ {isLoading ? (+ "Generating..."+ ) : (+ <>+ <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>+ <span>+</span>+ <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">+ Enter+ </kbd>+ </span>+ </>+ )}+ </button>+ </div>+ </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-2">+ <span className="text-xs text-[#666]">Try these:</span>+ {examplePrompts.map((example) => (+ <button+ key={example.id}+ type="button"+ onClick={() => setPrompt(example.prompt)}+ style={{+ borderColor: `${example.color}40`,+ color: example.color,+ }}+ className="px-2 py-1 text-xs rounded-full bg-[#252525] border hover:brightness-125 transition-all"+ >+ {example.headline}+ </button>+ ))}+ </div></form></div>);diff --git a/packages/template-code-generation/src/data/examplePrompts.ts b/packages/template-code-generation/src/data/examplePrompts.tsnew file mode 100644index 0000000000..489d078fcd--- /dev/null+++ b/packages/template-code-generation/src/data/examplePrompts.ts@@ -0,0 +1,65 @@+export const examplePrompts = [+ {+ id: "text-typewriter",+ headline: "Typewriter text",+ prompt: `+Generate the text "Hello world" with world in yellow highlighting. Do not render any background. That words should be shown next to each other and rendered in black++Animation: Let the words fade in from left to right and then highlight "world" yellow. Mimic a typewriter effect for the text appearance with a blinking cursor at the end of the text.+ `,+ color: "#fdba74",+ },+ {+ id: "chat-bubbles",+ headline: "Chat messages",+ prompt: `WhatsApp-style chat bubbles that appear one by one with a bouncy spring animation, alternating between sent and received messages.+Use green for sent messages and gray for received messages. Position them on left and right sides respectively.+ `,+ color: "#86efac",+ },+ {+ id: "counter",+ headline: "Metric counters",+ prompt: `Three animated number counters showing Users (10,000), Revenue ($50,000), and Growth (127%) that count up from zero with staggered timing.++Show all metrics at the same time, use this color #fde047. Focus on no overlaps and no flickering. Show the metrics in the center.`,+ color: "#fde047",+ },+ {+ id: "bar-chart",+ headline: "Bar chart",+ prompt: `An animated histogram with the gold price for the following data:+ {+ "title": "Gold Price 2024",+ "unit": "USD per troy ounce",+ "data": [+ { "month": "Jan", "price": 2039 },+ { "month": "Feb", "price": 2024 },+ { "month": "Mar", "price": 2160 },+ { "month": "Apr", "price": 2330 },+ { "month": "May", "price": 2327 },+ { "month": "Jun", "price": 2339 },+ { "month": "Jul", "price": 2426 },+ { "month": "Aug", "price": 2503 },+ { "month": "Sep", "price": 2634 },+ { "month": "Oct", "price": 2735 },+ { "month": "Nov", "price": 2672 },+ { "month": "Dec", "price": 2650 }+ ]+}++ `,+ color: "#a5b4fc",+ },+ {+ id: "doge-dvd",+ headline: "Doge screensaver",+ prompt: `Create a DVD-Rom Style animation of this image https://i.pinimg.com/600x/ac/82/57/ac8257e1cfc4e63f5c63f3d4869eb7c4.jpg+The graphic moves smoothly across the screen in a straight line, bouncing off the edges of the screen whenever it hits a border. Each time it hits a corner or side, it changes direction, creating a continuous floating, ricocheting motion. The speed is steady, the movement is linear, and the object keeps rotating around the screen endlessly, just like the classic DVD logo screensaver.++Change the color on every bounce, no rotation, Make the animation speed very fast.`,+ color: "#f9a8d4",+ },+] as const;++export type ExamplePrompt = (typeof examplePrompts)[number];