🎥 Make videos programmatically with React
Simplify UI components
ASchwad4be3f10b236c
diff --git a/packages/template-code-generation/src/components/AlignEnd.tsx b/packages/template-code-generation/src/components/AlignEnd.tsxdeleted file mode 100644index 7ff7ad53bf..0000000000--- a/packages/template-code-generation/src/components/AlignEnd.tsx+++ /dev/null@@ -1,7 +0,0 @@-import React from "react";--export const AlignEnd: React.FC<{- children: React.ReactNode;-}> = ({ children }) => {- return <div className="self-end">{children}</div>;-};diff --git a/packages/template-code-generation/src/components/Button.tsx b/packages/template-code-generation/src/components/Button.tsxindex 4f924f335d..bbd1ec1f8e 100644--- a/packages/template-code-generation/src/components/Button.tsx+++ b/packages/template-code-generation/src/components/Button.tsx@@ -1,6 +1,5 @@import React, { forwardRef } from "react";-import { Spacing } from "./Spacing";-import { Spinner } from "./Spinner";+import { Spinner } from "./ui/spinner";import { cn } from "../lib/utils";const ButtonForward: React.ForwardRefRenderFunction<@@ -25,12 +24,7 @@ const ButtonForward: React.ForwardRefRenderFunction<onClick={onClick}disabled={disabled}>- {loading && (- <>- <Spinner size={20}></Spinner>- <Spacing></Spacing>- </>- )}+ {loading && <Spinner className="mr-geist-quarter size-5" />}{children}</button>);diff --git a/packages/template-code-generation/src/components/DownloadButton.tsx b/packages/template-code-generation/src/components/DownloadButton.tsxindex 9ccff26b80..d759719cc2 100644--- a/packages/template-code-generation/src/components/DownloadButton.tsx+++ b/packages/template-code-generation/src/components/DownloadButton.tsx@@ -1,7 +1,6 @@import React from "react";import { State } from "../helpers/use-rendering";import { Button } from "./Button";-import { Spacing } from "./Spacing";const Megabytes: React.FC<{sizeInBytes: number;@@ -28,16 +27,16 @@ export const DownloadButton: React.FC<{}return (- <div className="flex">+ <div className="flex gap-geist-quarter"><Button secondary onClick={undo}><UndoIcon></UndoIcon></Button>- <Spacing></Spacing><a href={state.url}><Button>Download video- <Spacing></Spacing>- <Megabytes sizeInBytes={state.size}></Megabytes>+ <span className="ml-geist-quarter">+ <Megabytes sizeInBytes={state.size} />+ </span></Button></a></div>diff --git a/packages/template-code-generation/src/components/RenderControls.tsx b/packages/template-code-generation/src/components/RenderControls.tsxindex 3711310095..f1154534b3 100644--- a/packages/template-code-generation/src/components/RenderControls.tsx+++ b/packages/template-code-generation/src/components/RenderControls.tsx@@ -1,12 +1,10 @@import { z } from "zod";-import { AlignEnd } from "./AlignEnd";import { Button } from "./Button";import { InputContainer } from "./Container";import { DownloadButton } from "./DownloadButton";import { ErrorComp } from "./Error";import { Input } from "./Input";import { ProgressBar } from "./ProgressBar";-import { Spacing } from "./Spacing";import { COMP_NAME, CompositionProps } from "../../types/constants";import { useRendering } from "../helpers/use-rendering";@@ -22,14 +20,13 @@ export const RenderControls: React.FC<{{state.status === "init" ||state.status === "invoking" ||state.status === "error" ? (- <>+ <div className="flex flex-col gap-geist-quarter"><Inputdisabled={state.status === "invoking"}setText={setText}text={text}- ></Input>- <Spacing></Spacing>- <AlignEnd>+ />+ <div className="self-end"><Buttondisabled={state.status === "invoking"}loading={state.status === "invoking"}@@ -37,22 +34,21 @@ export const RenderControls: React.FC<{>Render video</Button>- </AlignEnd>+ </div>{state.status === "error" ? (- <ErrorComp message={state.error.message}></ErrorComp>+ <ErrorComp message={state.error.message} />) : null}- </>+ </div>) : null}{state.status === "rendering" || state.status === "done" ? (- <>+ <div className="flex flex-col gap-geist-quarter"><ProgressBarprogress={state.status === "rendering" ? state.progress : 1}/>- <Spacing></Spacing>- <AlignEnd>- <DownloadButton undo={undo} state={state}></DownloadButton>- </AlignEnd>- </>+ <div className="self-end">+ <DownloadButton undo={undo} state={state} />+ </div>+ </div>) : null}</InputContainer>);diff --git a/packages/template-code-generation/src/components/Spacing.tsx b/packages/template-code-generation/src/components/Spacing.tsxdeleted file mode 100644index c901cfdadb..0000000000--- a/packages/template-code-generation/src/components/Spacing.tsx+++ /dev/null@@ -1,5 +0,0 @@-import React from "react";--export const Spacing: React.FC = () => {- return <div className="w-geist-quarter h-geist-quarter" />;-};diff --git a/packages/template-code-generation/src/components/Spinner.tsx b/packages/template-code-generation/src/components/Spinner.tsxdeleted file mode 100644index 405f2260c1..0000000000--- a/packages/template-code-generation/src/components/Spinner.tsx+++ /dev/null@@ -1,46 +0,0 @@-import React, { useMemo } from "react";-import { makeRect } from "@remotion/shapes";-import { translatePath } from "@remotion/paths";--const viewBox = 100;-const lines = 12;-const width = viewBox * 0.08;--const { path } = makeRect({- height: viewBox * 0.24,- width,- cornerRadius: width / 2,-});--const translated = translatePath(path, viewBox / 2 - width / 2, viewBox * 0.03);--export const Spinner: React.FC<{- size: number;-}> = ({ size }) => {- const style = useMemo(() => {- return {- width: size,- height: size,- };- }, [size]);-- return (- <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>- {new Array(lines).fill(true).map((_, index) => {- return (- <path- className="animate-spinner"- style={{- rotate: `${(index * Math.PI * 2) / lines}rad`,- transformOrigin: "center center",- animationDelay: `${index * 0.1 - lines * 0.1}s`,- }}- key={index}- d={translated}- fill="var(--foreground)"- ></path>- );- })}- </svg>- );-};diff --git a/packages/template-code-generation/src/components/Tips.tsx b/packages/template-code-generation/src/components/Tips.tsxdeleted file mode 100644index 4e0d16cf4e..0000000000--- a/packages/template-code-generation/src/components/Tips.tsx+++ /dev/null@@ -1,53 +0,0 @@-import React from "react";--const Tip: React.FC<{- title: React.ReactNode;- description: React.ReactNode;- href: string;-}> = ({ title, description, href }) => {- return (- <a href={href} target="_blank" rel="noreferrer" className="flex-1">- <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">- <div className="flex flex-row items-center justify-start">- <h4 className="my-3 font-bold text-foreground">{title}</h4>- <div className="flex-1"></div>- <svg- className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"- height="1em"- viewBox="0 0 448 512"- >- <path- fill="var(--foreground)"- d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"- />- </svg>- </div>- <p className="text-sm leading-normal text-subtitle mb-6">- {description}- </p>- </div>- </a>- );-};--export const Tips: React.FC = () => {- return (- <div className="flex flex-col md:flex-row font-geist">- <Tip- href="https://www.remotion.dev/docs/the-fundamentals"- title="Learn Remotion"- description="Learn how to customize this video written in React."- ></Tip>- <Tip- href="https://github.com/remotion-dev/template-next-app-dir"- title="See source"- description="Visit the GitHub repository for this app."- ></Tip>- <Tip- href="https://remotion.dev/discord"- title="Join the community"- description="Chat with others builders on Discord."- ></Tip>- </div>- );-};diff --git a/packages/template-code-generation/src/components/ui/spinner.tsx b/packages/template-code-generation/src/components/ui/spinner.tsxnew file mode 100644index 0000000000..a70e713c5b--- /dev/null+++ b/packages/template-code-generation/src/components/ui/spinner.tsx@@ -0,0 +1,16 @@+import { Loader2Icon } from "lucide-react"++import { cn } from "@/lib/utils"++function Spinner({ className, ...props }: React.ComponentProps<"svg">) {+ return (+ <Loader2Icon+ role="status"+ aria-label="Loading"+ className={cn("size-4 animate-spin", className)}+ {...props}+ />+ )+}++export { Spinner }