🎥 Make videos programmatically with React
rocket icon
Jonny Burger2899585d4851
diff --git a/packages/cli/src/editor/components/CompositionSelectorItem.tsx b/packages/cli/src/editor/components/CompositionSelectorItem.tsxindex 323bac3e32..4f1a41aee0 100644--- a/packages/cli/src/editor/components/CompositionSelectorItem.tsx+++ b/packages/cli/src/editor/components/CompositionSelectorItem.tsx@@ -12,6 +12,7 @@ import {FilmIcon} from '../icons/film';import {CollapsedFolderIcon, ExpandedFolderIcon} from '../icons/folder';import {StillIcon} from '../icons/still';import {Row, Spacing} from './layout';+import {COMPOSITION_ITEM_HEIGHT, RenderButton} from './RenderButton';const itemStyle: React.CSSProperties = {paddingRight: 8,@@ -28,6 +29,7 @@ const itemStyle: React.CSSProperties = {width: '100%',textAlign: 'left',backgroundColor: BACKGROUND,+ height: COMPOSITION_ITEM_HEIGHT,};const iconStyle: React.CSSProperties = {@@ -147,7 +149,7 @@ export const CompositionSelectorItem: React.FC<{}return (- <Row>+ <Row align="center"><buttonstyle={style}onPointerEnter={onPointerEnter}@@ -166,9 +168,8 @@ export const CompositionSelectorItem: React.FC<{</button>{isCompositionStill(item.composition) ? (<>- <Spacing x={1} />- <FilmIcon style={iconStyle} />- <Spacing x={1} />+ <Spacing x={0.5} />+ <RenderButton /></>) : null}</Row>diff --git a/packages/cli/src/editor/components/RenderButton.tsx b/packages/cli/src/editor/components/RenderButton.tsxnew file mode 100644index 0000000000..cc3224b38f--- /dev/null+++ b/packages/cli/src/editor/components/RenderButton.tsx@@ -0,0 +1,65 @@+import React, {useCallback, useMemo, useState} from 'react';+import {CLEAR_HOVER, LIGHT_TEXT} from '../helpers/colors';+import {RenderIcon} from '../icons/render';+import {useZIndex} from '../state/z-index';++export const COMPOSITION_ITEM_HEIGHT = 32;++const itemStyle: React.CSSProperties = {+ display: 'flex',+ cursor: 'default',+ alignItems: 'center',+ justifyContent: 'center',+ marginBottom: 1,+ appearance: 'none',+ border: 'none',+ height: COMPOSITION_ITEM_HEIGHT,+};++export const RenderButton: React.FC = () => {+ const [hovered, setHovered] = useState(false);+ const onPointerEnter = useCallback(() => {+ setHovered(true);+ }, []);++ const onPointerLeave = useCallback(() => {+ setHovered(false);+ }, []);++ const {tabIndex} = useZIndex();++ const style: React.CSSProperties = useMemo(() => {+ return {+ ...itemStyle,+ backgroundColor: hovered ? CLEAR_HOVER : 'transparent',+ color: hovered ? 'white' : LIGHT_TEXT,+ };+ }, [hovered]);++ const iconStyle: React.CSSProperties = useMemo(() => {+ return {+ height: 14,+ color: hovered ? 'white' : LIGHT_TEXT,+ };+ }, [hovered]);++ const onClick = useCallback(() => {+ console.log('tab index');+ }, []);++ return (+ <button+ style={style}+ tabIndex={tabIndex}+ onClick={onClick}+ onPointerEnter={onPointerEnter}+ onPointerLeave={onPointerLeave}+ type="button"+ >+ <RenderIcon+ svgProps={{style: iconStyle}}+ color={hovered ? 'white' : LIGHT_TEXT}+ />+ </button>+ );+};diff --git a/packages/cli/src/editor/icons/render.tsx b/packages/cli/src/editor/icons/render.tsxnew file mode 100644index 0000000000..f5a1472342--- /dev/null+++ b/packages/cli/src/editor/icons/render.tsx@@ -0,0 +1,20 @@+import type {SVGProps} from 'react';+import React from 'react';++export const RenderIcon: React.FC<{+ svgProps: SVGProps<SVGSVGElement>;+ color: string;+}> = (props) => {+ return (+ <svg+ {...props.svgProps}+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 512 512"+ >+ <path+ fill={props.color}+ d="M408 143.1C408 166.1 390.1 183.1 368 183.1C345.9 183.1 328 166.1 328 143.1C328 121.9 345.9 103.1 368 103.1C390.1 103.1 408 121.9 408 143.1zM384 312.1V394.2C384 419.7 370.6 443.2 348.7 456.2L260.2 508.6C252.8 513 243.6 513.1 236.1 508.9C228.6 504.6 224 496.6 224 488V373.3C224 350.6 215 328.1 199 312.1C183 296.1 161.4 288 138.7 288H24C15.38 288 7.414 283.4 3.146 275.9C-1.123 268.4-1.042 259.2 3.357 251.8L55.83 163.3C68.79 141.4 92.33 127.1 117.8 127.1H199.9C281.7-3.798 408.8-8.546 483.9 5.272C495.6 7.411 504.6 16.45 506.7 28.07C520.5 103.2 515.8 230.3 384 312.1V312.1zM197.9 253.9C210.8 260.2 222.6 268.7 232.1 279C243.3 289.4 251.8 301.2 258.1 314.1C363.9 284.1 414.8 234.5 439.7 188C464.7 141.3 466.1 90.47 461.7 50.33C421.5 45.02 370.7 47.34 323.1 72.33C277.5 97.16 227.9 148.1 197.9 253.9H197.9zM41.98 345.5C76.37 311.1 132.1 311.1 166.5 345.5C200.9 379.9 200.9 435.6 166.5 470C117 519.5 .4765 511.5 .4765 511.5C.4765 511.5-7.516 394.1 41.98 345.5V345.5zM64.58 447.4C64.58 447.4 103.3 450.1 119.8 433.6C131.2 422.2 131.2 403.6 119.8 392.2C108.3 380.8 89.81 380.8 78.38 392.2C61.92 408.7 64.58 447.4 64.58 447.4z"+ />+ </svg>+ );+};