Skip to content

🎥 Make videos programmatically with React

eslint fixes

Jonny Burger7cbbda64c6cc
diff --git a/packages/create-video/src/templates.ts b/packages/create-video/src/templates.ts
index b4c24a8f55..20b9d6d257 100644
--- a/packages/create-video/src/templates.ts
+++ b/packages/create-video/src/templates.ts
@@ -10,6 +10,7 @@ export type Template = {
width: number;
height: number;
};
+ cliId: string;
};
export const FEATURED_TEMPLATES: Template[] = [
@@ -26,8 +27,8 @@ export const FEATURED_TEMPLATES: Template[] = [
height: 1080,
width: 1920,
},
+ cliId: 'hello-world',
},
-
{
homePageLabel: 'JavaScript',
shortName: 'Hello World (Javascript)',
@@ -41,6 +42,7 @@ export const FEATURED_TEMPLATES: Template[] = [
width: 1920,
height: 1080,
},
+ cliId: 'javascript',
},
{
homePageLabel: 'Blank',
@@ -55,6 +57,7 @@ export const FEATURED_TEMPLATES: Template[] = [
width: 1280,
height: 720,
},
+ cliId: 'blank',
},
{
homePageLabel: '3D',
@@ -69,6 +72,7 @@ export const FEATURED_TEMPLATES: Template[] = [
width: 1280,
height: 720,
},
+ cliId: 'three',
},
{
homePageLabel: 'Stills',
@@ -83,6 +87,7 @@ export const FEATURED_TEMPLATES: Template[] = [
height: 628,
width: 1200,
},
+ cliId: 'still',
},
{
homePageLabel: 'TTS',
@@ -97,6 +102,7 @@ export const FEATURED_TEMPLATES: Template[] = [
width: 1920,
height: 1080,
},
+ cliId: 'tts',
},
{
homePageLabel: 'Audiogram',
@@ -111,5 +117,6 @@ export const FEATURED_TEMPLATES: Template[] = [
height: 1080,
width: 1080,
},
+ cliId: 'audiogram',
},
];
diff --git a/packages/docs/src/components/ChooseTemplate.tsx b/packages/docs/src/components/ChooseTemplate.tsx
index 609485ef08..2537f7a453 100644
--- a/packages/docs/src/components/ChooseTemplate.tsx
+++ b/packages/docs/src/components/ChooseTemplate.tsx
@@ -21,7 +21,7 @@ const IconForTemplate: React.FC<{
style={{
height: 48,
}}
- ></TypeScriptIcon>
+ />
);
}
@@ -31,7 +31,7 @@ const IconForTemplate: React.FC<{
style={{
height: 36,
}}
- ></Blank>
+ />
);
}
@@ -41,16 +41,17 @@ const IconForTemplate: React.FC<{
style={{
height: 40,
}}
- ></JSIcon>
+ />
);
}
+
if (template.homePageLabel === "3D") {
return (
<Cubes
style={{
height: 36,
}}
- ></Cubes>
+ />
);
}
@@ -60,7 +61,7 @@ const IconForTemplate: React.FC<{
style={{
height: 36,
}}
- ></StillIcon>
+ />
);
}
@@ -70,16 +71,17 @@ const IconForTemplate: React.FC<{
style={{
height: 36,
}}
- ></Waveform>
+ />
);
}
+
if (template.homePageLabel === "TTS") {
return (
<TTSIcon
style={{
height: 36,
}}
- ></TTSIcon>
+ />
);
}
@@ -88,7 +90,7 @@ const IconForTemplate: React.FC<{
style={{
height: 40,
}}
- ></Blank>
+ />
);
};
@@ -118,10 +120,7 @@ export const ChooseTemplate: React.FC = () => {
}}
>
{modal ? (
- <TemplateModal
- selectedTemplate={modal}
- onDismiss={onDismiss}
- ></TemplateModal>
+ <TemplateModal selectedTemplate={modal} onDismiss={onDismiss} />
) : null}
<div style={{ flex: 1 }} />
<div
@@ -131,9 +130,10 @@ export const ChooseTemplate: React.FC = () => {
justifyContent: "center",
}}
>
- {chunks.map((c) => {
+ {chunks.map((c, i) => {
return (
<div
+ key={c.map((_) => _.cliId).join("-")}
style={{
display: "flex",
flexDirection: "row",
@@ -145,6 +145,7 @@ export const ChooseTemplate: React.FC = () => {
{c.map((template) => {
return (
<TemplateIcon
+ key={template.cliId}
onClick={() => onClick(template)}
label={template.homePageLabel}
>
diff --git a/packages/docs/src/components/CommandCopyButton.tsx b/packages/docs/src/components/CommandCopyButton.tsx
index 127028056b..85dc4099ac 100644
--- a/packages/docs/src/components/CommandCopyButton.tsx
+++ b/packages/docs/src/components/CommandCopyButton.tsx
@@ -3,32 +3,28 @@ import React from "react";
export const CommandCopyButton: React.FC<{
copied: boolean;
}> = ({ copied }) => {
- return (
- <>
- {copied ? (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 448 512"
- style={{
- height: 20,
- }}
- >
- <path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z" />
- </svg>
- ) : (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 384 512"
- style={{
- height: 20,
- }}
- >
- <path
- fill="currentColor"
- d="M320 64h-49.61C262.1 27.48 230.7 0 192 0S121 27.48 113.6 64H64C28.65 64 0 92.66 0 128v320c0 35.34 28.65 64 64 64h256c35.35 0 64-28.66 64-64V128C384 92.66 355.3 64 320 64zM192 48c13.23 0 24 10.77 24 24S205.2 96 192 96S168 85.23 168 72S178.8 48 192 48zM336 448c0 8.82-7.178 16-16 16H64c-8.822 0-16-7.18-16-16V128c0-8.82 7.178-16 16-16h18.26C80.93 117.1 80 122.4 80 128v16C80 152.8 87.16 160 96 160h192c8.836 0 16-7.164 16-16V128c0-5.559-.9316-10.86-2.264-16H320c8.822 0 16 7.18 16 16V448z"
- />
- </svg>
- )}
- </>
+ return copied ? (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 448 512"
+ style={{
+ height: 20,
+ }}
+ >
+ <path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z" />
+ </svg>
+ ) : (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 384 512"
+ style={{
+ height: 20,
+ }}
+ >
+ <path
+ fill="currentColor"
+ d="M320 64h-49.61C262.1 27.48 230.7 0 192 0S121 27.48 113.6 64H64C28.65 64 0 92.66 0 128v320c0 35.34 28.65 64 64 64h256c35.35 0 64-28.66 64-64V128C384 92.66 355.3 64 320 64zM192 48c13.23 0 24 10.77 24 24S205.2 96 192 96S168 85.23 168 72S178.8 48 192 48zM336 448c0 8.82-7.178 16-16 16H64c-8.822 0-16-7.18-16-16V128c0-8.82 7.178-16 16-16h18.26C80.93 117.1 80 122.4 80 128v16C80 152.8 87.16 160 96 160h192c8.836 0 16-7.164 16-16V128c0-5.559-.9316-10.86-2.264-16H320c8.822 0 16 7.18 16 16V448z"
+ />
+ </svg>
);
};
diff --git a/packages/docs/src/components/TemplateModal.tsx b/packages/docs/src/components/TemplateModal.tsx
index da7d846815..748bab8173 100644
--- a/packages/docs/src/components/TemplateModal.tsx
+++ b/packages/docs/src/components/TemplateModal.tsx
@@ -1,5 +1,5 @@
import { Template } from "create-video";
-import React, { useCallback, useEffect, useRef } from "react";
+import React, { useEffect, useRef } from "react";
import { TemplateModalContent } from "./TemplateModalContent";
const container: React.CSSProperties = {
@@ -35,27 +35,28 @@ export const TemplateModal: React.FC<{
return () => {
window.removeEventListener("keyup", onKeyPress);
};
- }, []);
+ }, [onDismiss]);
useEffect(() => {
const onClick = (event: MouseEvent) => {
if (inner.current.contains(event.target as Node)) {
return;
}
+
onDismiss();
};
window.addEventListener("click", onClick);
return () => window.removeEventListener("click", onClick);
- }, []);
+ }, [onDismiss]);
return (
- <div style={container} ref={outer}>
+ <div ref={outer} style={container}>
<div ref={inner}>
<TemplateModalContent
template={selectedTemplate}
onDismiss={onDismiss}
- ></TemplateModalContent>
+ />
</div>
</div>
);
diff --git a/packages/docs/src/components/TemplateModalContent.tsx b/packages/docs/src/components/TemplateModalContent.tsx
index 262859df45..ae9f27b287 100644
--- a/packages/docs/src/components/TemplateModalContent.tsx
+++ b/packages/docs/src/components/TemplateModalContent.tsx
@@ -75,7 +75,7 @@ const StackBlitzIcon: React.FC = () => {
<path
fill="currentColor"
d="M12.747 16.273h-7.46L18.925 1.5l-3.671 10.227h7.46L9.075 26.5l3.671-10.227z"
- ></path>
+ />
</svg>
);
};
@@ -163,11 +163,12 @@ export const TemplateModalContent: React.FC<{
navigator.clipboard.writeText(command);
setCopied(command);
}
- console.log(result.state);
} catch (err) {
+ // eslint-disable-next-line no-alert
alert("Copying is not supported on this device");
console.log("Could not copy command", err);
}
+
copyTimeout = setTimeout(() => {
setCopied(false);
}, 2000);
@@ -245,19 +246,17 @@ export const TemplateModalContent: React.FC<{
</svg>
</a>
</div>
- <br></br>
+ <br />
<div style={description}>{template.longerDescription}</div>
<br />
<div style={githubrow}>
<a style={link} onPointerDown={() => copyCommand("npm init video")}>
<div style={iconContainer}>
- <CommandCopyButton
- copied={copied === "npm init video"}
- ></CommandCopyButton>
+ <CommandCopyButton copied={copied === "npm init video"} />
</div>
<div style={installCommand}>npm init video</div>
</a>
- <div style={{ flex: 1 }}></div>
+ <div style={{ flex: 1 }} />
<a style={link} onPointerDown={togglePkgManagers}>
<span
style={{ whiteSpace: "pre", color: "var(--light-text-color)" }}
@@ -269,7 +268,7 @@ export const TemplateModalContent: React.FC<{
style={{
width: 8,
}}
- ></div>
+ />
</div>
{showPkgManagers ? (
<div style={githubrow}>
@@ -278,9 +277,7 @@ export const TemplateModalContent: React.FC<{
onPointerDown={() => copyCommand("pnpm create video")}
>
<div style={iconContainer}>
- <CommandCopyButton
- copied={copied === "pnpm create video"}
- ></CommandCopyButton>
+ <CommandCopyButton copied={copied === "pnpm create video"} />
</div>
<div style={installCommand}>pnpm create video</div>
</a>
@@ -294,9 +291,7 @@ export const TemplateModalContent: React.FC<{
onPointerDown={() => copyCommand("yarn create video")}
>
<div style={iconContainer}>
- <CommandCopyButton
- copied={copied === "yarn create video"}
- ></CommandCopyButton>
+ <CommandCopyButton copied={copied === "yarn create video"} />
</div>
<div style={installCommand}>yarn create video</div>
</a>
@@ -309,11 +304,11 @@ export const TemplateModalContent: React.FC<{
href={`https://github.com/${template.org}/${template.repoName}/generate`}
>
<div style={iconContainer}>
- <GithubIcon></GithubIcon>
+ <GithubIcon />
</div>{" "}
Use template
</a>
- <div style={separator}></div>
+ <div style={separator} />
<a
target={"_blank"}
style={link}
@@ -329,7 +324,7 @@ export const TemplateModalContent: React.FC<{
>
<div style={githubrow}>
<div style={iconContainer}>
- <StackBlitzIcon></StackBlitzIcon>
+ <StackBlitzIcon />
</div>
Try online{" "}
<span