🎥 Make videos programmatically with React
cool
JonnyBurger9884b9186d07
diff --git a/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsx b/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsxnew file mode 100644index 0000000000..91c2e2a072--- /dev/null+++ b/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsx@@ -0,0 +1,53 @@+import React, {useMemo} from 'react';++const arrowButton: React.CSSProperties = {+ background: 'none',+ border: 'none',+ color: 'white',+ cursor: 'pointer',+ padding: 0,+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ width: 12,+ height: 12,+ flexShrink: 0,+ fontSize: 8,+ marginRight: 4,+ userSelect: 'none',+ outline: 'none',+ lineHeight: 1,+};++const svgStyle: React.CSSProperties = {display: 'block'};++export const TimelineExpandArrowButton: React.FC<{+ readonly isExpanded: boolean;+ readonly onClick: () => void;+ readonly label: string;+}> = ({isExpanded, onClick, label}) => {+ const style: React.CSSProperties = useMemo(() => {+ return {+ ...arrowButton,+ transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',+ };+ }, [isExpanded]);++ return (+ <button+ type="button"+ style={style}+ onClick={onClick}+ aria-expanded={isExpanded}+ aria-label={`${isExpanded ? 'Collapse' : 'Expand'} ${label}`}+ >+ <svg width="12" height="12" viewBox="0 0 8 8" style={svgStyle}>+ <path d="M2 1L6 4L2 7Z" fill="white" />+ </svg>+ </button>+ );+};++export const TimelineExpandArrowSpacer: React.FC = () => {+ return <div style={arrowButton} />;+};diff --git a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsxindex 54d9c99a89..c6b775cfd3 100644--- a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx+++ b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx@@ -19,6 +19,7 @@ import {TREE_INDENT_PER_LEVEL,} from '../../helpers/timeline-layout';import {ExpandedTracksContext} from '../ExpandedTracksProvider';+import {TimelineExpandArrowButton} from './TimelineExpandArrowButton';import {TimelineFieldRow} from './TimelineFieldRow';import {SPACING} from './TimelineListItem';@@ -36,31 +37,11 @@ const separator: React.CSSProperties = {backgroundColor: TIMELINE_TRACK_SEPARATOR,};-const arrowButtonBase: React.CSSProperties = {- background: 'none',- border: 'none',- color: 'white',- cursor: 'pointer',- padding: 0,- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- width: 12,- height: 12,- flexShrink: 0,- fontSize: 8,- marginRight: 6,- userSelect: 'none',- outline: 'none',- lineHeight: 1,-};-const groupRowBase: React.CSSProperties = {height: TREE_GROUP_ROW_HEIGHT,display: 'flex',alignItems: 'center',paddingRight: EXPANDED_SECTION_PADDING_RIGHT,- cursor: 'pointer',};const rowLabel: React.CSSProperties = {@@ -75,22 +56,6 @@ const labelOnlyRowBase: React.CSSProperties = {paddingRight: EXPANDED_SECTION_PADDING_RIGHT,};-const Arrow: React.FC<{readonly isExpanded: boolean}> = ({isExpanded}) => {- return (- <svg- width="12"- height="12"- viewBox="0 0 8 8"- style={{- display: 'block',- transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',- }}- >- <path d="M2 1L6 4L2 7Z" fill="white" />- </svg>- );-};-export const TimelineExpandedSection: React.FC<{readonly sequence: TSequence;readonly originalLocation: OriginalPosition | null;@@ -157,16 +122,12 @@ export const TimelineExpandedSection: React.FC<{if (node.kind === 'group') {const isExpanded = expandedTracks[node.id] ?? false;return (- <div- role="button"- tabIndex={0}- style={{...groupRowBase, paddingLeft}}- onClick={() => toggleTrack(node.id)}- aria-expanded={isExpanded}- >- <span style={arrowButtonBase}>- <Arrow isExpanded={isExpanded} />- </span>+ <div style={{...groupRowBase, paddingLeft}}>+ <TimelineExpandArrowButton+ isExpanded={isExpanded}+ onClick={() => toggleTrack(node.id)}+ label={node.label}+ /><span style={rowLabel}>{node.label}</span></div>);diff --git a/packages/studio/src/components/Timeline/TimelineListItem.tsx b/packages/studio/src/components/Timeline/TimelineListItem.tsxindex 4f68b2fb8b..60996d977a 100644--- a/packages/studio/src/components/Timeline/TimelineListItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineListItem.tsx@@ -12,6 +12,10 @@ import {ContextMenu} from '../ContextMenu';import {ExpandedTracksContext} from '../ExpandedTracksProvider';import type {ComboboxValue} from '../NewComposition/ComboBox';import {showNotification} from '../Notifications/NotificationCenter';+import {+ TimelineExpandArrowButton,+ TimelineExpandArrowSpacer,+} from './TimelineExpandArrowButton';import {TimelineExpandedSection} from './TimelineExpandedSection';import {TimelineLayerEye} from './TimelineLayerEye';import {TimelineStack} from './TimelineStack';@@ -25,25 +29,6 @@ const space: React.CSSProperties = {flexShrink: 0,};-const arrowButton: React.CSSProperties = {- background: 'none',- border: 'none',- color: 'white',- cursor: 'pointer',- padding: 0,- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- width: 12,- height: 12,- flexShrink: 0,- fontSize: 8,- marginRight: 4,- userSelect: 'none',- outline: 'none',- lineHeight: 1,-};-export const TimelineListItem: React.FC<{readonly sequence: TSequence;readonly nestedDepth: number;@@ -237,13 +222,6 @@ export const TimelineListItem: React.FC<{};}, [sequence.type]);- const arrowStyle: React.CSSProperties = useMemo(() => {- return {- ...arrowButton,- transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',- };- }, [isExpanded]);-const hasExpandableContent =Boolean(sequence.controls) || sequence.effects.length > 0;@@ -258,24 +236,13 @@ export const TimelineListItem: React.FC<{{sequence.parent && nestedDepth > 0 ? <div style={space} /> : null}{visualModeActive ? (hasExpandableContent ? (- <button- type="button"- style={arrowStyle}+ <TimelineExpandArrowButton+ isExpanded={isExpanded}onClick={onToggleExpand}- aria-expanded={isExpanded}- aria-label={`${isExpanded ? 'Collapse' : 'Expand'} track`}- >- <svg- width="12"- height="12"- viewBox="0 0 8 8"- style={{display: 'block'}}- >- <path d="M2 1L6 4L2 7Z" fill="white" />- </svg>- </button>+ label="track"+ />) : (- <div style={arrowButton} />+ <TimelineExpandArrowSpacer />)) : null}<TimelineStack