Skip to content

🎥 Make videos programmatically with React

layout in constants

Jonny Burger34b56af96d7a
diff --git a/packages/cli/src/editor/components/AudioWaveform.tsx b/packages/cli/src/editor/components/AudioWaveform.tsx
index 70228a6eed..176a8556e3 100644
--- a/packages/cli/src/editor/components/AudioWaveform.tsx
+++ b/packages/cli/src/editor/components/AudioWaveform.tsx
@@ -1,5 +1,6 @@
import React, {useEffect, useMemo, useState} from 'react';
import {getWaveform} from '../helpers/get-waveform';
+import {TIMELINE_LAYER_HEIGHT} from '../helpers/timeline-layout';
const filterData = (audioBuffer: Float32Array) => {
const samples = 200; // Number of samples we want to have in our final data set
@@ -54,7 +55,7 @@ export const AudioWaveform: React.FC<{
flexDirection: 'row',
alignItems: 'center',
position: 'absolute',
- height: 80,
+ height: TIMELINE_LAYER_HEIGHT,
}}
>
{normalized.map((w, i) => {
@@ -63,7 +64,7 @@ export const AudioWaveform: React.FC<{
// eslint-disable-next-line react/no-array-index-key
key={i}
style={{
- height: 40 * w,
+ height: (TIMELINE_LAYER_HEIGHT / 2) * w,
width: 4,
backgroundColor: 'rgba(255, 255, 255, 0.2)',
marginLeft: 2,
diff --git a/packages/cli/src/editor/components/Timeline/TimelineElements.tsx b/packages/cli/src/editor/components/Timeline/TimelineElements.tsx
index 89b2d26f2f..72a8571c85 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineElements.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineElements.tsx
@@ -2,13 +2,14 @@ import React, {useContext, useMemo} from 'react';
import {Internals} from 'remotion';
import styled from 'styled-components';
import {calculateTimeline, Track} from '../../helpers/calculate-timeline';
+import {TIMELINE_LAYER_HEIGHT} from '../../helpers/timeline-layout';
import {TimelineSequence} from './TimelineSequence';
const Container = styled.div`
height: 100%;
display: grid;
grid-gap: 2px;
- grid-auto-rows: minmax(25px, 80px);
+ grid-auto-rows: minmax(25px, ${TIMELINE_LAYER_HEIGHT}px);
`;
export const TimelineElements: React.FC = () => {
@@ -27,7 +28,7 @@ export const TimelineElements: React.FC = () => {
const inner: React.CSSProperties = useMemo(() => {
return {
- height: 82,
+ height: TIMELINE_LAYER_HEIGHT + 2,
};
}, []);
diff --git a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
index 9eba5bd0df..cac9fa92f8 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
@@ -1,7 +1,10 @@
import React, {useMemo} from 'react';
import {Internals, TSequence} from 'remotion';
import styled from 'styled-components';
-import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
+import {
+ TIMELINE_LAYER_HEIGHT,
+ TIMELINE_PADDING,
+} from '../../helpers/timeline-layout';
import {useWindowSize} from '../../hooks/use-window-size';
import {AudioWaveform} from '../AudioWaveform';
import {Thumbnail} from '../Thumbnail';
@@ -16,8 +19,6 @@ const Pre = styled.pre`
position: absolute;
`;
-export const TIMELINE_LAYER_HEIGHT = 80;
-
const SEQUENCE_GRADIENT = 'linear-gradient(to bottom, #3697e1, #348AC7 60%)';
const AUDIO_GRADIENT = 'linear-gradient(rgb(16 171 58), rgb(43 165 63) 60%)';
@@ -54,7 +55,7 @@ export const TimelineSequence: React.FC<{
color: 'white',
overflow: 'hidden',
};
- }, [lastFrame, s.duration, s.from, spatialDuration, width]);
+ }, [lastFrame, s.duration, s.from, s.type, spatialDuration, width]);
const row: React.CSSProperties = useMemo(() => {
return {
diff --git a/packages/cli/src/editor/helpers/timeline-layout.ts b/packages/cli/src/editor/helpers/timeline-layout.ts
index fdb8b63049..dc54d5a7f4 100644
--- a/packages/cli/src/editor/helpers/timeline-layout.ts
+++ b/packages/cli/src/editor/helpers/timeline-layout.ts
@@ -1 +1,2 @@
export const TIMELINE_PADDING = 16;
+export const TIMELINE_LAYER_HEIGHT = 80;