🎥 Make videos programmatically with React
so many things
JonnyBurger646c93a650a9
diff --git a/bun.lock b/bun.lockindex db5a9683b7..2265a0dfbf 100644--- a/bun.lock+++ b/bun.lock@@ -256,9 +256,11 @@"@remotion/shapes": "workspace:*","@remotion/whisper-web": "workspace:*","@vercel/remix": "^2.15.2",+ "@vidstack/react": "1.12.13","class-variance-authority": "^0.7.0","clsx": "2.1.1","fast-average-color": "9.4.0",+ "hls.js": "^1.6.15","isbot": "4.1.0","lucide-react": "0.439.0","mediabunny": "catalog:",@@ -4528,6 +4530,8 @@"@vercel/static-config": ["@vercel/[email protected]", "", { "dependencies": { "ajv": "8.6.3", "json-schema-to-ts": "1.6.4", "ts-morph": "12.0.0" } }, "sha512-2qtvcBJ1bGY0dYGYh3iM7yGKkk971FujLEDXzuW5wcZsPr1GSEjO/w2iSr3qve6nDDtBImsGoDEnus5FI4+fIw=="],+ "@vidstack/react": ["@vidstack/[email protected]", "", { "dependencies": { "@floating-ui/dom": "^1.6.10", "media-captions": "^1.0.4" }, "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0" } }, "sha512-zyNydy1+HtoK6cJ8EmqFNkPPGHIFMrr2KH+ef3654EqXx4IcJ8A5LCNMXBuALQE8IMxtk040JMoR9OKyeXjBOQ=="],+"@vitejs/plugin-react": ["@vitejs/[email protected]", "", { "dependencies": { "@babel/core": "7.23.2", "@babel/plugin-transform-react-jsx-self": "7.27.1", "@babel/plugin-transform-react-jsx-source": "7.27.1", "@types/babel__core": "7.20.5", "react-refresh": "0.14.2" }, "peerDependencies": { "vite": "5.4.20" } }, "sha512-rM0SqazU9iqPUraQ2JlIvReeaxOoRj6n+PzB1C0cBzIbd8qP336nC39/R9yPi3wVcah7E7j/kdU1uCUqMEU4OQ=="],"@vitejs/plugin-react-swc": ["@vitejs/[email protected]", "", { "dependencies": { "@swc/core": "1.12.1" }, "peerDependencies": { "vite": "5.4.20" } }, "sha512-vYlodz/mjYRbxMGbHzDgR8aPR+z8n7K/enWkyBGH096xrL2DIPCuTvQVRYPTXGyy6wO7OFiMxZ3r4nKQD1sH0A=="],@@ -5632,7 +5636,7 @@"history": ["[email protected]", "", { "dependencies": { "@babel/runtime": "7.27.1", "loose-envify": "1.4.0", "resolve-pathname": "3.0.0", "tiny-invariant": "1.3.3", "tiny-warning": "1.0.3", "value-equal": "1.0.1" } }, "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew=="],- "hls.js": ["[email protected]", "", { "dependencies": { "eventemitter3": "4.0.7", "url-toolkit": "2.2.3" } }, "sha512-25A7+m6qqp6UVkuzUQ//VVh2EEOPYlOBg32ypr34bcPO7liBMOkKFvbjbCBfiPAOTA/7BSx1Dujft3Th57WyFg=="],+ "hls.js": ["[email protected]", "", {}, "sha512-E3a5VwgXimGHwpRGV+WxRTKeSp2DW5DI5MWv34ulL3t5UNmyJWCQ1KmLEHbYzcfThfXG8amBL+fCYPneGHC4VA=="],"hoist-non-react-statics": ["[email protected]", "", { "dependencies": { "react-is": "16.13.1" } }, "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw=="],@@ -6096,6 +6100,8 @@"mdurl": ["[email protected]", "", {}, "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="],+ "media-captions": ["[email protected]", "", {}, "sha512-cyDNmuZvvO4H27rcBq2Eudxo9IZRDCOX/I7VEyqbxsEiD2Ei7UYUhG/Sc5fvMZjmathgz3fEK7iAKqvpY+Ux1w=="],+"media-query-parser": ["[email protected]", "", { "dependencies": { "@babel/runtime": "7.27.1" } }, "sha512-1N4qp+jE0pL5Xv4uEcwVUhIkwdUO3S/9gML90nqKA7v7FcOS5vUtatfzok9S9U1EJU8dHWlcv95WLnKmmxZI9w=="],"media-typer": ["[email protected]", "", {}, "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ=="],@@ -8710,6 +8716,8 @@"@remotion/eslint-plugin/eslint": ["[email protected]", "", { "dependencies": { "@eslint-community/eslint-utils": "4.4.0", "@eslint-community/regexpp": "4.12.1", "@eslint/eslintrc": "2.1.4", "@eslint/js": "8.57.0", "@humanwhocodes/config-array": "0.11.14", "@humanwhocodes/module-importer": "1.0.1", "@nodelib/fs.walk": "1.2.8", "@ungap/structured-clone": "1.2.0", "ajv": "6.12.6", "chalk": "4.1.2", "cross-spawn": "7.0.6", "debug": "4.4.0", "doctrine": "3.0.0", "escape-string-regexp": "4.0.0", "eslint-scope": "7.2.2", "eslint-visitor-keys": "3.4.3", "espree": "9.6.1", "esquery": "1.5.0", "esutils": "2.0.3", "fast-deep-equal": "3.1.3", "file-entry-cache": "6.0.1", "find-up": "5.0.0", "glob-parent": "6.0.2", "globals": "13.24.0", "graphemer": "1.4.0", "ignore": "5.3.2", "imurmurhash": "0.1.4", "is-glob": "4.0.3", "is-path-inside": "3.0.3", "js-yaml": "4.1.0", "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.4.1", "lodash.merge": "4.6.2", "minimatch": "3.1.2", "natural-compare": "1.4.0", "optionator": "0.9.3", "strip-ansi": "6.0.1", "text-table": "0.2.0" }, "bin": { "eslint": "bin/eslint.js" } }, "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ=="],+ "@remotion/example/hls.js": ["[email protected]", "", { "dependencies": { "eventemitter3": "4.0.7", "url-toolkit": "2.2.3" } }, "sha512-25A7+m6qqp6UVkuzUQ//VVh2EEOPYlOBg32ypr34bcPO7liBMOkKFvbjbCBfiPAOTA/7BSx1Dujft3Th57WyFg=="],+"@remotion/example/tailwindcss": ["[email protected]", "", {}, "sha512-ULRPI3A+e39T7pSaf1xoi58AqqJxVCLg8F/uM5A3FadUbnyDTgltVnXJvdkTjwCOGA6NazqHVcwPJC5h2vRYVQ=="],"@remotion/lambda/@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "1.19.1", "@types/express-serve-static-core": "5.0.4", "@types/serve-static": "1.13.10" } }, "sha512-UZUw8vjpWFXuDnjFTh7/5c2TWDlQqeXHi6hcN7F2XSVT5P+WmUnnbFS3KA6Jnc6IsEqI2qCVu2bK0R0J4A8ZQQ=="],@@ -9402,6 +9410,8 @@"docs/clsx": ["[email protected]", "", {}, "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg=="],+ "docs/hls.js": ["[email protected]", "", { "dependencies": { "eventemitter3": "4.0.7", "url-toolkit": "2.2.3" } }, "sha512-25A7+m6qqp6UVkuzUQ//VVh2EEOPYlOBg32ypr34bcPO7liBMOkKFvbjbCBfiPAOTA/7BSx1Dujft3Th57WyFg=="],+"docs/polished": ["[email protected]", "", { "dependencies": { "@babel/runtime": "7.27.1" } }, "sha512-jq4t3PJUpVRcveC53nnbEX35VyQI05x3tniwp26WFdm1dwaNUBHAi5awa/roBlwQxx1uRhwNSYeAi/aMbfiJCQ=="],"dot-case/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],diff --git a/packages/convert/app/components/CardLikeButton.tsx b/packages/convert/app/components/CardLikeButton.tsxnew file mode 100644index 0000000000..a299cace9c--- /dev/null+++ b/packages/convert/app/components/CardLikeButton.tsx@@ -0,0 +1,76 @@+import {Heart} from '@remotion/shapes';+import React, {useCallback, useEffect, useState} from 'react';+import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {+ formatLikeCount,+ getLikedIds,+ removeLikedId,+ saveLikedId,+} from '~/lib/prompt-helpers';+import {useHeartAnimation} from '~/lib/use-heart-animation';++export const CardLikeButton: React.FC<{+ readonly submissionId: string;+ readonly initialLikeCount: number;+}> = ({submissionId, initialLikeCount}) => {+ const [liked, setLiked] = useState(false);+ const [likeCount, setLikeCount] = useState(initialLikeCount);+ const {scale, roundness, animate} = useHeartAnimation();++ useEffect(() => {+ setLiked(getLikedIds().has(submissionId));+ }, [submissionId]);++ const onClick = useCallback(+ async (e: React.MouseEvent) => {+ e.preventDefault();+ if (liked) {+ setLiked(false);+ setLikeCount((c) => c - 1);+ removeLikedId(submissionId);++ try {+ await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/unlike`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ body: JSON.stringify({submissionId}),+ });+ } catch {+ // Optimistic+ }+ } else {+ animate();+ setLiked(true);+ setLikeCount((c) => c + 1);+ saveLikedId(submissionId);++ try {+ await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/like`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ body: JSON.stringify({submissionId}),+ });+ } catch {+ // Optimistic+ }+ }+ },+ [liked, submissionId, animate],+ );++ return (+ <button onClick={onClick} className="flex items-center" type="button">+ <Heart+ height={16}+ fill={liked ? 'var(--color-brand)' : 'none'}+ stroke={liked ? 'var(--color-brand)' : 'black'}+ strokeWidth={2}+ bottomRoundnessAdjustment={roundness}+ style={{transform: `scale(${scale})`, marginTop: 2}}+ />+ <span className="font-brand font-medium" style={{marginLeft: 8, flex: 1}}>+ {formatLikeCount(likeCount)}+ </span>+ </button>+ );+};diff --git a/packages/convert/app/components/CopyPromptButton.tsx b/packages/convert/app/components/CopyPromptButton.tsxnew file mode 100644index 0000000000..161e71c268--- /dev/null+++ b/packages/convert/app/components/CopyPromptButton.tsx@@ -0,0 +1,32 @@+import {Button} from '@remotion/design';+import React, {useCallback, useState} from 'react';+import {ClipboardIcon} from '~/components/icons/ClipboardIcon';++export const CopyPromptButton: React.FC<{+ readonly prompt: string;+}> = ({prompt}) => {+ const [copied, setCopied] = useState(false);++ const onCopy = useCallback(() => {+ navigator.clipboard.writeText(prompt);+ setCopied(true);+ setTimeout(() => setCopied(false), 2000);+ }, [prompt]);++ return (+ <Button+ className="font-brand rounded-full flex items-center "+ onClick={onCopy}+ style={{width: 160}}+ depth={0.6}+ >+ <div className="flex items-center flex-row flex-1 w-[130px]">+ <ClipboardIcon size={20} />+ <div className="w-2" />+ <div style={{fontSize: 14, flex: 1, textAlign: 'center'}}>+ {copied ? 'Copied prompt!' : 'Copy prompt'}+ </div>+ </div>+ </Button>+ );+};diff --git a/packages/convert/app/components/LikeButton.tsx b/packages/convert/app/components/LikeButton.tsxnew file mode 100644index 0000000000..9ed3efc9c1--- /dev/null+++ b/packages/convert/app/components/LikeButton.tsx@@ -0,0 +1,79 @@+import {Button} from '@remotion/design';+import {Heart} from '@remotion/shapes';+import React, {useCallback, useEffect, useState} from 'react';+import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {+ formatLikeCount,+ getLikedIds,+ removeLikedId,+ saveLikedId,+} from '~/lib/prompt-helpers';+import {useHeartAnimation} from '~/lib/use-heart-animation';++export const LikeButton: React.FC<{+ readonly submissionId: string;+ readonly initialLikeCount: number;+}> = ({submissionId, initialLikeCount}) => {+ const [liked, setLiked] = useState(false);+ const [likeCount, setLikeCount] = useState(initialLikeCount);+ const {scale, roundness, animate} = useHeartAnimation();++ useEffect(() => {+ setLiked(getLikedIds().has(submissionId));+ }, [submissionId]);++ const onClick = useCallback(async () => {+ if (liked) {+ setLiked(false);+ setLikeCount((c) => c - 1);+ removeLikedId(submissionId);++ try {+ await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/unlike`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ body: JSON.stringify({submissionId}),+ });+ } catch {+ // Optimistic+ }+ } else {+ animate();+ setLiked(true);+ setLikeCount((c) => c + 1);+ saveLikedId(submissionId);++ try {+ await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/like`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ body: JSON.stringify({submissionId}),+ });+ } catch {+ // Optimistic+ }+ }+ }, [liked, submissionId, animate]);++ return (+ <Button+ className={`font-brand rounded-full flex items-center ${liked ? 'bg-brand text-white' : ''}`}+ onClick={onClick}+ style={{width: 90}}+ >+ <div className="flex items-center flex-row flex-1 w-[40px] justify-center">+ <Heart+ height={14}+ fill={liked ? 'white' : 'none'}+ stroke={liked ? 'white' : 'black'}+ strokeWidth={2}+ bottomRoundnessAdjustment={roundness}+ style={{transform: `scale(${scale})`}}+ />+ <span style={{fontSize: 15, marginLeft: 10}}>+ {formatLikeCount(likeCount)}+ </span>+ </div>+ </Button>+ );+};diff --git a/packages/convert/app/components/MuxPlayer.tsx b/packages/convert/app/components/MuxPlayer.tsxnew file mode 100644index 0000000000..fb03eedd73--- /dev/null+++ b/packages/convert/app/components/MuxPlayer.tsx@@ -0,0 +1,55 @@+import {+ isHLSProvider,+ MediaPlayer,+ MediaProvider,+ type MediaProviderAdapter,+ type MediaProviderChangeEvent,+} from '@vidstack/react';+import {+ DefaultVideoLayout,+ defaultLayoutIcons,+} from '@vidstack/react/player/layouts/default';+import React, {useCallback} from 'react';++import '@vidstack/react/player/styles/default/theme.css';+import '@vidstack/react/player/styles/default/layouts/video.css';++export const MuxPlayer: React.FC<{+ readonly playbackId: string;+ readonly title?: string;+ readonly rounded?: boolean;+}> = ({playbackId, title, rounded = true}) => {+ const onProviderChange = useCallback(+ (provider: MediaProviderAdapter | null, _e: MediaProviderChangeEvent) => {+ if (isHLSProvider(provider)) {+ provider.library = () => import('hls.js');+ }+ },+ [],+ );++ return (+ <MediaPlayer+ src={`https://stream.mux.com/${playbackId}.m3u8`}+ crossOrigin+ playsInline+ autoPlay+ muted+ title={title}+ className={`w-full aspect-video bg-black overflow-hidden ${rounded ? 'rounded' : ''}`}+ onProviderChange={onProviderChange}+ >+ <MediaProvider />+ <DefaultVideoLayout+ icons={defaultLayoutIcons}+ slots={{+ captionButton: null,+ pipButton: null,+ airPlayButton: null,+ googleCastButton: null,+ settingsMenu: null,+ }}+ />+ </MediaPlayer>+ );+};diff --git a/packages/convert/app/components/NewBackButton.tsx b/packages/convert/app/components/NewBackButton.tsxnew file mode 100644index 0000000000..ec2e2b24af--- /dev/null+++ b/packages/convert/app/components/NewBackButton.tsx@@ -0,0 +1,37 @@+import {Button} from '@remotion/design';+import React from 'react';++export const NewBackButton: React.FC<{+ readonly color: string;+ readonly text: string;+ readonly link: string;+}> = ({color, text, link}) => {+ return (+ <a+ href={link}+ className="justify-center items-center font-medium no-underline mb-4 block"+ style={{+ fontFamily: 'GTPlanar',+ fontWeight: 500,+ color,+ }}+ >+ <Button className="px-4 rounded-full text-sm h-10">+ <div className="flex row items-center justify-start font-normal">+ <svg+ className="h-4 mr-[8px] inline-block"+ style={{color}}+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 448 512"+ >+ <path+ fill="currentcolor"+ d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"+ />+ </svg>+ {text}+ </div>+ </Button>+ </a>+ );+};diff --git a/packages/convert/app/components/Page.tsx b/packages/convert/app/components/Page.tsxindex a1041ae83b..5dfea33df2 100644--- a/packages/convert/app/components/Page.tsx+++ b/packages/convert/app/components/Page.tsx@@ -6,10 +6,14 @@ export const pageRef = React.createRef<HTMLDivElement>();export const Page: React.FC<{readonly children: React.ReactNode;readonly className?: string;-}> = ({children, className}) => {+ readonly onDrop?: React.DragEventHandler<HTMLDivElement>;+ readonly onDragOver?: React.DragEventHandler<HTMLDivElement>;+}> = ({children, className, onDrop, onDragOver}) => {return (<divref={pageRef}+ onDrop={onDrop}+ onDragOver={onDragOver}className={clsx('overflow-y-auto w-full bg-slate-50 min-h-screen',className,diff --git a/packages/convert/app/components/icons/ClipboardIcon.tsx b/packages/convert/app/components/icons/ClipboardIcon.tsxnew file mode 100644index 0000000000..e4e3234b94--- /dev/null+++ b/packages/convert/app/components/icons/ClipboardIcon.tsx@@ -0,0 +1,18 @@+import React from 'react';++export const ClipboardIcon: React.FC<{+ readonly size?: number;+ readonly color?: string;+}> = ({size = 16, color = 'currentColor'}) => {+ return (+ <svg+ width={size}+ height={size}+ viewBox="0 0 448 512"+ fill={color}+ xmlns="http://www.w3.org/2000/svg"+ >+ <path d="M193.8 57.5c4.5-33.1 42.1-29 51 2 3.1 11.3 4.6 23.4 5.2 36.5l-60.1 0c.8-13.8 2.1-27.5 3.9-38.5zM303.1 32.4c-28.6-78.7-141.6-84.6-168.4-2-1-.1-52.9 .6-53.9 .6-83.2 4.6-88.7 75.4-86.5 143l0 1.5c-.8 85.3-5.3 182.8 8.1 262.5 1.6 36.1 28.4 68.6 66.9 71.6 86.7 9.3 178.9 6.3 266.1 .3 55 3.5 106.6-13.8 106.2-76.2-.7-18.9-.6-35.3 1-47.3 5.8-92.7 3.3-165.2-.5-267.9-1.7-46.5-39.3-83.6-85.8-84.8l-53.2-1.3zm10.9 64.3c20.6 2.3 62.6-7.6 64.1 24.2 3.8 102.5 6.2 171.9 .7 260.5-3.9 17.9 2 43.3-3.2 61.1-10.9 4.9-24.9 1.6-38.4 3.2-87.3 5.5-171.5 9.8-262.7 0-3.3-.3-7.2-3.2-7.7-8.6-13.6-84.2-9.3-175.1-8.5-260.2 5-25.2-12.6-79.3 23.2-82l44.4-.5c-2.6 27.2-4.4 64.6 31.1 65.5l125.3 0c34.4-.6 33.8-37 31.7-63.3z" />+ </svg>+ );+};diff --git a/packages/convert/app/components/icons/HeartIcon.tsx b/packages/convert/app/components/icons/HeartIcon.tsxnew file mode 100644index 0000000000..4314f1e859--- /dev/null+++ b/packages/convert/app/components/icons/HeartIcon.tsx@@ -0,0 +1,22 @@+import React from 'react';++export const HeartIcon: React.FC<{+ readonly size?: number;+ readonly fill?: string;+ readonly stroke?: string;+ readonly strokeWidth?: number;+}> = ({size = 24, fill = 'none', stroke = 'black', strokeWidth = 2}) => {+ return (+ <svg+ width={size}+ height={size}+ viewBox="0 0 24 24"+ fill={fill}+ stroke={stroke}+ strokeWidth={strokeWidth}+ xmlns="http://www.w3.org/2000/svg"+ >+ <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />+ </svg>+ );+};diff --git a/packages/convert/app/lib/prompt-helpers.ts b/packages/convert/app/lib/prompt-helpers.tsnew file mode 100644index 0000000000..8a2299f5a1--- /dev/null+++ b/packages/convert/app/lib/prompt-helpers.ts@@ -0,0 +1,63 @@+import type {Submission} from './prompt-types';++export const formatLikeCount = (n: number): string => {+ if (n < 1000) return String(n);+ if (n < 10000) return `${(n / 1000).toFixed(1).replace(/\.0$/, '')}k`;+ if (n < 1000000) return `${Math.floor(n / 1000)}k`;+ return `${(n / 1000000).toFixed(1).replace(/\.0$/, '')}M`;+};++const LIKED_KEY = 'remotion-prompt-likes';++export const getLikedIds = (): Set<string> => {+ try {+ const stored = localStorage.getItem(LIKED_KEY);+ return new Set(stored ? JSON.parse(stored) : []);+ } catch {+ return new Set();+ }+};++export const saveLikedId = (id: string) => {+ const liked = getLikedIds();+ liked.add(id);+ localStorage.setItem(LIKED_KEY, JSON.stringify([...liked]));+};++export const removeLikedId = (id: string) => {+ const liked = getLikedIds();+ liked.delete(id);+ localStorage.setItem(LIKED_KEY, JSON.stringify([...liked]));+};++export const getAvatarUrl = (s: Submission): string | null => {+ if (s.customAvatarUrl) return s.customAvatarUrl;+ if (s.githubUsername) return `https://github.com/${s.githubUsername}.png`;+ if (s.xUsername) return `https://unavatar.io/x/${s.xUsername}`;+ return null;+};++export const getAuthorName = (s: Submission): string => {+ if (s.githubUsername) return s.githubUsername;+ if (s.xUsername) return `@${s.xUsername}`;+ return 'Anonymous';+};++export const getRelativeTime = (dateStr: string): string => {+ const now = Date.now();+ const then = new Date(dateStr).getTime();+ const seconds = Math.floor((now - then) / 1000);++ if (seconds < 60) return 'just now';+ const minutes = Math.floor(seconds / 60);+ if (minutes < 60) return `${minutes} minute${minutes === 1 ? '' : 's'} ago`;+ const hours = Math.floor(minutes / 60);+ if (hours < 24) return `${hours} hour${hours === 1 ? '' : 's'} ago`;+ const days = Math.floor(hours / 24);+ if (days < 30) return `${days} day${days === 1 ? '' : 's'} ago`;+ const months = Math.floor(days / 30);+ if (months < 12)+ return `${months} month${months === 1 ? '' : 's'} ago`;+ const years = Math.floor(months / 12);+ return `${years} year${years === 1 ? '' : 's'} ago`;+};diff --git a/packages/convert/app/lib/prompt-types.ts b/packages/convert/app/lib/prompt-types.tsnew file mode 100644index 0000000000..de7982024a--- /dev/null+++ b/packages/convert/app/lib/prompt-types.ts@@ -0,0 +1,12 @@+export type Submission = {+ id: string;+ createdAt: string;+ title: string;+ slug: string;+ muxPlaybackId: string;+ prompt: string;+ githubUsername: string | null;+ xUsername: string | null;+ customAvatarUrl: string | null;+ likeCount: number;+};diff --git a/packages/convert/app/lib/use-heart-animation.ts b/packages/convert/app/lib/use-heart-animation.tsnew file mode 100644index 0000000000..74e7f4e91f--- /dev/null+++ b/packages/convert/app/lib/use-heart-animation.ts@@ -0,0 +1,36 @@+import {useCallback, useRef, useState} from 'react';++const DURATION = 300;++export const useHeartAnimation = () => {+ const [scale, setScale] = useState(1);+ const [roundness, setRoundness] = useState(0.09);+ const rafRef = useRef(0);++ const animate = useCallback(() => {+ cancelAnimationFrame(rafRef.current);+ const start = performance.now();++ const tick = (now: number) => {+ const elapsed = now - start;+ const t = Math.min(elapsed / DURATION, 1);+ // ease-out quad for the up phase, then ease-in for down+ const half = t < 0.5 ? t * 2 : (1 - t) * 2;+ const eased = half * (2 - half); // ease-out quad++ setScale(1 + 0.1 * eased);+ setRoundness(0.09 + 0.1 * eased);++ if (t < 1) {+ rafRef.current = requestAnimationFrame(tick);+ } else {+ setScale(1);+ setRoundness(0.09);+ }+ };++ rafRef.current = requestAnimationFrame(tick);+ }, []);++ return {scale, roundness, animate};+};diff --git a/packages/convert/app/routes/prompts.$slug._index.tsx b/packages/convert/app/routes/prompts.$slug._index.tsxdeleted file mode 100644index dcaa9561ef..0000000000--- a/packages/convert/app/routes/prompts.$slug._index.tsx+++ /dev/null@@ -1,204 +0,0 @@-import type {LoaderFunctionArgs} from '@remix-run/node';-import {useLoaderData} from '@remix-run/react';-import React, {useCallback, useEffect, useState} from 'react';-import {REMOTION_PRO_ORIGIN} from '~/lib/config';-import {Page} from '~/components/Page';-import {Button} from '~/components/ui/button';-import {Card} from '~/components/ui/card';--type Submission = {- id: string;- createdAt: string;- title: string;- slug: string;- muxPlaybackId: string;- prompt: string;- githubUsername: string | null;- xUsername: string | null;- customAvatarUrl: string | null;- likeCount: number;-};--export const loader = async ({params}: LoaderFunctionArgs) => {- return {slug: params.slug};-};--const LIKED_KEY = 'remotion-prompt-likes';--const getLikedIds = (): Set<string> => {- try {- const stored = localStorage.getItem(LIKED_KEY);- return new Set(stored ? JSON.parse(stored) : []);- } catch {- return new Set();- }-};--const saveLikedId = (id: string) => {- const liked = getLikedIds();- liked.add(id);- localStorage.setItem(LIKED_KEY, JSON.stringify([...liked]));-};--const PromptPermalink: React.FC = () => {- const {slug} = useLoaderData<typeof loader>();- const [submission, setSubmission] = useState<Submission | null>(null);- const [error, setError] = useState<string | null>(null);- const [liked, setLiked] = useState(false);- const [likeCount, setLikeCount] = useState(0);-- useEffect(() => {- (async () => {- try {- const res = await fetch(- `${REMOTION_PRO_ORIGIN}/api/prompts/${slug}`,- );- if (!res.ok) {- setError('Submission not found');- return;- }-- const data = await res.json();- setSubmission(data);- setLikeCount(data.likeCount);- setLiked(getLikedIds().has(data.id));- } catch {- setError('Failed to load submission');- }- })();- }, [slug]);-- const onLike = useCallback(async () => {- if (!submission || liked) return;-- setLiked(true);- setLikeCount((c) => c + 1);- saveLikedId(submission.id);-- try {- await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/like`, {- method: 'POST',- headers: {'content-type': 'application/json'},- body: JSON.stringify({submissionId: submission.id}),- });- } catch {- // Optimistic- }- }, [submission, liked]);-- if (error) {- return (- <Page className="flex-col">- <div className="m-auto max-w-[800px] w-full px-4 py-12">- <p className="text-muted-foreground">{error}</p>- <a href="/prompts" className="underline text-sm mt-4 block">- Back to gallery- </a>- </div>- </Page>- );- }-- if (!submission) {- return (- <Page className="flex-col">- <div className="m-auto max-w-[800px] w-full px-4 py-12">- <p className="text-muted-foreground">Loading...</p>- </div>- </Page>- );- }-- const avatarUrl =- submission.customAvatarUrl ||- (submission.githubUsername- ? `https://github.com/${submission.githubUsername}.png`- : null);-- const authorName = submission.githubUsername- ? submission.githubUsername- : submission.xUsername- ? `@${submission.xUsername}`- : 'Anonymous';-- const authorLink = submission.githubUsername- ? `https://github.com/${submission.githubUsername}`- : submission.xUsername- ? `https://x.com/${submission.xUsername}`- : null;-- return (- <Page className="flex-col">- <div className="m-auto max-w-[800px] w-full px-4 py-12">- <a- href="/prompts"- className="text-muted-foreground text-sm mb-4 block hover:underline"- >- ← Back to gallery- </a>- <Card className="overflow-hidden">- <div className="aspect-video bg-black">- <iframe- src={`https://stream.mux.com/${submission.muxPlaybackId}`}- className="w-full h-full"- allow="autoplay; fullscreen"- allowFullScreen- title={submission.title}- />- </div>- <div className="p-6">- <h1 className="text-2xl font-brand font-black">- {submission.title}- </h1>-- <div className="flex items-center gap-3 mt-4">- {avatarUrl && (- <img- src={avatarUrl}- width={32}- height={32}- className="rounded-full"- alt=""- />- )}- {authorLink ? (- <a- href={authorLink}- target="_blank"- rel="noopener noreferrer"- className="text-sm font-medium hover:underline"- >- {authorName}- </a>- ) : (- <span className="text-sm font-medium">- {authorName}- </span>- )}- </div>-- <h2 className="font-brand font-bold mt-6 mb-2">- Prompt- </h2>- <pre className="whitespace-pre-wrap text-sm bg-slate-100 rounded p-4 border">- {submission.prompt}- </pre>-- <div className="mt-6 flex items-center gap-4">- <Button- variant={liked ? 'default' : 'outline'}- onClick={onLike}- disabled={liked}- >- {liked ? '♥' : '♡'} {likeCount}{' '}- {likeCount === 1 ? 'like' : 'likes'}- </Button>- </div>- </div>- </Card>- </div>- </Page>- );-};--export default PromptPermalink;diff --git a/packages/convert/app/routes/prompts._index.tsx b/packages/convert/app/routes/prompts._index.tsxindex 2badf9c498..a0e344ef2a 100644--- a/packages/convert/app/routes/prompts._index.tsx+++ b/packages/convert/app/routes/prompts._index.tsx@@ -1,97 +1,40 @@+import {Button} from '@remotion/design';import React, {useCallback, useEffect, useState} from 'react';-import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {CardLikeButton} from '~/components/CardLikeButton';import {Page} from '~/components/Page';-import {Button} from '~/components/ui/button';import {Card} from '~/components/ui/card';--type Submission = {- id: string;- createdAt: string;- title: string;- slug: string;- muxPlaybackId: string;- prompt: string;- githubUsername: string | null;- xUsername: string | null;- customAvatarUrl: string | null;- likeCount: number;-};--const LIKED_KEY = 'remotion-prompt-likes';--const getLikedIds = (): Set<string> => {- try {- const stored = localStorage.getItem(LIKED_KEY);- return new Set(stored ? JSON.parse(stored) : []);- } catch {- return new Set();- }-};--const saveLikedId = (id: string) => {- const liked = getLikedIds();- liked.add(id);- localStorage.setItem(LIKED_KEY, JSON.stringify([...liked]));-};--const getAvatarUrl = (s: Submission): string | null => {- if (s.customAvatarUrl) return s.customAvatarUrl;- if (s.githubUsername) return `https://github.com/${s.githubUsername}.png`;- return null;-};--const getAuthorName = (s: Submission): string => {- if (s.githubUsername) return s.githubUsername;- if (s.xUsername) return `@${s.xUsername}`;- return 'Anonymous';-};+import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {getAuthorName, getAvatarUrl} from '~/lib/prompt-helpers';+import type {Submission} from '~/lib/prompt-types';const SubmissionCard: React.FC<{readonly submission: Submission}> = ({submission,}) => {- const [liked, setLiked] = useState(false);- const [likeCount, setLikeCount] = useState(submission.likeCount);-- useEffect(() => {- setLiked(getLikedIds().has(submission.id));- }, [submission.id]);-- const onLike = useCallback(async () => {- if (liked) return;-- setLiked(true);- setLikeCount((c) => c + 1);- saveLikedId(submission.id);-- try {- await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/like`, {- method: 'POST',- headers: {'content-type': 'application/json'},- body: JSON.stringify({submissionId: submission.id}),- });- } catch {- // Optimistic update, don't revert- }- }, [liked, submission.id]);-+ const [hovered, setHovered] = useState(false);const avatarUrl = getAvatarUrl(submission);return (- <a href={`/prompts/${submission.slug}`} className="block">+ <a+ href={`/prompts/show?prompt=${submission.slug}`}+ className="block"+ onMouseEnter={() => setHovered(true)}+ onMouseLeave={() => setHovered(false)}+ ><Card className="overflow-hidden hover:shadow-md transition-shadow"><img- src={`https://image.mux.com/${submission.muxPlaybackId}/thumbnail.png?width=400&height=225&fit_mode=smartcrop`}+ src={+ hovered+ ? `https://image.mux.com/${submission.muxPlaybackId}/animated.gif?width=400&height=225&fit_mode=smartcrop`+ : `https://image.mux.com/${submission.muxPlaybackId}/thumbnail.png?width=400&height=225&fit_mode=smartcrop`+ }className="w-full aspect-video object-cover"alt={submission.title}/><div className="p-4">- <h3 className="font-brand font-bold text-sm truncate">+ <h3 className="font-brand font-bold text-lg truncate">{submission.title}</h3>- <p className="text-muted-foreground text-xs mt-1 line-clamp-2">- {submission.prompt}- </p>- <div className="flex items-center justify-between mt-3">+ <div className="flex items-center justify-between mt-1"><div className="flex items-center gap-2">{avatarUrl && (<img@@ -102,20 +45,14 @@ const SubmissionCard: React.FC<{readonly submission: Submission}> = ({alt=""/>)}- <span className="text-xs text-muted-foreground">+ <span className="text-sm font-brand text-black">{getAuthorName(submission)}</span></div>- <button- onClick={(e) => {- e.preventDefault();- onLike();- }}- className={`text-xs flex items-center gap-1 ${liked ? 'text-red-500' : 'text-muted-foreground hover:text-red-500'}`}- type="button"- >- {liked ? '♥' : '♡'} {likeCount}- </button>+ <CardLikeButton+ submissionId={submission.id}+ initialLikeCount={submission.likeCount}+ /></div></div></Card>@@ -154,45 +91,51 @@ const PromptsGallery: React.FC = () => {return (<Page className="flex-col"><div className="m-auto max-w-[1200px] w-full px-4 py-12">- <div className="flex items-center justify-between mb-8">- <h1 className="text-3xl font-brand font-black">- Prompt Gallery- </h1>- <a href="/prompts/submit">- <Button>Submit a prompt</Button>- </a>+ <div className="mb-8">+ <h1 className="text-3xl font-brand font-black">Prompt Gallery</h1>+ <p className="font-brand text-muted-foreground mt-4 max-w-[700px]">+ With{' '}+ <a href="/docs/ai/skills" className="underline hover:text-black">+ Remotion Skills+ </a>+ , you can create videos simply by giving a prompt to your coding+ agent, whether it's Claude Code, Codex, or OpenCode. Browse the+ gallery for inspiration!+ </p></div>-+ <a href="/prompts/submit" className="flex items-center gap-2">+ <Button className="font-brand rounded-full bg-[#D97757] flex items-center text-white">+ <svg+ width="20"+ height="20"+ viewBox="0 0 149 149"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ style={{marginRight: 8}}+ >+ <path+ d="M29.05 98.54L58.19 82.19L58.68 80.77L58.19 79.98H56.77L51.9 79.68L35.25 79.23L20.81 78.63L6.82 77.88L3.3 77.13L0 72.78L0.340004 70.61L3.3 68.62L7.54 68.99L16.91 69.63L30.97 70.6L41.17 71.2L56.28 72.77H58.68L59.02 71.8L58.2 71.2L57.56 70.6L43.01 60.74L27.26 50.32L19.01 44.32L14.55 41.28L12.3 38.43L11.33 32.21L15.38 27.75L20.82 28.12L22.21 28.49L27.72 32.73L39.49 41.84L54.86 53.16L57.11 55.03L58.01 54.39L58.12 53.94L57.11 52.25L48.75 37.14L39.83 21.77L35.86 15.4L34.81 11.58C34.44 10.01 34.17 8.69 34.17 7.08L38.78 0.820007L41.33 0L47.48 0.820007L50.07 3.07001L53.89 11.81L60.08 25.57L69.68 44.28L72.49 49.83L73.99 54.97L74.55 56.54H75.52V55.64L76.31 45.1L77.77 32.16L79.19 15.51L79.68 10.82L82 5.2L86.61 2.16L90.21 3.88L93.17 8.12L92.76 10.86L91 22.3L87.55 40.22L85.3 52.22H86.61L88.11 50.72L94.18 42.66L104.38 29.91L108.88 24.85L114.13 19.26L117.5 16.6H123.87L128.56 23.57L126.46 30.77L119.9 39.09L114.46 46.14L106.66 56.64L101.79 65.04L102.24 65.71L103.4 65.6L121.02 61.85L130.54 60.13L141.9 58.18L147.04 60.58L147.6 63.02L145.58 68.01L133.43 71.01L119.18 73.86L97.96 78.88L97.7 79.07L98 79.44L107.56 80.34L111.65 80.56H121.66L140.3 81.95L145.17 85.17L148.09 89.11L147.6 92.11L140.1 95.93L129.98 93.53L106.36 87.91L98.26 85.89H97.14V86.56L103.89 93.16L116.26 104.33L131.75 118.73L132.54 122.29L130.55 125.1L128.45 124.8L114.84 114.56L109.59 109.95L97.7 99.94H96.91V100.99L99.65 105L114.12 126.75L114.87 133.42L113.82 135.59L110.07 136.9L105.95 136.15L97.48 124.26L88.74 110.87L81.69 98.87L80.83 99.36L76.67 144.17L74.72 146.46L70.22 148.18L66.47 145.33L64.48 140.72L66.47 131.61L68.87 119.72L70.82 110.27L72.58 98.53L73.63 94.63L73.56 94.37L72.7 94.48L63.85 106.63L50.39 124.82L39.74 136.22L37.19 137.23L32.77 134.94L33.18 130.85L35.65 127.21L50.39 108.46L59.28 96.84L65.02 90.13L64.98 89.16H64.64L25.49 114.58L18.52 115.48L15.52 112.67L15.89 108.06L17.31 106.56L29.08 98.46L29.04 98.5L29.05 98.54Z"+ fill="#fff"+ />+ </svg>+ <div className="text-sm">Make your own</div>+ </Button>+ <Button className="font-brand rounded-full text-sm">+ Submit a prompt+ </Button>+ </a>+ <div className="h-12" /><div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">{submissions.map((s) => (<SubmissionCard key={s.id} submission={s} />))}</div>- {loading && (- <div className="text-center text-muted-foreground mt-8">- Loading...- </div>- )}-- {!loading && submissions.length === 0 && (- <div className="text-center text-muted-foreground mt-8">- No submissions yet. Be the first to{' '}- <a href="/prompts/submit" className="underline">- submit a prompt- </a>- !- </div>- )}+ {loading && <div className="text-center text-muted-foreground mt-8" />}{nextCursor && !loading && (<div className="text-center mt-8">- <Button- variant="outline"- onClick={() => fetchPage(nextCursor)}- >- Load more- </Button>+ <Button onClick={() => fetchPage(nextCursor)}>Load more</Button></div>)}</div>diff --git a/packages/convert/app/routes/prompts.show._index.tsx b/packages/convert/app/routes/prompts.show._index.tsxnew file mode 100644index 0000000000..4b597aa0dd--- /dev/null+++ b/packages/convert/app/routes/prompts.show._index.tsx@@ -0,0 +1,148 @@+import {useSearchParams} from '@remix-run/react';+import React, {useEffect, useState} from 'react';+import {CopyPromptButton} from '~/components/CopyPromptButton';+import {LikeButton} from '~/components/LikeButton';+import {MuxPlayer} from '~/components/MuxPlayer';+import {NewBackButton} from '~/components/NewBackButton';+import {Page} from '~/components/Page';+import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {+ getAuthorName,+ getAvatarUrl,+ getRelativeTime,+} from '~/lib/prompt-helpers';+import type {Submission} from '~/lib/prompt-types';++const PromptPermalink: React.FC = () => {+ const [searchParams] = useSearchParams();+ const slug = searchParams.get('prompt');+ const [submission, setSubmission] = useState<Submission | null>(null);+ const [error, setError] = useState<string | null>(null);++ useEffect(() => {+ if (!slug) {+ setError('No prompt specified');+ return;+ }++ (async () => {+ try {+ const res = await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/${slug}`);+ if (!res.ok) {+ setError('Submission not found');+ return;+ }++ const data = await res.json();+ setSubmission(data);+ } catch {+ setError('Failed to load submission');+ }+ })();+ }, [slug]);++ if (error) {+ return (+ <Page className="flex-col">+ <div className="m-auto max-w-[800px] w-full px-4 py-12">+ <p className="text-muted-foreground">{error}</p>+ <a href="/prompts" className="underline text-sm mt-4 block">+ Back to gallery+ </a>+ </div>+ </Page>+ );+ }++ if (!submission) {+ return (+ <Page className="flex-col">+ <div className="m-auto max-w-[800px] w-full px-4 py-12">+ <p className="text-muted-foreground">Loading...</p>+ </div>+ </Page>+ );+ }++ const avatarUrl = getAvatarUrl(submission);+ const authorName = getAuthorName(submission);++ const authorLink = submission.githubUsername+ ? `https://github.com/${submission.githubUsername}`+ : submission.xUsername+ ? `https://x.com/${submission.xUsername}`+ : null;++ return (+ <Page className="flex-col">+ <div className="m-auto max-w-[800px] w-full px-4 py-12">+ <NewBackButton color="black" text="Back to gallery" link="/prompts" />+ <div className="h-6" />+ <div>+ <MuxPlayer+ playbackId={submission.muxPlaybackId}+ title={submission.title}+ rounded={false}+ />+ <div className="pt-6">+ <h1 className="text-2xl font-brand font-black">+ {submission.title}+ </h1>++ <div className="flex items-center gap-3 mt-4">+ {avatarUrl && (+ <img+ src={avatarUrl}+ width={32}+ height={32}+ className="rounded-full"+ alt=""+ />+ )}+ <div>+ <div className="text-sm font-brand">+ Submitted by{' '}+ {authorLink ? (+ <a+ href={authorLink}+ target="_blank"+ rel="noopener noreferrer"+ className="font-medium hover:underline"+ >+ {authorName}+ </a>+ ) : (+ <span className="font-medium">{authorName}</span>+ )}+ </div>+ <div+ className="text-xs text-muted-foreground font-brand"+ title={new Date(submission.createdAt).toLocaleString()}+ >+ {getRelativeTime(submission.createdAt)}+ </div>+ </div>+ </div>++ <h2 className="font-brand font-bold mt-6 mb-2">Prompt</h2>+ <pre+ className="whitespace-pre-wrap text-sm rounded p-4 text-white"+ style={{backgroundColor: '#272A36'}}+ >+ {submission.prompt}+ </pre>+ <div className="mt-6 flex items-center gap-2">+ <LikeButton+ submissionId={submission.id}+ initialLikeCount={submission.likeCount}+ />+ <CopyPromptButton prompt={submission.prompt} />+ </div>+ </div>+ </div>+ </div>+ </Page>+ );+};++export default PromptPermalink;diff --git a/packages/convert/app/routes/prompts.submit._index.tsx b/packages/convert/app/routes/prompts.submit._index.tsxindex c403ffb507..08345dd8ea 100644--- a/packages/convert/app/routes/prompts.submit._index.tsx+++ b/packages/convert/app/routes/prompts.submit._index.tsx@@ -1,12 +1,18 @@+import {useNavigate} from '@remix-run/react';+import {+ Button,+ Input,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger,+ Textarea,+} from '@remotion/design';import React, {useCallback, useEffect, useRef, useState} from 'react';-import {REMOTION_PRO_ORIGIN} from '~/lib/config';+import {MuxPlayer} from '~/components/MuxPlayer';+import {NewBackButton} from '~/components/NewBackButton';import {Page} from '~/components/Page';-import {Button} from '~/components/ui/button';-import {Card} from '~/components/ui/card';-import {Input} from '~/components/ui/input';-import {Label} from '~/components/ui/label';-import {RadioGroup, RadioGroupItem} from '~/components/ui/radio';-import {Textarea} from '~/components/ui/textarea';+import {REMOTION_PRO_ORIGIN} from '~/lib/config';type UsernameType = 'github' | 'x';@@ -24,9 +30,10 @@ type SubmitStatus =| {type: 'error'; err: Error};const PromptSubmit: React.FC = () => {+ const navigate = useNavigate();const [title, setTitle] = useState('');const [prompt, setPrompt] = useState('');- const [usernameType, setUsernameType] = useState<UsernameType | null>(null);+ const [usernameType, setUsernameType] = useState<UsernameType>('github');const [username, setUsername] = useState('');const [uploadState, setUploadState] = useState<UploadState>({type: 'idle'});const [submitStatus, setSubmitStatus] = useState<SubmitStatus>({@@ -40,74 +47,91 @@ const PromptSubmit: React.FC = () => {};}, []);- const onFileSelect = useCallback(- async (e: React.ChangeEvent<HTMLInputElement>) => {- const file = e.target.files?.[0];- if (!file) return;+ const fileInputRef = useRef<HTMLInputElement | null>(null);- setUploadState({type: 'uploading', progress: 0});+ const startUpload = useCallback(async (file: File) => {+ setUploadState({type: 'uploading', progress: 0});- try {- const res = await fetch(- `${REMOTION_PRO_ORIGIN}/api/prompts/upload`,- {- method: 'POST',- headers: {'content-type': 'application/json'},- },- );- const {id, url} = await res.json();+ try {+ const res = await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/upload`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ });+ const {id, url} = await res.json();- const {createUpload} = await import('@mux/upchunk');- const upload = createUpload({endpoint: url, file});+ const {createUpload} = await import('@mux/upchunk');+ const upload = createUpload({endpoint: url, file});- upload.on('progress', (p: {detail: number}) => {- setUploadState({type: 'uploading', progress: p.detail});- });+ upload.on('progress', (p: {detail: number}) => {+ setUploadState({type: 'uploading', progress: p.detail});+ });- upload.on('success', () => {- setUploadState({type: 'processing'});+ upload.on('success', () => {+ setUploadState({type: 'processing'});- pollRef.current = setInterval(async () => {- try {- const statusRes = await fetch(- `${REMOTION_PRO_ORIGIN}/api/prompts/upload/${id}`,- );- const data = await statusRes.json();+ pollRef.current = setInterval(async () => {+ try {+ const statusRes = await fetch(+ `${REMOTION_PRO_ORIGIN}/api/prompts/upload/${id}`,+ );+ const data = await statusRes.json();- if (- data.status === 'asset_created' &&- data.playback_id &&- data.asset_status === 'ready'- ) {- if (pollRef.current) clearInterval(pollRef.current);- setUploadState({- type: 'ready',- muxAssetId: data.asset_id,- muxPlaybackId: data.playback_id,- });- }- } catch {- // keep polling+ if (+ data.status === 'asset_created' &&+ data.playback_id &&+ data.asset_status === 'ready'+ ) {+ if (pollRef.current) clearInterval(pollRef.current);+ setUploadState({+ type: 'ready',+ muxAssetId: data.asset_id,+ muxPlaybackId: data.playback_id,+ });}- }, 2000);- });+ } catch {+ // keep polling+ }+ }, 2000);+ });- upload.on('error', (err: {detail: {message: string}}) => {- setUploadState({- type: 'error',- message: err.detail.message,- });- });- } catch (err) {+ upload.on('error', (err: {detail: {message: string}}) => {setUploadState({type: 'error',- message: err instanceof Error ? err.message : 'Upload failed',+ message: err.detail.message,});- }+ });+ } catch (err) {+ setUploadState({+ type: 'error',+ message: err instanceof Error ? err.message : 'Upload failed',+ });+ }+ }, []);++ const onFileSelect = useCallback(+ (e: React.ChangeEvent<HTMLInputElement>) => {+ const file = e.target.files?.[0];+ if (!file) return;+ startUpload(file);+ },+ [startUpload],+ );++ const onPageDrop: React.DragEventHandler = useCallback(+ (e) => {+ e.preventDefault();+ if (uploadState.type !== 'idle') return;+ const file = e.dataTransfer?.files?.[0];+ if (!file) return;+ startUpload(file);},- [],+ [startUpload, uploadState.type],);+ const onPageDragOver: React.DragEventHandler = useCallback((e) => {+ e.preventDefault();+ }, []);+const submitPossible =title.length > 0 &&title.length <= 80 &&@@ -123,22 +147,18 @@ const PromptSubmit: React.FC = () => {setSubmitStatus({type: 'submitting'});try {- const res = await fetch(- `${REMOTION_PRO_ORIGIN}/api/prompts/submit`,- {- method: 'POST',- headers: {'content-type': 'application/json'},- body: JSON.stringify({- muxAssetId: uploadState.muxAssetId,- muxPlaybackId: uploadState.muxPlaybackId,- title,- prompt,- githubUsername:- usernameType === 'github' ? username : undefined,- xUsername: usernameType === 'x' ? username : undefined,- }),- },- );+ const res = await fetch(`${REMOTION_PRO_ORIGIN}/api/prompts/submit`, {+ method: 'POST',+ headers: {'content-type': 'application/json'},+ body: JSON.stringify({+ muxAssetId: uploadState.muxAssetId,+ muxPlaybackId: uploadState.muxPlaybackId,+ title,+ prompt,+ githubUsername: usernameType === 'github' ? username : undefined,+ xUsername: usernameType === 'x' ? username : undefined,+ }),+ });if (!res.ok) {const data = await res.json();@@ -156,40 +176,51 @@ const PromptSubmit: React.FC = () => {return (<Page className="flex-col"><div className="m-auto max-w-[800px] w-full">- <Card className="mx-4 px-8 py-8 mt-12 pt-8">+ <div className="mx-4 px-8 py-8 mt-12 pt-8"><h1 className="text-3xl font-brand font-black">Submission received!</h1>- <p className="mt-4 text-muted-foreground">- Your prompt submission is pending review. Once approved, it will- appear on the{' '}+ <div className="mt-4 text-muted-foreground font-brand">+ Thanks for submitting your prompt! Your prompt submission is+ pending review.+ <br /> Once approved, it will appear on the{' '}<a href="/prompts" className="underline">prompts gallery</a>.- </p>- </Card>+ </div>+ <div className="mt-4 text-muted-foreground font-brand">+ Note that this our showcase is curated - we may reject submissions+ if they are repetitive or not up to our quality standards. In that+ case, we will not give notification or reason.+ </div>+ <Button+ onClick={() => navigate('/prompts')}+ className="font-brand rounded-full mt-4"+ >+ Back to gallery+ </Button>+ </div></div></Page>);}return (- <Page className="flex-col">+ <Page className="flex-col" onDrop={onPageDrop} onDragOver={onPageDragOver}><div className="m-auto max-w-[800px] w-full">- <Card className="mx-4 px-8 py-8 mt-12 pt-8">- <h1 className="text-3xl font-brand font-black">- Submit a prompt- </h1>-+ <div className="mx-4 px-8 py-8 mt-12 pt-8">+ <NewBackButton color="black" text="Back to gallery" link="/prompts" />+ <div className="h-10" />+ <h1 className="text-3xl font-brand font-black">Submit a prompt</h1><h2 className="font-brand mt-5 font-bold">Title *</h2><p className="text-muted-foreground text-sm">A short title for your prompt (max 80 characters).</p><Inputname="title"- className="mt-3"- placeholder="My cool Remotion prompt"+ placeholder="Newspaper highlighting animation"+ className="font-brand mt-3"value={title}maxLength={80}onChange={(e) => setTitle(e.target.value)}@@ -200,46 +231,45 @@ const PromptSubmit: React.FC = () => {<h2 className="font-brand mt-5 font-bold">Video *</h2><p className="text-muted-foreground text-sm">- Upload a video showing the result of your prompt.+ Upload a video showing the result of your prompt. You can also drop+ a file anywhere on this page.</p>- <div className="relative overflow-hidden flex h-40 border-black rounded-md mt-3 justify-center items-center border-solid border-2">+ <input+ ref={fileInputRef}+ type="file"+ accept="video/*"+ onChange={onFileSelect}+ className="hidden"+ />+ <div className="flex flex-col items-center py-12">{uploadState.type === 'idle' && (- <>- <input- type="file"- accept="video/*"- onChange={onFileSelect}- className="appearance-none w-full h-full cursor-pointer opacity-0"- />- <div className="pointer-events-none inset-0 absolute flex items-center justify-center">- <div className="text-muted-foreground font-medium text-sm">- Drag a video or click here- </div>- </div>- </>+ <Button+ className="font-brand rounded-full"+ onClick={() => fileInputRef.current?.click()}+ >+ Choose video file+ </Button>)}{uploadState.type === 'uploading' && (- <div className="text-muted-foreground font-medium text-sm">+ <div className="text-muted-foreground font-brand font-medium text-sm">Uploading {Math.round(uploadState.progress)}%</div>)}{uploadState.type === 'processing' && (- <div className="text-muted-foreground font-medium text-sm">+ <div className="text-muted-foreground font-brand font-medium text-sm">Processing video...</div>)}{uploadState.type === 'ready' && (- <div className="text-muted-foreground font-medium text-sm flex flex-col items-center gap-2">- <img- src={`https://image.mux.com/${uploadState.muxPlaybackId}/thumbnail.png?width=240`}- className="rounded"- alt="Video thumbnail"+ <div className="w-full">+ <MuxPlayer+ playbackId={uploadState.muxPlaybackId}+ title={title || 'Preview'}/>- Video ready</div>)}{uploadState.type === 'error' && (- <div className="text-red-500 font-medium text-sm">+ <div className="text-red-500 font-brand font-medium text-sm">{uploadState.message}</div>)}@@ -251,7 +281,7 @@ const PromptSubmit: React.FC = () => {</p><Textareaname="prompt"- className="mt-3"+ className="font-brand mt-3"placeholder="Enter your full prompt here"value={prompt}onChange={(e) => setPrompt(e.target.value)}@@ -260,50 +290,44 @@ const PromptSubmit: React.FC = () => {<h2 className="font-brand mt-5 font-bold">How should we credit you? *</h2>- <RadioGroup- name="usernameType"+ <Tabs+ defaultValue="github"className="mt-3"- onValueChange={(e: string) =>- setUsernameType(e as UsernameType)- }+ onValueChange={(value: string) => {+ setUsernameType(value as UsernameType);+ setUsername('');+ }}>- <div className="flex items-center space-x-2">- <RadioGroupItem- checked={usernameType === 'github'}- value="github"- id="github"+ <TabsList>+ <TabsTrigger value="github">GitHub</TabsTrigger>+ <TabsTrigger value="x">X (Twitter)</TabsTrigger>+ </TabsList>+ <TabsContent value="github">+ <Input+ name="username"+ className="font-brand"+ placeholder="Your GitHub username"+ value={usernameType === 'github' ? username : ''}+ onChange={(e) => setUsername(e.target.value)}/>- <Label htmlFor="github">GitHub username</Label>- </div>- <div className="flex items-center space-x-2">- <RadioGroupItem- checked={usernameType === 'x'}- value="x"- id="x"+ </TabsContent>+ <TabsContent value="x">+ <Input+ name="username"+ className="font-brand"+ placeholder="Your X username (without @)"+ value={usernameType === 'x' ? username : ''}+ onChange={(e) => setUsername(e.target.value)}/>- <Label htmlFor="x">X (Twitter) username</Label>- </div>- </RadioGroup>-- {usernameType && (- <Input- name="username"- className="mt-3"- placeholder={- usernameType === 'github'- ? 'Your GitHub username'- : 'Your X username (without @)'- }- value={username}- onChange={(e) => setUsername(e.target.value)}- />- )}+ </TabsContent>+ </Tabs><div className="h-8" /><ButtononClick={submit}disabled={!submitPossible}type="submit"+ className="font-brand rounded-full w-full bg-brand text-white">Submit</Button>@@ -312,7 +336,7 @@ const PromptSubmit: React.FC = () => {An error occurred: {submitStatus.err.message}</p>)}- </Card>+ </div></div></Page>);diff --git a/packages/convert/package.json b/packages/convert/package.jsonindex 63968966ac..dcdafb82d5 100644--- a/packages/convert/package.json+++ b/packages/convert/package.json@@ -38,9 +38,11 @@"@remotion/shapes": "workspace:*","@remotion/whisper-web": "workspace:*","@vercel/remix": "^2.15.2",+ "@vidstack/react": "1.12.13","class-variance-authority": "^0.7.0","clsx": "2.1.1","fast-average-color": "9.4.0",+ "hls.js": "^1.6.15","isbot": "4.1.0","lucide-react": "0.439.0","mediabunny": "catalog:",diff --git a/packages/promo-pages/src/components/templates.tsx b/packages/promo-pages/src/components/templates.tsxindex 1a178389b7..6449e614b2 100644--- a/packages/promo-pages/src/components/templates.tsx+++ b/packages/promo-pages/src/components/templates.tsx@@ -55,7 +55,7 @@ export const Templates: React.FC = () => {><Buttondepth={0.5}- className="items-start justify-start text-left p-3.5 flex flex-col relative cursor-pointer text-[var(--text-color)] no-underline h-full w-full items-start"+ className="justify-start text-left p-3.5 flex flex-col relative cursor-pointer text-[var(--text-color)] no-underline h-full w-full items-start"><Itemlabel={template.homePageLabel}