Skip to content

🎥 Make videos programmatically with React

outer

JonnyBurger5e8b557196f8
diff --git a/packages/convert/app/components/ConversionDone.tsx b/packages/convert/app/components/ConversionDone.tsx
index e3a247a027..5d01da37b7 100644
--- a/packages/convert/app/components/ConversionDone.tsx
+++ b/packages/convert/app/components/ConversionDone.tsx
@@ -1,9 +1,8 @@
-import {Button as RemotionButton} from '@remotion/design';
+import {Button, Button as RemotionButton} from '@remotion/design';
import React, {useCallback} from 'react';
import type {ConvertState, Source} from '~/lib/convert-state';
import {CloneIcon} from './icons/clone';
import {UndoIcon} from './icons/undo';
-import {Button} from './ui/button';
export const ConversionDone: React.FC<{
readonly state: ConvertState;
@@ -47,29 +46,29 @@ export const ConversionDone: React.FC<{
<RemotionButton className="block w-full" onClick={onDownload}>
Download
</RemotionButton>
- <>
- <div className="h-2" />
+ <div className="h-2" />
+ <div className="flex flex-row gap-2">
<Button
- variant="ghost"
- className="w-full flex flex-row justify-start"
+ className="w-full flex-1 flex-row justify-start rounded-full text-sm h-10"
type="button"
onClick={useAsInput}
+ depth={0.2}
>
<CloneIcon className="size-4" />
<div className="w-2" />
Use as input
</Button>
- </>
- <Button
- variant="ghost"
- className="w-full flex flex-row justify-start"
- type="button"
- onClick={startOver}
- >
- <UndoIcon className="size-4" />
- <div className="w-2" />
- Start over
- </Button>
+ <Button
+ className="w-full flex-1 flex-row justify-start rounded-full text-sm h-10"
+ type="button"
+ onClick={startOver}
+ depth={0.2}
+ >
+ <UndoIcon className="size-4" />
+ <div className="w-2" />
+ Start over
+ </Button>
+ </div>
</>
);
};
diff --git a/packages/convert/app/components/DropFileBox.tsx b/packages/convert/app/components/DropFileBox.tsx
index 0302e84b15..601ec7e24f 100644
--- a/packages/convert/app/components/DropFileBox.tsx
+++ b/packages/convert/app/components/DropFileBox.tsx
@@ -31,7 +31,7 @@ export const DropFileBox: React.FC<{
/>
<Button
onClick={() => ref.current?.click()}
- className="bg-brand text-white"
+ className="bg-brand text-white rounded-full px-10"
>
Choose file
</Button>
diff --git a/packages/design/src/Button.tsx b/packages/design/src/Button.tsx
index 9e2ea61942..24cbca04df 100644
--- a/packages/design/src/Button.tsx
+++ b/packages/design/src/Button.tsx
@@ -4,8 +4,10 @@ import {useHoverTransforms} from './helpers/hover-transforms';
import {Outer} from './helpers/Outer';
export const Button: React.FC<
- React.ButtonHTMLAttributes<HTMLButtonElement>
-> = ({children, className, disabled, ...buttonProps}) => {
+ React.ButtonHTMLAttributes<HTMLButtonElement> & {
+ readonly depth?: number;
+ }
+> = ({children, className, disabled, depth, ...buttonProps}) => {
const [dimensions, setDimensions] = useState<{
width: number;
height: number;
@@ -110,6 +112,7 @@ export const Button: React.FC<
height={dimensions.height}
cornerRadius={dimensions.borderRadius}
hoverTransform={progress}
+ depthFactor={depth ?? 1}
>
{content}
</Outer>
diff --git a/packages/design/src/helpers/Outer.tsx b/packages/design/src/helpers/Outer.tsx
index bbc3c3c6b3..df19e76f58 100644
--- a/packages/design/src/helpers/Outer.tsx
+++ b/packages/design/src/helpers/Outer.tsx
@@ -24,11 +24,23 @@ export const Outer: React.FC<{
cornerRadius: number;
hoverTransform: number;
parentRef: React.RefObject<HTMLDivElement | null>;
-}> = ({children, width, height, cornerRadius, hoverTransform, parentRef}) => {
+ depthFactor: number;
+}> = ({
+ children,
+ width,
+ height,
+ cornerRadius,
+ hoverTransform,
+ parentRef,
+ depthFactor,
+}) => {
const clickTransform = useClickTransforms(parentRef);
const angle = useMousePosition(parentRef);
- const appropriateScale = Math.min(1.1, (20 + width) / width);
+ const appropriateScale = Math.min(
+ 1 + 0.1 * depthFactor,
+ (20 + width) / width,
+ );
const transformationUnhovered: MatrixTransform4D = reduceMatrices([
rotateX(-Math.PI / 20),
@@ -46,8 +58,9 @@ export const Outer: React.FC<{
transformationHovered,
);
- const depthFromClick = clickTransform * 15;
- const depthFromHover = interpolate(hoverTransform, [0, 1], [10, 20]);
+ const depthFromClick = clickTransform * 15 * depthFactor;
+ const depthFromHover =
+ interpolate(hoverTransform, [0, 1], [10, 20]) * depthFactor;
const depth = depthFromHover;
const frontFace = reduceMatrices([