🎥 Make videos programmatically with React
new time value
Jonny Burger20b3aea4d9c0
diff --git a/packages/studio/src/components/TimeValue.tsx b/packages/studio/src/components/TimeValue.tsxindex 4d2e49a787..903150e13d 100644--- a/packages/studio/src/components/TimeValue.tsx+++ b/packages/studio/src/components/TimeValue.tsx@@ -1,30 +1,33 @@import React from 'react';import {Internals, useCurrentFrame} from 'remotion';+import {LIGHT_TEXT} from '../helpers/colors';import {useIsStill} from '../helpers/is-current-selected-still';import {renderFrame} from '../state/render-frame';import {Spacing} from './layout';const text: React.CSSProperties = {color: 'white',- fontSize: 18,display: 'flex',flexDirection: 'row',alignItems: 'flex-end',fontVariantNumeric: 'tabular-nums',lineHeight: 1,+ width: '100%',};const time: React.CSSProperties = {display: 'inline-block',fontSize: 18,lineHeight: 1,+ fontFamily: 'monospace',};const frameStyle: React.CSSProperties = {- color: '#ccc',- fontSize: 10,+ color: LIGHT_TEXT,fontWeight: 500,lineHeight: 1,+ fontSize: 18,+ fontFamily: 'monospace',};export const TimeValue: React.FC = () => {@@ -42,10 +45,9 @@ export const TimeValue: React.FC = () => {return (<div style={text}>- <div style={time}>{renderFrame(frame, config.fps)}</div> <Spacing x={1} />- <div style={frameStyle}>- {frame} <span style={frameStyle}>({config.fps} fps)</span>- </div>+ <div style={time}>{renderFrame(frame, config.fps)}</div>+ <Spacing x={1.5} />+ <div style={frameStyle}>{frame}</div></div>);};diff --git a/packages/studio/src/components/Timeline/LoopedIndicator.tsx b/packages/studio/src/components/Timeline/LoopedIndicator.tsxindex 427d1664db..1916276123 100644--- a/packages/studio/src/components/Timeline/LoopedIndicator.tsx+++ b/packages/studio/src/components/Timeline/LoopedIndicator.tsx@@ -1,5 +1,6 @@import React from 'react';import {AbsoluteFill} from 'remotion';+import {LIGHT_COLOR} from '../../helpers/colors';const width: React.CSSProperties = {width: 30,@@ -9,24 +10,13 @@ const width: React.CSSProperties = {};const icon: React.CSSProperties = {- height: 14,- width: 14,+ height: 12,};const Icon: React.FC = () => (- <svg- aria-hidden="true"- focusable="false"- data-prefix="fas"- data-icon="repeat"- className="svg-inline--fa fa-repeat fa-w-16"- role="img"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 512 512"- style={icon}- >+ <svg viewBox="0 0 512 512" style={icon}><path- fill="currentColor"+ fill={LIGHT_COLOR}d="M512 256c0 88.224-71.775 160-160 160H170.067l34.512 32.419c9.875 9.276 10.119 24.883.539 34.464l-10.775 10.775c-9.373 9.372-24.568 9.372-33.941 0l-92.686-92.686c-9.373-9.373-9.373-24.568 0-33.941l92.686-92.686c9.373-9.373 24.568-9.373 33.941 0l10.775 10.775c9.581 9.581 9.337 25.187-.539 34.464L170.067 352H352c52.935 0 96-43.065 96-96 0-13.958-2.996-27.228-8.376-39.204-4.061-9.039-2.284-19.626 4.723-26.633l12.183-12.183c11.499-11.499 30.965-8.526 38.312 5.982C505.814 205.624 512 230.103 512 256zM72.376 295.204C66.996 283.228 64 269.958 64 256c0-52.935 43.065-96 96-96h181.933l-34.512 32.419c-9.875 9.276-10.119 24.883-.539 34.464l10.775 10.775c9.373 9.372 24.568 9.372 33.941 0l92.686-92.686c9.373-9.373 9.373-24.568 0-33.941l-92.686-92.686c-9.373-9.373-24.568-9.373-33.941 0L306.882 29.12c-9.581 9.581-9.337 25.187.539 34.464L341.933 96H160C71.775 96 0 167.776 0 256c0 25.897 6.186 50.376 17.157 72.039 7.347 14.508 26.813 17.481 38.312 5.982l12.183-12.183c7.008-7.008 8.786-17.595 4.724-26.634z"/></svg>@@ -34,16 +24,16 @@ const Icon: React.FC = () => (const topLine: React.CSSProperties = {top: 0,- height: 5,+ height: 2,width: 1,- background: 'white',+ background: LIGHT_COLOR,};const bottomLine: React.CSSProperties = {top: 0,- height: 5,+ height: 2,width: 1,- background: 'white',+ background: LIGHT_COLOR,};const topContainer: React.CSSProperties = {diff --git a/packages/studio/src/components/Timeline/TimelineList.tsx b/packages/studio/src/components/Timeline/TimelineList.tsxindex 79f2ae9bae..212304ca83 100644--- a/packages/studio/src/components/Timeline/TimelineList.tsx+++ b/packages/studio/src/components/Timeline/TimelineList.tsx@@ -1,5 +1,5 @@import React from 'react';-import {BACKGROUND, TIMELINE_TRACK_SEPARATOR} from '../../helpers/colors';+import {BACKGROUND} from '../../helpers/colors';import type {TrackWithHash} from '../../helpers/get-timeline-sequence-sort-key';import {TimelineListItem} from './TimelineListItem';import {TimelineTimePadding} from './TimelineTimeIndicators';@@ -9,19 +9,13 @@ const container: React.CSSProperties = {background: BACKGROUND,};-const topSeparator: React.CSSProperties = {- borderBottom: '1px solid ' + TIMELINE_TRACK_SEPARATOR,-};-export const TimelineList: React.FC<{timeline: TrackWithHash[];}> = ({timeline}) => {return (<div style={container}><TimelineTimePadding />- <div style={topSeparator} />- {timeline.map((track, i) => {- const beforeDepth = i === 0 ? 0 : timeline[i - 1].depth;+ {timeline.map((track) => {return (<div key={track.sequence.id}><TimelineListItem@@ -29,7 +23,6 @@ export const TimelineList: React.FC<{hash={track.hash}nestedDepth={track.depth}sequence={track.sequence}- beforeDepth={beforeDepth}/></div>);diff --git a/packages/studio/src/components/Timeline/TimelineListItem.tsx b/packages/studio/src/components/Timeline/TimelineListItem.tsxindex 99c910673d..b80f2a5f46 100644--- a/packages/studio/src/components/Timeline/TimelineListItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineListItem.tsx@@ -5,18 +5,11 @@ import {LIGHT_COLOR, TIMELINE_TRACK_SEPARATOR} from '../../helpers/colors';import {TIMELINE_ITEM_BORDER_BOTTOM,TIMELINE_LAYER_HEIGHT,- TIMELINE_PADDING,} from '../../helpers/timeline-layout';import {TimelineLayerEye} from './TimelineLayerEye';-const HOOK_WIDTH = 7;-const BORDER_BOTTOM_LEFT_RADIUS = 2;const SPACING = 5;-const TIMELINE_LAYER_PADDING = HOOK_WIDTH + SPACING;--export const TOTAL_TIMELINE_LAYER_LEFT_PADDING = TIMELINE_PADDING;-const textStyle: React.CSSProperties = {fontSize: 12,whiteSpace: 'nowrap',@@ -40,21 +33,6 @@ const outer: React.CSSProperties = {borderBottom: `1px solid ${TIMELINE_TRACK_SEPARATOR}`,};-const hookContainer: React.CSSProperties = {- height: TIMELINE_LAYER_HEIGHT,- width: HOOK_WIDTH,- position: 'relative',-};--const hook: React.CSSProperties = {- borderLeft: '1px solid #555',- borderBottom: '1px solid #555',- borderBottomLeftRadius: BORDER_BOTTOM_LEFT_RADIUS,- width: HOOK_WIDTH,- position: 'absolute',- bottom: TIMELINE_LAYER_HEIGHT / 2 - 1,-};-const space: React.CSSProperties = {width: SPACING,flexShrink: 0,@@ -63,30 +41,18 @@ const space: React.CSSProperties = {export const TimelineListItem: React.FC<{sequence: TSequence;nestedDepth: number;- beforeDepth: number;hash: string;-}> = ({nestedDepth, sequence, beforeDepth}) => {+}> = ({nestedDepth, sequence}) => {const {hidden, setHidden} = useContext(Internals.SequenceVisibilityToggleContext,);- const leftOffset = TIMELINE_LAYER_PADDING;- const hookStyle = useMemo(() => {- return {- ...hook,- height:- TIMELINE_LAYER_HEIGHT +- BORDER_BOTTOM_LEFT_RADIUS / 2 -- (beforeDepth === nestedDepth ? 2 : 12),- };- }, [beforeDepth, nestedDepth]);-const padder = useMemo((): React.CSSProperties => {return {- width: leftOffset * (nestedDepth - 1),+ width: Number(SPACING * 1.5) * nestedDepth,flexShrink: 0,};- }, [leftOffset, nestedDepth]);+ }, [nestedDepth]);const text =sequence.displayName.length > 80@@ -111,14 +77,7 @@ export const TimelineListItem: React.FC<{<div style={outer}><TimelineLayerEye hidden={isItemHidden} onClick={onToggleVisibility} /><div style={padder} />- {sequence.parent && nestedDepth > 0 ? (- <>- <div style={hookContainer}>- <div style={hookStyle} />- </div>- <div style={space} />- </>- ) : null}+ {sequence.parent && nestedDepth > 0 ? <div style={space} /> : null}<div title={text || 'Untitled'} style={textStyle}>{text || 'Untitled'}</div>diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsxindex 2427480a31..709fa6d2a7 100644--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@ -6,10 +6,7 @@ import {getTimelineSequenceLayout,SEQUENCE_BORDER_WIDTH,} from '../../helpers/get-timeline-sequence-layout';-import {- TIMELINE_ITEM_BORDER_BOTTOM,- TIMELINE_LAYER_HEIGHT,-} from '../../helpers/timeline-layout';+import {TIMELINE_LAYER_HEIGHT} from '../../helpers/timeline-layout';import {AudioWaveform} from '../AudioWaveform';import {LoopedTimelineIndicator} from './LoopedTimelineIndicators';import {TimelineSequenceFrame} from './TimelineSequenceFrame';@@ -75,7 +72,6 @@ const Inner: React.FC<{width,color: 'white',overflow: 'hidden',- marginBottom: TIMELINE_ITEM_BORDER_BOTTOM * 4,};}, [marginLeft, s.type, width]);diff --git a/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx b/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsxindex 3c570e0415..6c445c60f4 100644--- a/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx+++ b/packages/studio/src/components/Timeline/TimelineTimeIndicators.tsx@@ -4,12 +4,15 @@ import {BACKGROUND,LIGHT_TEXT,TIMELINE_BACKGROUND,+ TIMELINE_TRACK_SEPARATOR,} from '../../helpers/colors';-import {TIMELINE_PADDING} from '../../helpers/timeline-layout';+import {+ TIMELINE_ITEM_BORDER_BOTTOM,+ TIMELINE_PADDING,+} from '../../helpers/timeline-layout';import {renderFrame} from '../../state/render-frame';import {TimeValue} from '../TimeValue';import {getFrameIncrementFromWidth} from './timeline-scroll-logic';-import {TOTAL_TIMELINE_LAYER_LEFT_PADDING} from './TimelineListItem';import {TimelineWidthContext} from './TimelineWidthProvider';export const TIMELINE_TIME_INDICATOR_HEIGHT = 30;@@ -47,10 +50,11 @@ const timeValue: React.CSSProperties = {position: 'absolute',top: 0,width: '100%',- paddingLeft: TOTAL_TIMELINE_LAYER_LEFT_PADDING,+ paddingLeft: 10,display: 'flex',alignItems: 'center',backgroundColor: BACKGROUND,+ borderBottom: `${TIMELINE_ITEM_BORDER_BOTTOM}px solid ${TIMELINE_TRACK_SEPARATOR}`,};export const TimelineTimePlaceholders: React.FC = () => {