Skip to content

🎥 Make videos programmatically with React

nice

JonnyBurger6264a8f6c6c8
diff --git a/packages/design/bundle.ts b/packages/design/bundle.ts
index ca390e7d91..b0b3057fb3 100644
--- a/packages/design/bundle.ts
+++ b/packages/design/bundle.ts
@@ -7,6 +7,7 @@ if (process.env.NODE_ENV !== 'production') {
console.time('Generated.');
const output = await build({
entrypoints: ['src/index.ts'],
+ naming: '[name].mjs',
external: [
'remotion',
'remotion/no-react',
diff --git a/packages/design/src/Button.tsx b/packages/design/src/Button.tsx
index 432d010005..200c1eb504 100644
--- a/packages/design/src/Button.tsx
+++ b/packages/design/src/Button.tsx
@@ -22,10 +22,6 @@ export const Button: React.FC<
}
setDimensions((prevDim) => {
- if (prevDim) {
- return prevDim;
- }
-
if (!ref.current) {
throw new Error('Ref is not set');
}
@@ -42,14 +38,29 @@ export const Button: React.FC<
const rect = childNode.getBoundingClientRect();
const {borderRadius} = getComputedStyle(childNode);
+
const cornerRadius = borderRadius.includes('e+0')
? Infinity
: parseInt(borderRadius ?? '0', 10);
+ const newCornerRadius = Math.min(
+ cornerRadius,
+ rect.width / 2,
+ rect.height / 2,
+ );
+
+ if (prevDim) {
+ return {
+ width: rect.width,
+ height: rect.height,
+ borderRadius: prevDim.borderRadius,
+ };
+ }
+
return {
width: rect.width,
height: rect.height,
- borderRadius: Math.min(cornerRadius, rect.width / 2, rect.height / 2),
+ borderRadius: newCornerRadius,
};
});
},
@@ -61,10 +72,10 @@ export const Button: React.FC<
type="button"
disabled={disabled}
className={cn(
- 'text-black',
+ 'text-text',
'flex',
'justify-center',
- 'bg-white',
+ 'bg-button-bg',
'items-center',
'font-brand',
'border-solid',
@@ -75,11 +86,13 @@ export const Button: React.FC<
'border-b-4',
'cursor-pointer',
'px-4',
- 'py-3',
+ 'h-12',
+ 'flex',
+ 'flex-row',
+ 'items-center',
'disabled:cursor-default',
'disabled:border-gray-500',
'disabled:text-gray-500',
- 'transition-colors',
className,
)}
{...buttonProps}
diff --git a/packages/design/src/helpers/Outer.tsx b/packages/design/src/helpers/Outer.tsx
index 945d41f5de..bbc3c3c6b3 100644
--- a/packages/design/src/helpers/Outer.tsx
+++ b/packages/design/src/helpers/Outer.tsx
@@ -86,6 +86,7 @@ export const Outer: React.FC<{
width,
position: 'absolute',
top: 0,
+ left: 0,
}}
pointerEvents="none"
>
diff --git a/packages/docs/src/pages/design/index.tsx b/packages/docs/src/pages/design/index.tsx
new file mode 100644
index 0000000000..511bda1f97
--- /dev/null
+++ b/packages/docs/src/pages/design/index.tsx
@@ -0,0 +1,17 @@
+import Layout from '@theme/Layout';
+import React from 'react';
+
+import Head from '@docusaurus/Head';
+import {DesignPage} from '@remotion/promo-pages/dist/design.js';
+
+export default () => {
+ return (
+ <Layout>
+ <Head>
+ <title>Remotion | About</title>
+ <meta name="description" content="Remotion's story." />
+ </Head>
+ <DesignPage />
+ </Layout>
+ );
+};
diff --git a/packages/promo-pages/bundle.ts b/packages/promo-pages/bundle.ts
index 3fc3d0d6be..757044088f 100644
--- a/packages/promo-pages/bundle.ts
+++ b/packages/promo-pages/bundle.ts
@@ -28,6 +28,7 @@ const result = await build({
'./src/components/Homepage.tsx',
'./src/components/homepage/Pricing.tsx',
'./src/components/team.tsx',
+ './src/components/design.tsx',
],
outdir: 'dist',
format: 'esm',
diff --git a/packages/promo-pages/src/components/design.tsx b/packages/promo-pages/src/components/design.tsx
new file mode 100644
index 0000000000..a7285f04ef
--- /dev/null
+++ b/packages/promo-pages/src/components/design.tsx
@@ -0,0 +1,41 @@
+import {Button, Counter, Switch} from '@remotion/design';
+import React, {useCallback, useState} from 'react';
+import '../index.css';
+
+export const DesignPage: React.FC = () => {
+ const [count, setCount] = useState<number>(10);
+ const [active, setActive] = useState<boolean>(false);
+
+ const [submitButtonActive, setSubmitButtonActive] = useState<boolean>(true);
+
+ const onClick = useCallback(() => {
+ setSubmitButtonActive(false);
+ setTimeout(() => {
+ setSubmitButtonActive(true);
+ }, 1000);
+ }, []);
+
+ return (
+ <div className="w-[800px] mx-auto pt-10 pb-10">
+ <div className="flex flex-row gap-4">
+ <Button>Button with label</Button>
+ <Button disabled>Disabled</Button>
+ <Button className="bg-brand text-white">Primary</Button>
+ <Button onClick={onClick} disabled={!submitButtonActive}>
+ Click to disable
+ </Button>
+ <Button className="rounded-full">Rounded</Button>
+ </div>
+ <div className="h-8" />
+ <Button className="w-full">Choose a template</Button>
+ <div className="h-8" />
+ <Button className="w-full rounded-full">Fully rounded</Button>
+ <div className="h-8" />
+ <Button className="rounded-full bg-brand w-12 h-12" />
+ <div className="h-8" />
+ <Counter count={count} setCount={setCount} minCount={1} step={1} />
+ <div className="h-8" />
+ <Switch active={active} onToggle={() => setActive((e) => !e)} />
+ </div>
+ );
+};
diff --git a/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx b/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx
index d9f11a400d..aa9f88be12 100644
--- a/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx
+++ b/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx
@@ -1,6 +1,6 @@
+import {Button} from '@remotion/design';
import React, {useState} from 'react';
import {GithubButton} from './GitHubButton';
-import {PlainButton} from './layout/Button';
export const GetStarted: React.FC = () => {
const [clicked, setClicked] = useState<number | null>(null);
@@ -41,16 +41,12 @@ export const GetStarted: React.FC = () => {
href="https://www.youtube.com/watch?v=deg8bOoziaE"
target="_blank"
>
- <PlainButton size="sm" loading={false} className="w-full">
- Watch demo
- </PlainButton>
+ <Button className="w-full">Watch demo</Button>
</a>
</div>
<div style={{width: 10, height: 10}} />
<a className={'no-underline w-full lg:w-auto'} href="/docs">
- <PlainButton size="sm" loading={false} className="w-full">
- Docs
- </PlainButton>
+ <Button className="w-full">Docs</Button>
</a>
<div className="w-2 h-2" />
<a
@@ -58,9 +54,7 @@ export const GetStarted: React.FC = () => {
href="https://remotion.dev/discord"
target="_blank"
>
- <PlainButton size="sm" loading={false} className="w-full">
- Discord
- </PlainButton>
+ <Button className="w-full">Discord</Button>
</a>
<div className="w-2 h-2" />
<a
@@ -68,9 +62,9 @@ export const GetStarted: React.FC = () => {
href="https://github.com/remotion-dev/remotion"
target="_blank"
>
- <PlainButton size="sm" loading={false} className="w-full">
+ <Button className="w-full">
<GithubButton />
- </PlainButton>
+ </Button>
</a>
</div>
);
diff --git a/packages/promo-pages/src/design.tsx b/packages/promo-pages/src/design.tsx
index a634d7e152..f1d3117362 100644
--- a/packages/promo-pages/src/design.tsx
+++ b/packages/promo-pages/src/design.tsx
@@ -1,52 +1,13 @@
-import {Button, Counter, Switch} from '@remotion/design';
-import React, {StrictMode, useCallback, useState} from 'react';
+import {StrictMode} from 'react';
import {createRoot} from 'react-dom/client';
-import './index.css';
-
-const Comp: React.FC = () => {
- const [count, setCount] = useState<number>(10);
- const [active, setActive] = useState<boolean>(false);
-
- const [submitButtonActive, setSubmitButtonActive] = useState<boolean>(true);
-
- const onClick = useCallback(() => {
- setSubmitButtonActive(false);
- setTimeout(() => {
- setSubmitButtonActive(true);
- }, 1000);
- }, []);
-
- return (
- <>
- <div className="flex flex-row gap-4">
- <Button>Button with label</Button>
- <Button disabled>Disabled</Button>
- <Button className="bg-brand text-white">Primary</Button>
- <Button onClick={onClick} disabled={!submitButtonActive}>
- Click to disable
- </Button>
- <Button className="rounded-full">Rounded</Button>
- </div>
- <div className="h-8" />
- <Button className="w-full">Choose a template</Button>
- <div className="h-8" />
- <Button className="w-full rounded-full">Fully rounded</Button>
- <div className="h-8" />
- <Button className="rounded-full bg-brand w-12 h-12" />
- <div className="h-8" />
- <Counter count={count} setCount={setCount} minCount={1} step={1} />
- <div className="h-8" />
- <Switch active={active} onToggle={() => setActive((e) => !e)} />
- </>
- );
-};
+import {DesignPage} from './components/design';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<div data-theme="light">
<div className="flex absolute h-full w-full bg-[#F9FAFC] pt-[100px]">
<div className="w-[800px] mx-auto">
- <Comp />
+ <DesignPage />
</div>
</div>
</div>
diff --git a/packages/promo-pages/src/index.css b/packages/promo-pages/src/index.css
index 89e606af28..98d5d8e29c 100644
--- a/packages/promo-pages/src/index.css
+++ b/packages/promo-pages/src/index.css
@@ -119,6 +119,7 @@ body {
--color-pane: var(--ifm-background-surface-color);
--color-muted: var(--subtitle);
--color-text: var(--text-color);
+ --color-button-bg: var(--plain-button);
}
@utility border-effect {