Skip to content

🎥 Make videos programmatically with React

editor special case for still

Jonny Burger39e5ccabaf87
diff --git a/packages/cli/src/editor/components/CompositionSelector.tsx b/packages/cli/src/editor/components/CompositionSelector.tsx
index 337df31dbc..f244b4f95a 100644
--- a/packages/cli/src/editor/components/CompositionSelector.tsx
+++ b/packages/cli/src/editor/components/CompositionSelector.tsx
@@ -1,6 +1,9 @@
import React, {useCallback, useContext, useEffect} from 'react';
import {Internals, TComposition} from 'remotion';
import styled from 'styled-components';
+import {isCompositionStill} from '../helpers/is-composition-still';
+import {FilmIcon} from '../icons/film';
+import {StillIcon} from '../icons/still';
import {CurrentComposition} from './CurrentComposition';
import {
getCurrentCompositionFromUrl,
@@ -16,7 +19,7 @@ const Container = styled.div`
`;
const List = styled.div`
- padding: 8px;
+ padding: 5px;
height: calc(100% - 100px);
overflow-y: auto;
`;
@@ -24,20 +27,37 @@ const List = styled.div`
const Item = styled.a<{
selected: boolean;
}>`
- background: ${(props) => (props.selected ? 'white' : 'transparent')};
- color: ${(props) => (props.selected ? 'black' : 'white')};
+ background: ${(props) =>
+ props.selected ? 'rgba(255, 255, 255, 0.3)' : 'transparent'};
+ color: ${(props) => (props.selected ? 'white' : 'rgba(255, 255, 255, 0.6)')};
padding-left: 8px;
padding-right: 8px;
padding-top: 6px;
padding-bottom: 6px;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
- display: block;
+ display: flex;
border-radius: 2px;
text-decoration: none;
cursor: default;
+ align-items: center;
+ border-width: 1px;
+ border-style: solid;
+ border-color: transparent;
+ margin-bottom: 1px;
+ &:hover {
+ border-color: ${(props) =>
+ props.selected ? 'transparent' : 'rgba(255, 255, 255, 0.1)'};
+ background: ${(props) =>
+ props.selected ? 'rgba(255, 255, 255, 0.3)' : 'rgba(255, 255, 255, 0.1)'};
+ color: white;
+ }
`;
+const spacer: React.CSSProperties = {
+ width: 6,
+};
+
export const CompositionSelector: React.FC = () => {
const {compositions, setCurrentComposition, currentComposition} = useContext(
Internals.CompositionManager
@@ -89,6 +109,12 @@ export const CompositionSelector: React.FC = () => {
selectComposition(c);
}}
>
+ {isCompositionStill(c) ? (
+ <StillIcon style={{height: 18, width: 18}} />
+ ) : (
+ <FilmIcon style={{height: 18, width: 18}} />
+ )}
+ <div style={spacer} />
{c.id}
</Item>
);
diff --git a/packages/cli/src/editor/components/CurrentComposition.tsx b/packages/cli/src/editor/components/CurrentComposition.tsx
index d7156938a2..668bd10581 100644
--- a/packages/cli/src/editor/components/CurrentComposition.tsx
+++ b/packages/cli/src/editor/components/CurrentComposition.tsx
@@ -1,6 +1,7 @@
import React, {useContext} from 'react';
import {Internals} from 'remotion';
import styled from 'styled-components';
+import {isCompositionStill} from '../helpers/is-composition-still';
import {renderFrame} from '../state/render-frame';
import {RichTimelineContext} from '../state/rich-timeline';
import {Thumbnail} from './Thumbnail';
@@ -63,11 +64,16 @@ export const CurrentComposition = () => {
<div>
<Title>{video.id}</Title>
<Subtitle>
- {video.width}x{video.height}, {video.fps} FPS
- </Subtitle>
- <Subtitle>
- Duration {renderFrame(video.durationInFrames, video.fps)}
+ {video.width}x{video.height}
+ {isCompositionStill(video) ? null : `, ${video.fps} FPS`}
</Subtitle>
+ {isCompositionStill(video) ? (
+ <Subtitle>Still</Subtitle>
+ ) : (
+ <Subtitle>
+ Duration {renderFrame(video.durationInFrames, video.fps)}
+ </Subtitle>
+ )}
</div>
</Row>
</Container>
diff --git a/packages/cli/src/editor/helpers/is-composition-still.ts b/packages/cli/src/editor/helpers/is-composition-still.ts
new file mode 100644
index 0000000000..d9f1270548
--- /dev/null
+++ b/packages/cli/src/editor/helpers/is-composition-still.ts
@@ -0,0 +1,5 @@
+import {TComposition} from 'remotion';
+
+export const isCompositionStill = (comp: TComposition) => {
+ return comp.durationInFrames === 1;
+};
diff --git a/packages/cli/src/editor/icons/film.tsx b/packages/cli/src/editor/icons/film.tsx
new file mode 100644
index 0000000000..239b3d999d
--- /dev/null
+++ b/packages/cli/src/editor/icons/film.tsx
@@ -0,0 +1,12 @@
+import React, {SVGProps} from 'react';
+
+export const FilmIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {
+ return (
+ <svg viewBox="0 0 512 512" {...props}>
+ <path
+ fill="currentColor"
+ d="M488 64h-8v20c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12V64H96v20c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12V64h-8C10.7 64 0 74.7 0 88v336c0 13.3 10.7 24 24 24h8v-20c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v20h320v-20c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v20h8c13.3 0 24-10.7 24-24V88c0-13.3-10.7-24-24-24zM96 372c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm280 208c0 6.6-5.4 12-12 12H148c-6.6 0-12-5.4-12-12V124c0-6.6 5.4-12 12-12h216c6.6 0 12 5.4 12 12v264zm104-16c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40z"
+ />
+ </svg>
+ );
+};
diff --git a/packages/cli/src/editor/icons/still.tsx b/packages/cli/src/editor/icons/still.tsx
new file mode 100644
index 0000000000..49a105e7c2
--- /dev/null
+++ b/packages/cli/src/editor/icons/still.tsx
@@ -0,0 +1,12 @@
+import React, {SVGProps} from 'react';
+
+export const StillIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {
+ return (
+ <svg viewBox="0 0 512 512" {...props}>
+ <path
+ fill="currentColor"
+ d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm-6 336H54a6 6 0 0 1-6-6V118a6 6 0 0 1 6-6h404a6 6 0 0 1 6 6v276a6 6 0 0 1-6 6zM128 152c-22.091 0-40 17.909-40 40s17.909 40 40 40 40-17.909 40-40-17.909-40-40-40zM96 352h320v-80l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L192 304l-39.515-39.515c-4.686-4.686-12.284-4.686-16.971 0L96 304v48z"
+ />
+ </svg>
+ );
+};