Skip to content

🎥 Make videos programmatically with React

tabs

Jonny Burger7aac8e37b422
diff --git a/packages/convert/app/components/timing-editor/AnimationDuration.tsx b/packages/convert/app/components/timing-editor/AnimationDuration.tsx
index c23acb06ec..daacb3f7e8 100644
--- a/packages/convert/app/components/timing-editor/AnimationDuration.tsx
+++ b/packages/convert/app/components/timing-editor/AnimationDuration.tsx
@@ -11,7 +11,6 @@ const row: React.CSSProperties = {
position: 'absolute',
right: PADDING_RIGHT,
bottom: PADDING_BOTTOM - 12,
- cursor: 'pointer',
fontVariantNumeric: 'tabular-nums',
};
diff --git a/packages/convert/app/components/timing-editor/Canvas.tsx b/packages/convert/app/components/timing-editor/Canvas.tsx
index 9064d8cd88..c36e1ae2af 100644
--- a/packages/convert/app/components/timing-editor/Canvas.tsx
+++ b/packages/convert/app/components/timing-editor/Canvas.tsx
@@ -20,6 +20,7 @@ export const Canvas: React.FC<{
width: '100%',
height: '100%',
backgroundColor: 'var(--background)',
+ fontFeatureSettings: '"ss03"',
};
}, []);
diff --git a/packages/convert/app/components/timing-editor/ReplayButton.tsx b/packages/convert/app/components/timing-editor/ReplayButton.tsx
new file mode 100644
index 0000000000..1a005d978a
--- /dev/null
+++ b/packages/convert/app/components/timing-editor/ReplayButton.tsx
@@ -0,0 +1,32 @@
+import {Button} from '@remotion/design';
+import React, {useCallback, useState} from 'react';
+import {ReplayIcon} from './ReplayIcon';
+
+export const ReplayButton: React.FC<{
+ readonly onReplay: () => void;
+}> = ({onReplay}) => {
+ const [rotation, setRotation] = useState(0);
+
+ const handleClick = useCallback(() => {
+ setRotation((prev) => prev + 360);
+ onReplay();
+ }, [onReplay]);
+
+ return (
+ <Button
+ type="button"
+ depth={0.7}
+ onClick={handleClick}
+ className="rounded-full w-10 h-10"
+ >
+ <div
+ style={{
+ transform: `rotate(${rotation}deg)`,
+ transition: 'transform 0.3s ease-out',
+ }}
+ >
+ <ReplayIcon />
+ </div>
+ </Button>
+ );
+};
diff --git a/packages/convert/app/components/timing-editor/Sidebar.tsx b/packages/convert/app/components/timing-editor/Sidebar.tsx
index ec9027dbf4..3ade3ce273 100644
--- a/packages/convert/app/components/timing-editor/Sidebar.tsx
+++ b/packages/convert/app/components/timing-editor/Sidebar.tsx
@@ -2,7 +2,6 @@ import {Button} from '@remotion/design';
import React, {useState} from 'react';
import {TextMarkLogo} from '../TextMarkLogo';
import {CodeModal} from './CodeModal';
-import {ReplayIcon} from './ReplayIcon';
import {TimingComponentEditor} from './TimingComponentEditor';
import type {MixingMode, TimingComponent, TimingConfig} from './types';
@@ -20,7 +19,6 @@ export const Sidebar: React.FC<{
) => void;
readonly onChange: (componentId: string, config: TimingConfig) => void;
readonly onRelease: (componentId: string) => void;
- readonly onReplay: () => void;
readonly addComponent: () => void;
readonly removeComponent: (componentId: string) => void;
readonly onMixingModeChange: (componentId: string, mode: MixingMode) => void;
@@ -32,7 +30,6 @@ export const Sidebar: React.FC<{
onChange,
setDraggedConfig,
onRelease,
- onReplay,
addComponent,
removeComponent,
onMixingModeChange,
@@ -52,14 +49,6 @@ export const Sidebar: React.FC<{
>
Get Code
</Button>
- <Button
- type="button"
- depth={0.7}
- onClick={onReplay}
- className="rounded-full w-10 h-10"
- >
- <ReplayIcon />
- </Button>
</div>
</div>
{components.map((component, index) => (
diff --git a/packages/convert/app/components/timing-editor/TimingComponentEditor.tsx b/packages/convert/app/components/timing-editor/TimingComponentEditor.tsx
index 320d0447a5..585900c016 100644
--- a/packages/convert/app/components/timing-editor/TimingComponentEditor.tsx
+++ b/packages/convert/app/components/timing-editor/TimingComponentEditor.tsx
@@ -57,7 +57,7 @@ export const TimingComponentEditor: React.FC<{
</div>
</div>
) : null}
- <Card className="p-3 mb-3 relative group">
+ <Card className="p-3 mb-3 relative group mt-7">
{canRemove ? (
<div className="absolute -top-2 -right-2 opacity-0 group-hover:opacity-100 transition-opacity">
<Button
@@ -71,15 +71,15 @@ export const TimingComponentEditor: React.FC<{
</Button>
</div>
) : null}
- <div className="flex items-center justify-between mb-5">
+ <div className="flex items-center justify-center mb-5 -mt-8">
<Tabs
value={config.type}
onValueChange={(value) =>
onModeChange(value as 'spring' | 'interpolate' | 'sine')
}
- className="flex-1"
+ style={{width: '70%'}}
>
- <TabsList style={{width: '100%'}}>
+ <TabsList>
<TabsTrigger value="spring" style={{flex: 1}}>
Spring
</TabsTrigger>
diff --git a/packages/convert/app/components/timing-editor/TimingEditor.tsx b/packages/convert/app/components/timing-editor/TimingEditor.tsx
index cf8a5b5ab7..881ef0f74c 100644
--- a/packages/convert/app/components/timing-editor/TimingEditor.tsx
+++ b/packages/convert/app/components/timing-editor/TimingEditor.tsx
@@ -8,6 +8,7 @@ import {
DEFAULT_SPRING_CONFIG,
} from './defaults';
import {HARDCODED_FPS} from './generate-code';
+import {ReplayButton} from './ReplayButton';
import {Sidebar} from './Sidebar';
import type {MixingMode, TimingComponent, TimingConfig} from './types';
@@ -156,25 +157,29 @@ export function TimingEditor() {
setDraggedConfig={setDraggedConfig}
onRelease={onRelease}
onChange={onChange}
- onReplay={onReplay}
addComponent={addComponent}
removeComponent={removeComponent}
onMixingModeChange={onMixingModeChange}
/>
- <div className="flex flex-col w-full h-auto flex-1 ">
- <CanvasWrapper
- components={components}
- draggedState={draggedState}
- draggedDuration={draggedDuration}
- duration={duration}
- fps={HARDCODED_FPS}
- replayKey={replayKey}
- />
- <div className="hidden md:flex flex-row justify-center">
+ <div className="flex flex-col w-full h-auto flex-1">
+ <div className="absolute right-4 top-4">
+ <ReplayButton onReplay={onReplay} />
+ </div>
+ <div className="hidden md:flex flex-row justify-center items-center flex-1">
<AnimationPreview animation="Scale" id="spring-scale" />
<AnimationPreview animation="Translate" id="spring-translate" />
<AnimationPreview animation="Rotate" id="spring-rotate" />
</div>
+ <div className="h-[300px]">
+ <CanvasWrapper
+ components={components}
+ draggedState={draggedState}
+ draggedDuration={draggedDuration}
+ duration={duration}
+ fps={HARDCODED_FPS}
+ replayKey={replayKey}
+ />
+ </div>
</div>
</div>
</div>
diff --git a/packages/convert/app/components/timing-editor/draw.ts b/packages/convert/app/components/timing-editor/draw.ts
index 9edc43abf6..c4d154cdc8 100644
--- a/packages/convert/app/components/timing-editor/draw.ts
+++ b/packages/convert/app/components/timing-editor/draw.ts
@@ -1,7 +1,6 @@
import {measureText} from '@remotion/layout-utils';
import {
AXIS_LABEL_WIDTH,
- LINE_WIDTH,
PADDING_BOTTOM,
PADDING_LEFT,
PADDING_RIGHT,
@@ -114,7 +113,6 @@ export const draw = ({
const range = max - min;
context.strokeStyle = 'rgba(0, 0, 0, 0.1)';
- context.lineWidth = LINE_WIDTH * window.devicePixelRatio;
context.lineCap = 'round';
const getYForValue = (value: number) => {
@@ -125,7 +123,8 @@ export const draw = ({
);
};
- const lineEndX =
+ // Short line end for min value (needs space for time info)
+ const shortLineEndX =
width -
PADDING_RIGHT -
measureText({
@@ -138,14 +137,19 @@ export const draw = ({
23 -
16;
+ // Full width line end for other values
+ const fullLineEndX = width - PADDING_RIGHT;
+
const formatAxisLabel = (value: number) => {
return value.toFixed(2);
};
- const drawAxisLine = (value: number) => {
+ const drawAxisLine = (value: number, isMin: boolean) => {
const y = getYForValue(value);
+ const lineEndX = isMin ? shortLineEndX : fullLineEndX;
// Draw the line
+ context.lineWidth = 1 * window.devicePixelRatio;
context.beginPath();
context.moveTo(PADDING_LEFT, y);
context.lineTo(lineEndX, y);
@@ -165,21 +169,21 @@ export const draw = ({
};
// Draw max line with label
- drawAxisLine(max);
+ drawAxisLine(max, false);
// Draw min line with label (only if different from max)
if (min !== max) {
- drawAxisLine(min);
+ drawAxisLine(min, true);
}
// Draw 0 line if it's within range but not already drawn as min or max
if (min < 0 && max > 0) {
- drawAxisLine(0);
+ drawAxisLine(0, false);
}
// Draw 1 line if it's within range but not already drawn as min or max
if (min < 1 && max > 1) {
- drawAxisLine(1);
+ drawAxisLine(1, false);
}
const toStop: (() => void)[] = [];
diff --git a/packages/convert/app/components/ui/tabs.tsx b/packages/convert/app/components/ui/tabs.tsx
index b2ab1a5705..7182a71687 100644
--- a/packages/convert/app/components/ui/tabs.tsx
+++ b/packages/convert/app/components/ui/tabs.tsx
@@ -12,7 +12,7 @@ const TabsList = React.forwardRef<
<TabsPrimitive.List
ref={ref}
className={cn(
- 'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
+ 'inline-flex h-11 items-center justify-center bg-white py-2 px-1 font-brand border-2 border-black border-b-4 rounded-full',
className,
)}
{...props}
@@ -27,7 +27,7 @@ const TabsTrigger = React.forwardRef<
<TabsPrimitive.Trigger
ref={ref}
className={cn(
- 'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1.5 text-sm ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-brand data-[state=active]:text-white data-[state=inactive]:hover:bg-gray-100',
className,
)}
{...props}