Skip to content

🎥 Make videos programmatically with React

Simplify components

ASchwad06e478128e2e
diff --git a/packages/template-code-generation/src/components/Container.tsx b/packages/template-code-generation/src/components/Container.tsx
deleted file mode 100644
index 19cbcb59e5..0000000000
--- a/packages/template-code-generation/src/components/Container.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import React from "react";
-
-export const InputContainer: React.FC<{
- children: React.ReactNode;
-}> = ({ children }) => {
- return (
- <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
- {children}
- </div>
- );
-};
diff --git a/packages/template-code-generation/src/components/Input.tsx b/packages/template-code-generation/src/components/Input.tsx
deleted file mode 100644
index d6dcc0434d..0000000000
--- a/packages/template-code-generation/src/components/Input.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import React, { useCallback } from "react";
-
-export const Input: React.FC<{
- text: string;
- setText: React.Dispatch<React.SetStateAction<string>>;
- disabled?: boolean;
-}> = ({ text, setText, disabled }) => {
- const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
- (e) => {
- setText(e.currentTarget.value);
- },
- [setText],
- );
-
- return (
- <input
- className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
- disabled={disabled}
- name="title"
- value={text}
- onChange={onChange}
- />
- );
-};
diff --git a/packages/template-code-generation/src/components/RenderControls.tsx b/packages/template-code-generation/src/components/RenderControls.tsx
index abdd636afe..efc07a8514 100644
--- a/packages/template-code-generation/src/components/RenderControls.tsx
+++ b/packages/template-code-generation/src/components/RenderControls.tsx
@@ -1,9 +1,8 @@
import { z } from "zod";
import { Button } from "@/components/ui/button";
-import { InputContainer } from "./Container";
+import { Input } from "@/components/ui/input";
import { DownloadButton } from "./DownloadButton";
import { ErrorComp } from "./Error";
-import { Input } from "./Input";
import { ProgressBar } from "./ProgressBar";
import { COMP_NAME, CompositionProps } from "../../types/constants";
import { useRendering } from "../helpers/use-rendering";
@@ -16,15 +15,15 @@ export const RenderControls: React.FC<{
const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
return (
- <InputContainer>
+ <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
{state.status === "init" ||
state.status === "invoking" ||
state.status === "error" ? (
<div className="flex flex-col gap-geist-quarter">
<Input
disabled={state.status === "invoking"}
- setText={setText}
- text={text}
+ value={text}
+ onChange={(e) => setText(e.target.value)}
/>
<div className="self-end">
<Button
@@ -50,6 +49,6 @@ export const RenderControls: React.FC<{
</div>
</div>
) : null}
- </InputContainer>
+ </div>
);
};
diff --git a/packages/template-code-generation/src/components/ui/input.tsx b/packages/template-code-generation/src/components/ui/input.tsx
new file mode 100644
index 0000000000..89169058d0
--- /dev/null
+++ b/packages/template-code-generation/src/components/ui/input.tsx
@@ -0,0 +1,21 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+function Input({ className, type, ...props }: React.ComponentProps<"input">) {
+ return (
+ <input
+ type={type}
+ data-slot="input"
+ className={cn(
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
+ "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",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+export { Input }