🎥 Make videos programmatically with React
layout change
Jonny Burgerbbeff45c850e
diff --git a/packages/convert/app/components/timing-editor/Sidebar.tsx b/packages/convert/app/components/timing-editor/Sidebar.tsxindex 0052fb723a..2826cc6968 100644--- a/packages/convert/app/components/timing-editor/Sidebar.tsx+++ b/packages/convert/app/components/timing-editor/Sidebar.tsx@@ -3,7 +3,6 @@ import {Slider} from '~/components/ui/slider';import {Tabs, TabsList, TabsTrigger} from '~/components/ui/tabs';import {CheckboxWithLabel} from './CheckboxWithLabel';import {EASING_OPTIONS} from './defaults';-import {PADDING_LEFT} from './draw-trajectory';import {SliderLabel} from './SliderLabel';import {Spacing} from './Spacing';import type {EasingType, TimingConfig} from './types';@@ -44,14 +43,13 @@ export const Sidebar: React.FC<{return (<divid="spring-sidebar"+ className="p-4"style={{- padding: PADDING_LEFT,display: 'flex',flexDirection: 'column',borderRight: '1px solid #242424',}}>- <Spacing y={3} /><Tabsvalue={config.type}onValueChange={(value) =>@@ -87,7 +85,6 @@ export const Sidebar: React.FC<{value={config.springConfig.mass}toggleable={null}/>- <br /><Slidermin={1}max={200}@@ -100,7 +97,6 @@ export const Sidebar: React.FC<{value={config.springConfig.damping}toggleable={null}/>- <br /><Slidermin={1}max={200}@@ -112,8 +108,7 @@ export const Sidebar: React.FC<{toggleable={null}label="stiffness"value={config.springConfig.stiffness}- />- <br />+ /><Slidermin={0}max={400}@@ -124,7 +119,6 @@ export const Sidebar: React.FC<{onPointerUp={onRelease}/><SliderLabel label="delay" toggleable={null} value={config.delay} />- <br /><Slidermin={1}max={200}@@ -146,7 +140,6 @@ export const Sidebar: React.FC<{}}value={config.durationInFrames ?? null}/>- <br /><CheckboxWithLabelchecked={config.springConfig.overshootClamping}id="overshootClamping"diff --git a/packages/convert/app/components/timing-editor/draw-trajectory.ts b/packages/convert/app/components/timing-editor/draw-trajectory.tsindex bf75e93aaa..340cddfea3 100644--- a/packages/convert/app/components/timing-editor/draw-trajectory.ts+++ b/packages/convert/app/components/timing-editor/draw-trajectory.ts@@ -1,9 +1,8 @@-import {interpolate, interpolateColors} from 'remotion';--const gradient = ['#42e9f5', '#4290f5'] as const;+import {interpolate} from 'remotion';export const LINE_WIDTH = 5;-export const PADDING_LEFT = 25;+export const AXIS_LABEL_WIDTH = 40;+export const PADDING_LEFT = 25 + AXIS_LABEL_WIDTH;export const PADDING_RIGHT = 20;export const PADDING_TOP = 20;export const PADDING_BOTTOM = 20;@@ -82,18 +81,13 @@ export const drawTrajectory = ({context.moveTo(lastX, lastY);context.lineWidth = LINE_WIDTH;context.lineCap = 'round';- const color = interpolateColors(- i,- [0, springTrajectory.length - 1],- gradient,- );const x = getX({i, segmentWidth});const y = getY({canvasHeight, i, min, max, springTrajectory});lastX = x;lastY = y;- context.strokeStyle = primary ? color : '#eee';+ context.strokeStyle = primary ? '#0b84f3' : '#eee';context.lineTo(x, y);context.stroke();context.closePath();diff --git a/packages/convert/app/components/timing-editor/draw.ts b/packages/convert/app/components/timing-editor/draw.tsindex 2c8978d0bf..d0fba484c3 100644--- a/packages/convert/app/components/timing-editor/draw.ts+++ b/packages/convert/app/components/timing-editor/draw.ts@@ -1,6 +1,7 @@import {measureText} from '@remotion/layout-utils';import {getTrajectory} from './get-trajectory';import {+ AXIS_LABEL_WIDTH,LINE_WIDTH,PADDING_BOTTOM,PADDING_LEFT,@@ -50,7 +51,7 @@ export const draw = ({const min = Math.min(...activeTrajectory);const range = max - min;- context.strokeStyle = 'rgba(255, 255, 255, 0.05)';+ context.strokeStyle = 'rgba(0, 0, 0, 0.1)';context.lineWidth = LINE_WIDTH * window.devicePixelRatio;context.lineCap = 'round';@@ -75,22 +76,49 @@ export const draw = ({23 -16;- // Draw 0 line (if 0 is within the range)- if (min <= 0 && max >= 0) {- const zeroHeight = getYForValue(0);+ const formatAxisLabel = (value: number) => {+ if (Number.isInteger(value)) {+ return value.toString();+ }+ return value.toFixed(2);+ };++ const drawAxisLine = (value: number) => {+ const y = getYForValue(value);++ // Draw the linecontext.beginPath();- context.moveTo(PADDING_LEFT, zeroHeight);- context.lineTo(lineEndX, zeroHeight);+ context.moveTo(PADDING_LEFT, y);+ context.lineTo(lineEndX, y);context.stroke();context.closePath();++ // Draw the label+ context.fillStyle = 'rgba(0, 0, 0, 0.5)';+ context.font = '12px GTPlanar';+ context.textAlign = 'right';+ context.textBaseline = 'middle';+ context.fillText(+ formatAxisLabel(value),+ PADDING_LEFT - AXIS_LABEL_WIDTH + 30,+ y,+ );+ };++ // Draw max line with label+ drawAxisLine(max);++ // Draw min line with label (only if different from max)+ if (min !== max) {+ drawAxisLine(min);}- // Draw 1 line (if 1 is within the range)- if (min <= 1 && max >= 1) {- const oneHeight = getYForValue(1);+ // Draw 0 line if it's within range but not already drawn as min or max+ if (min < 0 && max > 0) {+ const zeroY = getYForValue(0);context.beginPath();- context.moveTo(PADDING_LEFT, oneHeight);- context.lineTo(width - PADDING_RIGHT, oneHeight);+ context.moveTo(PADDING_LEFT, zeroY);+ context.lineTo(lineEndX, zeroY);context.stroke();context.closePath();}diff --git a/packages/convert/app/components/ui/label.tsx b/packages/convert/app/components/ui/label.tsxindex c7850a6f52..90961d86e7 100644--- a/packages/convert/app/components/ui/label.tsx+++ b/packages/convert/app/components/ui/label.tsx@@ -5,7 +5,7 @@ import * as React from 'react';import {cn} from '~/lib/utils';const labelVariants = cva(- 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',+ 'ont-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',);const Label = React.forwardRef<