Skip to content

🎥 Make videos programmatically with React

try to perfect the design

Jonny Burger662f74c9ff77
diff --git a/packages/player/src/PlayerControls.tsx b/packages/player/src/PlayerControls.tsx
index 2eef092d65..b201cd079b 100644
--- a/packages/player/src/PlayerControls.tsx
+++ b/packages/player/src/PlayerControls.tsx
@@ -1,7 +1,7 @@
import React, {MouseEventHandler, useMemo} from 'react';
import {Internals} from 'remotion';
import {formatTime} from './format-time';
-import {FullscreenExitIcon, FullscreenIcon, PauseIcon, PlayIcon} from './icons';
+import {FullscreenIcon, PauseIcon, PlayIcon} from './icons';
import {PlayerSeekBar} from './PlayerSeekBar';
import {usePlayer} from './use-player';
import {browserSupportsFullscreen} from './utils/browser-supports-fullscreen';
@@ -11,7 +11,7 @@ const containerStyle: React.CSSProperties = {
position: 'absolute',
bottom: 0,
width: '100%',
- paddingTop: 40,
+ paddingTop: 10,
paddingBottom: 10,
background: 'linear-gradient(transparent, rgba(0, 0, 0, 0.4))',
display: 'flex',
@@ -29,6 +29,7 @@ const buttonStyle: React.CSSProperties = {
padding: 0,
display: 'inline',
marginBottom: 0,
+ marginTop: 0,
height: 25,
};
@@ -37,7 +38,7 @@ const controlsRow: React.CSSProperties = {
flexDirection: 'row',
width: '100%',
alignItems: 'center',
- justifyContent: 'space-between',
+ justifyContent: 'center',
userSelect: 'none',
};
@@ -56,10 +57,12 @@ const ySpacer: React.CSSProperties = {
height: 8,
};
-const fullscreen: React.CSSProperties = {
- justifyItems: 'flex-end',
+const flex1: React.CSSProperties = {
+ flex: 1,
};
+const fullscreen: React.CSSProperties = {};
+
const timeLabel: React.CSSProperties = {
color: 'white',
fontFamily: 'sans-serif',
@@ -114,6 +117,7 @@ export const Controls: React.FC<{
{formatTime(frame / fps)} / {formatTime(durationInFrames / fps)}
</div>
</div>
+ <div style={flex1} />
{browserSupportsFullscreen && allowFullscreen ? (
<div style={fullscreen}>
<button
@@ -127,7 +131,7 @@ export const Controls: React.FC<{
: onFullscreenButtonClick
}
>
- {isFullscreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
+ <FullscreenIcon minimized={!isFullscreen} />
</button>
</div>
) : null}
diff --git a/packages/player/src/PlayerSeekBar.tsx b/packages/player/src/PlayerSeekBar.tsx
index 3cdc51364d..f080d34ce4 100644
--- a/packages/player/src/PlayerSeekBar.tsx
+++ b/packages/player/src/PlayerSeekBar.tsx
@@ -137,7 +137,10 @@ export const PlayerSeekBar: React.FC<{
position: 'absolute',
top: VERTICAL_PADDING - KNOB_SIZE / 2 + 5 / 2,
backgroundColor: 'white',
- left: (frame / durationInFrames) * ((size?.width ?? 0) - KNOB_SIZE),
+ left: Math.max(
+ -KNOB_SIZE / 2,
+ (frame / (durationInFrames - 1)) * (size?.width ?? 0) - KNOB_SIZE / 2
+ ),
boxShadow: '0 0 2px black',
opacity: Number(barHovered),
};
diff --git a/packages/player/src/icons.tsx b/packages/player/src/icons.tsx
index 4bd7810025..316768e965 100644
--- a/packages/player/src/icons.tsx
+++ b/packages/player/src/icons.tsx
@@ -1,6 +1,7 @@
import React from 'react';
const size = 25;
+const fullscreenIconSize = 16;
const rotate: React.CSSProperties = {
transform: `rotate(90deg)`,
@@ -9,12 +10,13 @@ const rotate: React.CSSProperties = {
export const PlayIcon: React.FC = () => {
return (
<svg width={size} height={size} viewBox="-100 -100 400 400" style={rotate}>
- <g stroke="#fff" strokeWidth="100" strokeLinejoin="round">
- <path
- fill="#fff"
- d="M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z"
- />
- </g>
+ <path
+ fill="#fff"
+ stroke="#fff"
+ strokeWidth="100"
+ strokeLinejoin="round"
+ d="M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z"
+ />
</svg>
);
};
@@ -28,30 +30,59 @@ export const PauseIcon: React.FC = () => {
);
};
-export const FullscreenIcon: React.FC = () => {
- return (
- <svg height={size} viewBox="0 0 24 24" width={size}>
- <path d="M0 0h24v24H0z" fill="none" />
- <path
- d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"
- fill="#fff"
- />
- </svg>
- );
-};
+export const FullscreenIcon: React.FC<{minimized: boolean}> = ({minimized}) => {
+ const strokeWidth = 6;
+ const viewSize = 32;
+
+ const out = minimized ? strokeWidth / 2 : 0;
+ const middleInset = minimized ? strokeWidth / 2 : strokeWidth * 1.6;
+ const inset = minimized ? strokeWidth * 2 : strokeWidth * 1.6;
-export const FullscreenExitIcon: React.FC = () => {
return (
<svg
- xmlns="http://www.w3.org/2000/svg"
- height={size}
- width={size}
- viewBox="0 0 24 24"
+ viewBox={`0 0 ${viewSize} ${viewSize}`}
+ height={fullscreenIconSize}
+ width={fullscreenIconSize}
>
- <path fill="none" d="M0 0h24v24H0z" />
<path
- d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"
- fill="#fff"
+ d={`
+ M ${out} ${inset}
+ L ${middleInset} ${middleInset}
+ L ${inset} ${out}
+ `}
+ stroke="#fff"
+ strokeWidth={strokeWidth}
+ fill="none"
+ />
+ <path
+ d={`
+ M ${viewSize - out} ${inset}
+ L ${viewSize - middleInset} ${middleInset}
+ L ${viewSize - inset} ${out}
+ `}
+ stroke="#fff"
+ strokeWidth={strokeWidth}
+ fill="none"
+ />
+ <path
+ d={`
+ M ${out} ${viewSize - inset}
+ L ${middleInset} ${viewSize - middleInset}
+ L ${inset} ${viewSize - out}
+ `}
+ stroke="#fff"
+ strokeWidth={strokeWidth}
+ fill="none"
+ />
+ <path
+ d={`
+ M ${viewSize - out} ${viewSize - inset}
+ L ${viewSize - middleInset} ${viewSize - middleInset}
+ L ${viewSize - inset} ${viewSize - out}
+ `}
+ stroke="#fff"
+ strokeWidth={strokeWidth}
+ fill="none"
/>
</svg>
);