Skip to content

🎥 Make videos programmatically with React

Newsletter API route

Jonny Burgera9fc5c1e4c23
diff --git a/.gitignore b/.gitignore
index 8b51d44e34..3a27325834 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ packages/example/out
.pnpm-debug.log
.vscode/taskmarks.json
.turbo
+.vercel
diff --git a/package.json b/package.json
index 4084424321..fea63c8e89 100644
--- a/package.json
+++ b/package.json
@@ -16,10 +16,14 @@
"node": ">=12",
"pnpm": ">=3"
},
- "devDependencies": {},
+ "devDependencies": {
+ "@types/node": "^18.11.2"
+ },
"dependencies": {
"lerna": "^4.0.0",
- "turbo": "1.5.6"
+ "turbo": "1.5.6",
+ "@vercel/node": "^2.5.26",
+ "got": "^11"
},
"workspaces": [
"packages/*"
diff --git a/packages/docs/components/LandingPage/NewsletterButton.tsx b/packages/docs/components/LandingPage/NewsletterButton.tsx
index 9fd0d2ad7b..bdbfff320f 100644
--- a/packages/docs/components/LandingPage/NewsletterButton.tsx
+++ b/packages/docs/components/LandingPage/NewsletterButton.tsx
@@ -1,37 +1,87 @@
-import React from "react";
+import React, { useCallback, useState } from "react";
import { BlueButton } from "../layout/Button";
+import { Spacer } from "../layout/Spacer";
+import { CoolInput } from "../TextInput";
import styles from "./newsletter.module.css";
export const NewsletterButton: React.FC<{}> = () => {
+ const [email, setEmail] = useState("");
+ const [submitting, setSubmitting] = useState(false);
+ const [subscribed, setSubscribed] = useState(false);
+
+ const handleSubmit = useCallback(
+ async (e: React.FormEvent<HTMLFormElement>) => {
+ try {
+ setSubmitting(true);
+ e.preventDefault();
+
+ const response = await fetch("http://localhost:3001/api/newsletter", {
+ method: "POST",
+ body: JSON.stringify({ email }),
+ headers: {
+ "content-type": "application/json",
+ },
+ });
+ const json = await response.json();
+ if (json.success) {
+ setSubscribed(true);
+ } else {
+ // eslint-disable-next-line no-alert
+ alert("Something went wrong. Please try again later.");
+ }
+
+ setSubmitting(false);
+ } catch (err) {
+ // eslint-disable-next-line no-alert
+ alert("Something went wrong. Please try again later.");
+ }
+ },
+ [email]
+ );
+
return (
<div>
<div className={styles.newslettergrow}>
<div className={styles.portion}>
<div className={styles.panel}>
- <div
- className={[styles.tablenewsletter, styles.titlecolor].join(" ")}
- >
- Remotion Newsletter
- </div>
- <ul>
- <li>
- In our newsletter, we announce and summarize every once in a
- while new features and all noteworthy updates we have made on
- Remotion. Stay in the loop and join our newsletter.
- </li>
- </ul>
- <div style={{ flex: 1 }} />
- <a
- className={styles.newslettera}
- href="https://www.getrevue.co/profile/Remotion?via=twitter-profile"
- target="_blank"
+ <div className={[styles.tablenewsletter].join(" ")}>Newsletter</div>
+ <form
+ onSubmit={handleSubmit}
+ style={{
+ width: "100%",
+ }}
>
+ <p>
+ Read about new features and all noteworthy updates we have made
+ on Remotion once in a while.
+ </p>
+
+ <CoolInput
+ style={{
+ width: "100%",
+ }}
+ disabled={submitting}
+ fullWidth
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ type={"email"}
+ required
+ placeholder="[email protected]"
+ />
+ <Spacer />
+ <Spacer />
<div>
- <BlueButton fullWidth loading={false} size="bg">
- Subscribe
+ <BlueButton
+ type="submit"
+ fullWidth
+ loading={submitting}
+ disabled={submitting || subscribed}
+ size="bg"
+ >
+ {subscribed ? "Subscribed!" : "Subscribe"}
</BlueButton>
</div>
- </a>
+ </form>
</div>
</div>
</div>
diff --git a/packages/docs/components/LandingPage/newsletter.module.css b/packages/docs/components/LandingPage/newsletter.module.css
index cfea015e9d..5aad3a4d49 100644
--- a/packages/docs/components/LandingPage/newsletter.module.css
+++ b/packages/docs/components/LandingPage/newsletter.module.css
@@ -4,35 +4,20 @@
padding: 10px;
border-radius: 15px;
flex: 1;
- text-align: center;
- padding-top: 30px;
+
padding-bottom: 10px;
min-height: 250px;
display: flex;
flex-direction: column;
}
-.panel ul {
- text-align: center;
- list-style-type: none;
- padding-left: 0;
-}
-.panel li {
- margin-top: 12px;
- margin-bottom: 12px;
- display: flex;
- color: var(--text-color);
- font-size: 0.95em;
-}
+
.tablenewsletter {
font-size: 40px;
font-weight: 700;
- margin-top: -5px;
+ font-family: 'GT Planar';
}
-.titlecolor {
- color: #4290f5;
-}
@media screen and (max-width: 200px) {
.newslettergrow {
diff --git a/packages/docs/components/LandingPage/pricing.module.css b/packages/docs/components/LandingPage/pricing.module.css
index a3494b1db0..42ef2ebfb8 100644
--- a/packages/docs/components/LandingPage/pricing.module.css
+++ b/packages/docs/components/LandingPage/pricing.module.css
@@ -53,11 +53,11 @@
font-size: 60px;
font-weight: 700;
margin-top: -5px;
+ font-family: 'GT Planar';
}
.freeprice {
color: #4290f5;
-
}
.gradientprice {
diff --git a/packages/docs/components/TextInput.tsx b/packages/docs/components/TextInput.tsx
index 252e656dcf..2ecbdb112e 100644
--- a/packages/docs/components/TextInput.tsx
+++ b/packages/docs/components/TextInput.tsx
@@ -13,13 +13,16 @@ const inputStyle: React.CSSProperties = {
fontSize: 16,
};
-const backgroundStyle = (focused: boolean): React.CSSProperties => {
+const backgroundStyle = (
+ focused: boolean,
+ fullWidth: boolean
+): React.CSSProperties => {
return {
padding: 3,
background: focused
? `linear-gradient(to right, ${LIGHT_BLUE}, ${DARK_BLUE})`
: "rgba(0, 0, 0, 0.1)",
- display: "inline-block",
+ display: fullWidth ? "block" : "inline-block",
transition: "1s background-color",
borderRadius: 7,
overflow: "hidden",
@@ -32,9 +35,11 @@ type Props = Omit<
HTMLInputElement
>,
"onFocus" | "onBlur"
->;
+> & {
+ fullWidth?: boolean;
+};
-export const CoolInput: React.FC<Props> = ({ style, ...props }) => {
+export const CoolInput: React.FC<Props> = ({ style, fullWidth, ...props }) => {
const [focus, setFocused] = useState(false);
const onFocus = useCallback(() => {
@@ -46,7 +51,7 @@ export const CoolInput: React.FC<Props> = ({ style, ...props }) => {
}, [setFocused]);
return (
- <div style={backgroundStyle(focus)}>
+ <div style={backgroundStyle(focus, fullWidth)}>
<input
style={{ ...inputStyle, ...style }}
{...props}
diff --git a/packages/docs/package.json b/packages/docs/package.json
index efb6f4b01d..bdb3a5e396 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -5,6 +5,7 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
+ "start-docs": "docusaurus start",
"build": "tsc -d",
"build-docs": "node --max_old_space_size=16000 node_modules/@docusaurus/core/bin/docusaurus.mjs build",
"swizzle": "docusaurus swizzle",