🎥 Make videos programmatically with React
`@remotion/studio`: Distinguish expanded timeline rows (#10672)
Jonny Burgercf85a1d16136
diff --git a/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsx b/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsxindex 77a77f1c82..da1e983fdc 100644--- a/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsx+++ b/packages/studio/src/components/Timeline/TimelineExpandArrowButton.tsx@@ -1,12 +1,11 @@import React, {useMemo} from 'react';-import {LIGHT_GRAY, WHITE} from '../../helpers/colors';+import {LIGHT_GRAY, TRANSPARENT, WHITE} from '../../helpers/colors';+import {HOVERABLE_CLASS_NAME, hoverableStyle} from '../../helpers/hoverable';import {CaretDown} from '../../icons/caret';const arrowButton: React.CSSProperties = {background: 'none',border: 'none',- color: WHITE,- cursor: 'pointer',padding: 0,display: 'flex',alignItems: 'center',@@ -23,7 +22,6 @@ const arrowButton: React.CSSProperties = {const arrowSpacer: React.CSSProperties = {...arrowButton,- cursor: 'default',};export const TimelineExpandArrowButton: React.FC<{@@ -54,8 +52,13 @@ export const TimelineExpandArrowButton: React.FC<{const style: React.CSSProperties = useMemo(() => {return {...arrowButton,+ ...hoverableStyle({+ idleBackground: TRANSPARENT,+ hoverBackground: TRANSPARENT,+ idleColor: LIGHT_GRAY,+ hoverColor: disabled ? LIGHT_GRAY : WHITE,+ }),transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',- cursor: disabled ? 'default' : 'pointer',opacity: disabled ? 0.5 : 1,};}, [isExpanded, disabled]);@@ -63,6 +66,7 @@ export const TimelineExpandArrowButton: React.FC<{return (<buttontype="button"+ className={`${HOVERABLE_CLASS_NAME} __remotion-timeline-expand-arrow-button`}style={style}onClick={handleClick}onDoubleClick={stopPropagation}@@ -71,7 +75,7 @@ export const TimelineExpandArrowButton: React.FC<{aria-expanded={isExpanded}aria-label={`${isExpanded ? 'Collapse' : 'Expand'} ${label}`}>- <CaretDown color={LIGHT_GRAY} />+ <CaretDown /></button>);};diff --git a/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx b/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsxindex a33f41f404..9408fb30ca 100644--- a/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx+++ b/packages/studio/src/components/Timeline/TimelineExpandedKeyframeRow.tsx@@ -11,6 +11,7 @@ import {TimelineKeyframeDiamond} from './TimelineKeyframeDiamond';import {TimelineKeyframeEasingLine} from './TimelineKeyframeEasingLine';import {getTimelineSelectedTrackHighlightStyle,+ TIMELINE_EXPANDED_SELECTED_BACKGROUND,useTimelineRowHighlightBackground,} from './TimelineSelection';import {TimelineWidthContext} from './TimelineWidthProvider';@@ -44,8 +45,13 @@ const TimelineExpandedKeyframeRowUnmemoized: React.FC<TimelineExpandedKeyframeRowProps> = ({height, keyframes, canEditEasing, nodePathInfo, showSeparator}) => {const timelineWidth = useContext(TimelineWidthContext);- const rowHighlightBackground =- useTimelineRowHighlightBackground(nodePathInfo);+ const rowHighlightBackground = useTimelineRowHighlightBackground(+ nodePathInfo,+ {+ hovered: false,+ selectedBackground: TIMELINE_EXPANDED_SELECTED_BACKGROUND,+ },+ );const easingSegments = canEditEasing? getTimelineEasingSegments(keyframes): [];diff --git a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsxindex 393bf3e2ad..60d50a81e9 100644--- a/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx+++ b/packages/studio/src/components/Timeline/TimelineExpandedSection.tsx@@ -6,11 +6,18 @@ import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sorimport {flattenVisibleTreeNodes,getTreeRowHeight,+ TIMELINE_ITEM_BORDER_BOTTOM,} from '../../helpers/timeline-layout';import {TimelineExpandedRow} from './TimelineExpandedRow';+import {TimelineRowSelectedBackgroundContext} from './TimelineRowChrome';+import {+ TIMELINE_BACKGROUND,+ TIMELINE_EXPANDED_SELECTED_BACKGROUND,+} from './TimelineSelection';import {useTimelineExpandedTree} from './use-timeline-expanded-tree';const expandedSectionBase: React.CSSProperties = {+ backgroundColor: TIMELINE_BACKGROUND,color: WHITE,fontFamily: 'Arial, Helvetica, sans-serif',fontSize: 12,@@ -61,7 +68,7 @@ export const TimelineExpandedSection: React.FC<{const style = useMemo(() => {return {...expandedSectionBase,- height: expandedHeight,+ height: expandedHeight + TIMELINE_ITEM_BORDER_BOTTOM,};}, [expandedHeight]);@@ -72,26 +79,30 @@ export const TimelineExpandedSection: React.FC<{}return (- <div style={style}>- {flat.map(({node, depth}, i) => {- return (- <React.Fragment key={JSON.stringify(node.nodePathInfo)}>- {i > 0 ? <div style={separator} /> : null}- <TimelineExpandedRow- node={node}- depth={depth}- nestedDepth={nestedDepth}- getIsExpanded={getIsExpanded}- toggleTrack={toggleTrack}- validatedLocation={validatedLocation}- nodePath={nodePathInfo.sequenceSubscriptionKey}- schema={schema}- keyframeDisplayOffset={keyframeDisplayOffset}- keyframeControlsMode="timeline"- />- </React.Fragment>- );- })}- </div>+ <TimelineRowSelectedBackgroundContext.Provider+ value={TIMELINE_EXPANDED_SELECTED_BACKGROUND}+ >+ <div style={style}>+ {flat.map(({node, depth}, i) => {+ return (+ <React.Fragment key={JSON.stringify(node.nodePathInfo)}>+ {i > 0 ? <div style={separator} /> : null}+ <TimelineExpandedRow+ node={node}+ depth={depth}+ nestedDepth={nestedDepth}+ getIsExpanded={getIsExpanded}+ toggleTrack={toggleTrack}+ validatedLocation={validatedLocation}+ nodePath={nodePathInfo.sequenceSubscriptionKey}+ schema={schema}+ keyframeDisplayOffset={keyframeDisplayOffset}+ keyframeControlsMode="timeline"+ />+ </React.Fragment>+ );+ })}+ </div>+ </TimelineRowSelectedBackgroundContext.Provider>);};diff --git a/packages/studio/src/components/Timeline/TimelineRowChrome.tsx b/packages/studio/src/components/Timeline/TimelineRowChrome.tsxindex 1f8d9206e2..429010ed15 100644--- a/packages/studio/src/components/Timeline/TimelineRowChrome.tsx+++ b/packages/studio/src/components/Timeline/TimelineRowChrome.tsx@@ -7,7 +7,14 @@ import {} from './timeline-row-layout';import {TimelineRowLayoutContext} from './TimelineRowLayoutContext';import type {TimelineSelectionInteraction} from './TimelineSelection';-import {getTimelineRowHighlightBackground} from './TimelineSelection';+import {+ getTimelineRowHighlightBackground,+ TIMELINE_SELECTED_BACKGROUND,+} from './TimelineSelection';++export const TimelineRowSelectedBackgroundContext = React.createContext<string>(+ TIMELINE_SELECTED_BACKGROUND,+);const rowBase: React.CSSProperties = {alignItems: 'stretch',@@ -104,6 +111,7 @@ export const TimelineRowChrome: React.FC<{rowBorderRadius,rowHorizontalMargin,} = useContext(TimelineRowLayoutContext);+ const selectedBackground = useContext(TimelineRowSelectedBackgroundContext);const indentWidth = getTimelineRowIndentWidth(depth);const chromeColumnStyle = useMemo(@@ -163,6 +171,7 @@ export const TimelineRowChrome: React.FC<{selected,containsSelection,hovered,+ selectedBackground,});const innerRowStyle = useMemo(diff --git a/packages/studio/src/components/Timeline/TimelineSelection.tsx b/packages/studio/src/components/Timeline/TimelineSelection.tsxindex 606d1abb76..7a0a0a4852 100644--- a/packages/studio/src/components/Timeline/TimelineSelection.tsx+++ b/packages/studio/src/components/Timeline/TimelineSelection.tsx@@ -73,6 +73,7 @@ import {TimelineClipboardKeybindings} from './TimelineClipboardKeybindings';import {TimelineDeleteKeybindings} from './TimelineDeleteKeybindings';export const TIMELINE_SELECTED_BACKGROUND = TIMELINE_SELECTED_BACKGROUND_COLOR;+export const TIMELINE_EXPANDED_SELECTED_BACKGROUND = BACKGROUND;export const TIMELINE_HOVER_BACKGROUND = WHITE_ALPHA_05;export const TIMELINE_SELECTED_LABEL_BACKGROUND =TIMELINE_SELECTED_LABEL_BACKGROUND_COLOR;@@ -120,14 +121,16 @@ export const getTimelineRowHighlightBackground = ({selected,containsSelection,hovered,+ selectedBackground,}: {readonly showSelectedBackground: boolean;readonly selected: boolean;readonly containsSelection: boolean;readonly hovered: boolean;+ readonly selectedBackground: string;}): string | undefined => {if (showSelectedBackground && (selected || containsSelection)) {- return TIMELINE_SELECTED_BACKGROUND;+ return selectedBackground;}return hovered ? TIMELINE_HOVER_BACKGROUND : undefined;@@ -1882,7 +1885,13 @@ export const useTimelineRowContainsSelection = (export const useTimelineRowHighlightBackground = (nodePathInfo: SequenceNodePathInfo | null,- hovered = false,+ {+ hovered,+ selectedBackground,+ }: {+ readonly hovered: boolean;+ readonly selectedBackground: string;+ },): string | undefined => {const {selected} = useTimelineRowSelection(nodePathInfo);const containsSelection = useTimelineRowContainsSelection(nodePathInfo);@@ -1891,5 +1900,6 @@ export const useTimelineRowHighlightBackground = (selected,containsSelection,hovered,+ selectedBackground,});};diff --git a/packages/studio/src/components/Timeline/TimelineTrack.tsx b/packages/studio/src/components/Timeline/TimelineTrack.tsxindex 876f9d3dca..a2d629b260 100644--- a/packages/studio/src/components/Timeline/TimelineTrack.tsx+++ b/packages/studio/src/components/Timeline/TimelineTrack.tsx@@ -10,6 +10,7 @@ import {ExpandedTracksGetterContext} from '../ExpandedTracksProvider';import {TimelineExpandedTrackKeyframes} from './TimelineExpandedTrackKeyframes';import {getTimelineSelectedTrackHighlightStyle,+ TIMELINE_SELECTED_BACKGROUND,useTimelineRowHighlightBackground,} from './TimelineSelection';import {TimelineSequence} from './TimelineSequence';@@ -29,7 +30,10 @@ const TimelineTrackUnmemoized: React.FC<{);const rowHighlightBackground = useTimelineRowHighlightBackground(track.nodePathInfo,- hovered,+ {+ hovered,+ selectedBackground: TIMELINE_SELECTED_BACKGROUND,+ },);const layerStyle = useMemo(diff --git a/packages/studio/src/helpers/colors.ts b/packages/studio/src/helpers/colors.tsindex 94a7830387..6e71030a35 100644--- a/packages/studio/src/helpers/colors.ts+++ b/packages/studio/src/helpers/colors.ts@@ -65,7 +65,7 @@ export const ERROR_LINK_COLOR = '#58a6ff';export const INFO_BLUE = '#60a5fa';export const SERVER_DISCONNECTED_BACKGROUND = '#e74c3c';export const STACK_FRAME_BORDER_BLUE = 'rgb(66, 144, 245)';-export const TIMELINE_BACKGROUND_COLOR = '#0F1113';+export const TIMELINE_BACKGROUND_COLOR = '#15181B';export const TIMELINE_SELECTED_BACKGROUND_COLOR = '#3B3F42';export const TIMELINE_SELECTED_LABEL_BACKGROUND_COLOR = '#B0B0B0';export const TIMELINE_BLUE = '#0b84ff';diff --git a/packages/studio/src/helpers/inject-css.ts b/packages/studio/src/helpers/inject-css.tsindex 95490812d7..b1761a846b 100644--- a/packages/studio/src/helpers/inject-css.ts+++ b/packages/studio/src/helpers/inject-css.ts@@ -64,7 +64,7 @@ const makeDefaultGlobalCSS = () => {input:focus,textarea:focus,- button:focus:not(.__remotion_input_dragger):not(.__remotion_color_swatch):not(.__remotion-inspector-section-title),+ button:focus:not(.__remotion_input_dragger):not(.__remotion_color_swatch):not(.__remotion-inspector-section-title):not(.__remotion-timeline-expand-arrow-button),a:focus {outline: none;box-shadow: ${FOCUS_BOX_SHADOW};@@ -72,14 +72,16 @@ const makeDefaultGlobalCSS = () => {.__remotion-composition-selector-item:focus,.__remotion-inspector-quick-action:focus,- .__remotion-inspector-section-title:focus {+ .__remotion-inspector-section-title:focus,+ .__remotion-timeline-expand-arrow-button:focus {outline: none;box-shadow: none;}.__remotion-composition-selector-item:focus-visible,.__remotion-inspector-quick-action:focus-visible,- .__remotion-inspector-section-title:focus-visible {+ .__remotion-inspector-section-title:focus-visible,+ .__remotion-timeline-expand-arrow-button:focus-visible {box-shadow: ${FOCUS_BOX_SHADOW};}diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.tsindex c3a523b400..a786de345b 100644--- a/packages/studio/src/test/timeline-selection.test.ts+++ b/packages/studio/src/test/timeline-selection.test.ts@@ -123,6 +123,7 @@ import {isTimelineSelectionModifierEvent,shouldSelectTimelineRowOnPointerDown,TIMELINE_BACKGROUND,+ TIMELINE_EXPANDED_SELECTED_BACKGROUND,TIMELINE_HOVER_BACKGROUND,TIMELINE_SELECTED_BACKGROUND,TIMELINE_TICKS_BACKGROUND,@@ -3091,7 +3092,7 @@ test('Timeline from drag removes the prop at the default value', () => {});test('Timeline colors use the outlines palette', () => {- expect(TIMELINE_BACKGROUND).toBe('#0F1113');+ expect(TIMELINE_BACKGROUND).toBe('#15181B');expect(TIMELINE_TICKS_BACKGROUND).not.toBe(TIMELINE_BACKGROUND);});@@ -3102,6 +3103,7 @@ test('Timeline hover highlight is weaker than selection', () => {selected: false,containsSelection: false,hovered: true,+ selectedBackground: TIMELINE_SELECTED_BACKGROUND,}),).toBe(TIMELINE_HOVER_BACKGROUND);expect(@@ -3110,8 +3112,18 @@ test('Timeline hover highlight is weaker than selection', () => {selected: true,containsSelection: false,hovered: true,+ selectedBackground: TIMELINE_SELECTED_BACKGROUND,}),).toBe(TIMELINE_SELECTED_BACKGROUND);+ expect(+ getTimelineRowHighlightBackground({+ showSelectedBackground: true,+ selected: true,+ containsSelection: false,+ hovered: false,+ selectedBackground: TIMELINE_EXPANDED_SELECTED_BACKGROUND,+ }),+ ).toBe(TIMELINE_EXPANDED_SELECTED_BACKGROUND);});test('Timeline outlines visibility is enabled by default and persisted', () => {