Skip to content

🎥 Make videos programmatically with React

Add license confirmation before project download

Jonny Burgerf854cdce4f44
diff --git a/packages/studio/src/components/ConfigureLicenseModal.tsx b/packages/studio/src/components/ConfigureLicenseModal.tsx
index df3e4a0d32..f415419dc2 100644
--- a/packages/studio/src/components/ConfigureLicenseModal.tsx
+++ b/packages/studio/src/components/ConfigureLicenseModal.tsx
@@ -1,7 +1,8 @@
import type {ConfigUpdate} from '@remotion/studio-shared';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
-import {BLUE, LIGHT_TEXT, WHITE} from '../helpers/colors';
+import {BLUE, LIGHT_TEXT} from '../helpers/colors';
import {Spacing} from './layout';
+import {LicenseExplanation} from './LicenseExplanation';
import {
fetchLicenseKeyDetails,
hasActiveCompanyLicense,
@@ -37,18 +38,13 @@ const description: React.CSSProperties = {
margin: 0,
};
-const descriptionLink: React.CSSProperties = {
- color: WHITE,
+const externalDescriptionLink: React.CSSProperties = {
+ color: BLUE,
fontFamily: 'sans-serif',
fontSize: 14,
lineHeight: '21px',
};
-const externalDescriptionLink: React.CSSProperties = {
- ...descriptionLink,
- color: BLUE,
-};
-
const externalLinkIndicator: React.CSSProperties = {
display: 'inline-block',
height: 12,
@@ -57,60 +53,6 @@ const externalLinkIndicator: React.CSSProperties = {
width: 12,
};
-const licenseExplanation: React.CSSProperties = {
- display: 'flex',
- flexDirection: 'column',
- gap: 12,
-};
-
-const licenseExplanationRow: React.CSSProperties = {
- display: 'flex',
- alignItems: 'center',
- gap: 12,
-};
-
-const people: React.CSSProperties = {
- display: 'grid',
- gridTemplateColumns: 'repeat(4, 9px)',
- gap: 3,
- flexShrink: 0,
-};
-
-const person: React.CSSProperties = {
- display: 'block',
- height: 24,
- overflow: 'visible',
- width: 9,
-};
-
-const PersonIcon: React.FC<{
- readonly handsUp: boolean;
- readonly opacity: number;
-}> = ({handsUp, opacity}) => {
- return (
- <svg
- aria-hidden="true"
- opacity={opacity}
- style={person}
- viewBox="0 0 192 512"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- fill={LIGHT_TEXT}
- d="M128 64a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM32 64A64 64 0 1 1 160 64 64 64 0 1 1 32 64zm0 128l0 128 128 0 0-128-128 0zM0 160l192 0 0 192-32 0 0 160-32 0 0-160-64 0 0 160-32 0 0-160-32 0 0-192z"
- />
- {handsUp ? (
- <path
- d="M10.667 192 0 -32 M181.333 192 192 -32"
- fill="none"
- stroke={LIGHT_TEXT}
- strokeWidth="32"
- />
- ) : null}
- </svg>
- );
-};
-
const freeLicenseMessage: React.CSSProperties = {
...description,
marginBottom: 5,
@@ -284,46 +226,7 @@ export const LicenseSettings: React.FC = () => {
return (
<div style={container}>
<div style={content}>
- <div style={licenseExplanation}>
- <div style={licenseExplanationRow}>
- <div style={people}>
- <PersonIcon handsUp opacity={1} />
- <PersonIcon handsUp opacity={1} />
- <PersonIcon handsUp opacity={1} />
- </div>
- <p style={description}>
- Remotion is free to use if you are an individual or company of 3
- or less.
- </p>
- </div>
- <div style={licenseExplanationRow}>
- <div style={people}>
- <PersonIcon handsUp={false} opacity={1} />
- <PersonIcon handsUp={false} opacity={1} />
- <PersonIcon handsUp={false} opacity={1} />
- <PersonIcon handsUp={false} opacity={1} />
- </div>
- <p style={description}>
- If used in an organization with 4+ people, you need a{' '}
- <a style={descriptionLink} href="https://remotion.pro/license">
- Company License
- </a>
- .
- </p>
- </div>
- <div style={licenseExplanationRow}>
- <div style={people}>
- <PersonIcon handsUp={false} opacity={1} />
- <PersonIcon handsUp={false} opacity={0.3} />
- <PersonIcon handsUp={false} opacity={0.3} />
- <PersonIcon handsUp={false} opacity={0.3} />
- </div>
- <p style={description}>
- The total headcount matters, not the amount of people using
- Remotion.
- </p>
- </div>
- </div>
+ <LicenseExplanation />
<Spacing y={2} />
<div aria-label="License type" role="radiogroup">
<RadioButton
diff --git a/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx b/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
index f4d1555df6..389380508f 100644
--- a/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
@@ -15,8 +15,10 @@ import {PicIcon} from '../../icons/frame';
import {SolidIcon} from '../../icons/solid';
import {FilmIcon} from '../../icons/video';
import {VisualControlsContext} from '../../visual-controls/VisualControls';
+import {useConfirmationDialog} from '../ConfirmationDialog';
import {DefaultPropsEditor} from '../DefaultPropsEditor';
import {useZodIfPossible, useZodTypesIfPossible} from '../get-zod-if-possible';
+import {LicenseExplanation} from '../LicenseExplanation';
import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
import {showNotification} from '../Notifications/NotificationCenter';
import {ObserveDefaultPropsContext} from '../ObserveDefaultPropsContext';
@@ -60,6 +62,11 @@ const actionIconStyle: React.CSSProperties = {
width: 18,
};
+const downloadLicenseAgreement: React.CSSProperties = {
+ marginBottom: 0,
+ marginTop: 20,
+};
+
const CompositionActions: React.FC = () => {
const {
canInsertAsset,
@@ -73,12 +80,30 @@ const CompositionActions: React.FC = () => {
insertSolid,
} = useCompositionActions();
const downloadProject = getBrowserStudioOperations()?.downloadProject ?? null;
+ const confirm = useConfirmationDialog();
const onDownloadProject = useCallback(async () => {
if (downloadProject === null) {
return;
}
+ const accepted = await confirm({
+ title: 'Download project',
+ message: (
+ <>
+ <LicenseExplanation />
+ <p style={downloadLicenseAgreement}>
+ By downloading this project, you agree to comply with the license.
+ </p>
+ </>
+ ),
+ confirmLabel: 'Accept and download',
+ cancelLabel: 'Cancel',
+ });
+ if (!accepted) {
+ return;
+ }
+
try {
const {data, fileName} = await downloadProject();
const arrayBuffer = data.buffer.slice(
@@ -97,7 +122,7 @@ const CompositionActions: React.FC = () => {
2000,
);
}
- }, [downloadProject]);
+ }, [confirm, downloadProject]);
if (
!canShowInsertAsset &&
diff --git a/packages/studio/src/components/LicenseExplanation.tsx b/packages/studio/src/components/LicenseExplanation.tsx
new file mode 100644
index 0000000000..3fd5173910
--- /dev/null
+++ b/packages/studio/src/components/LicenseExplanation.tsx
@@ -0,0 +1,115 @@
+import React from 'react';
+import {LIGHT_TEXT, WHITE} from '../helpers/colors';
+
+const description: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: 1.5,
+ margin: 0,
+};
+
+const descriptionLink: React.CSSProperties = {
+ color: WHITE,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: '21px',
+};
+
+const licenseExplanation: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 12,
+};
+
+const licenseExplanationRow: React.CSSProperties = {
+ display: 'flex',
+ alignItems: 'center',
+ gap: 12,
+};
+
+const people: React.CSSProperties = {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(4, 9px)',
+ gap: 3,
+ flexShrink: 0,
+};
+
+const person: React.CSSProperties = {
+ display: 'block',
+ height: 24,
+ overflow: 'visible',
+ width: 9,
+};
+
+const PersonIcon: React.FC<{
+ readonly handsUp: boolean;
+ readonly opacity: number;
+}> = ({handsUp, opacity}) => {
+ return (
+ <svg
+ aria-hidden="true"
+ opacity={opacity}
+ style={person}
+ viewBox="0 0 192 512"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ fill={LIGHT_TEXT}
+ d="M128 64a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM32 64A64 64 0 1 1 160 64 64 64 0 1 1 32 64zm0 128l0 128 128 0 0-128-128 0zM0 160l192 0 0 192-32 0 0 160-32 0 0-160-64 0 0 160-32 0 0-160-32 0 0-192z"
+ />
+ {handsUp ? (
+ <path
+ d="M10.667 192 0 -32 M181.333 192 192 -32"
+ fill="none"
+ stroke={LIGHT_TEXT}
+ strokeWidth="32"
+ />
+ ) : null}
+ </svg>
+ );
+};
+
+export const LicenseExplanation: React.FC = () => {
+ return (
+ <div style={licenseExplanation}>
+ <div style={licenseExplanationRow}>
+ <div style={people}>
+ <PersonIcon handsUp opacity={1} />
+ <PersonIcon handsUp opacity={1} />
+ <PersonIcon handsUp opacity={1} />
+ </div>
+ <p style={description}>
+ Remotion is free to use if you are an individual or company of 3 or
+ less.
+ </p>
+ </div>
+ <div style={licenseExplanationRow}>
+ <div style={people}>
+ <PersonIcon handsUp={false} opacity={1} />
+ <PersonIcon handsUp={false} opacity={1} />
+ <PersonIcon handsUp={false} opacity={1} />
+ <PersonIcon handsUp={false} opacity={1} />
+ </div>
+ <p style={description}>
+ If used in an organization with 4+ people, you need a{' '}
+ <a style={descriptionLink} href="https://remotion.pro/license">
+ Company License
+ </a>
+ .
+ </p>
+ </div>
+ <div style={licenseExplanationRow}>
+ <div style={people}>
+ <PersonIcon handsUp={false} opacity={1} />
+ <PersonIcon handsUp={false} opacity={0.3} />
+ <PersonIcon handsUp={false} opacity={0.3} />
+ <PersonIcon handsUp={false} opacity={0.3} />
+ </div>
+ <p style={description}>
+ The total headcount matters, not the amount of people using Remotion.
+ </p>
+ </div>
+ </div>
+ );
+};