Skip to content

🎥 Make videos programmatically with React

countdown design

Patric Salvisbergeef42daf5683
diff --git a/packages/docs/src/components/V4Countdown.tsx b/packages/docs/src/components/V4Countdown.tsx
new file mode 100644
index 0000000000..7a7d26e001
--- /dev/null
+++ b/packages/docs/src/components/V4Countdown.tsx
@@ -0,0 +1,85 @@
+import { useEffect } from "react";
+import React from "react";
+import { useState } from "react";
+
+const style: React.CSSProperties = {
+ display: "flex",
+ flex: 1,
+ justifyContent: "center",
+ alignItems: "center",
+};
+
+const timeWrapper: React.CSSProperties = {
+ padding: "10px",
+ borderRadius: " 15px",
+ paddingBottom: "10px",
+ display: "flex",
+ flexDirection: "column",
+ fontSize: "3em",
+ justifyContent: "center",
+ alignItems: "center",
+ fontVariantNumeric: "tabular-nums",
+};
+
+export const V4Countdown: React.FC = () => {
+ const [countdown, setCountdown] = useState<[string, string, string, string]>([
+ "00",
+ "00",
+ "00",
+ "00",
+ ]);
+
+ const targetUnixTimeStamp = 1688403600;
+
+ useEffect(() => {
+ const interval = setInterval(() => {
+ const currentCountdown = getUpdatedCountdown();
+ setCountdown(currentCountdown);
+ }, 1000);
+
+ return () => clearInterval(interval);
+ }, [countdown]);
+
+ const getUpdatedCountdown = (): [string, string, string, string] => {
+ const currentUnixTime = Math.floor(Date.now() / 1000);
+
+ const timeRemaining = targetUnixTimeStamp - currentUnixTime;
+ let remainder = 0;
+ const days = Math.floor(timeRemaining / (60 * 60 * 24));
+ remainder = timeRemaining % (60 * 60 * 24);
+ const hours = Math.floor(remainder / (60 * 60));
+ remainder %= 60 * 60;
+ const minutes = Math.floor(remainder / 60);
+ remainder %= 60;
+ const seconds = Math.floor(remainder);
+
+ const strDays = days < 10 ? "0" + days.toString() : days.toString();
+ const strHours = hours < 10 ? "0" + hours.toString() : hours.toString();
+ const strMinutes =
+ minutes < 10 ? "0" + minutes.toString() : minutes.toString();
+ const strSeconds =
+ seconds < 10 ? "0" + seconds.toString() : seconds.toString();
+
+ return [strDays, strHours, strMinutes, strSeconds];
+ };
+
+ return (
+ <div style={style}>
+ <h1 style={timeWrapper}>
+ {countdown[0]}
+ <p style={{ fontSize: "16px" }}> Days</p>
+ </h1>
+ <h1 style={timeWrapper}>
+ {countdown[1]}
+ <p style={{ fontSize: "16px" }}> Hours</p>
+ </h1>
+ <h1 style={timeWrapper}>
+ {countdown[2]}
+ <p style={{ fontSize: "16px" }}> Minutes</p>
+ </h1>
+ <h1 style={timeWrapper}>
+ {countdown[3]} <p style={{ fontSize: "16px" }}> Seconds</p>
+ </h1>
+ </div>
+ );
+};
diff --git a/packages/docs/src/pages/4/index.tsx b/packages/docs/src/pages/4/index.tsx
index f2b104dd79..bee22ca856 100644
--- a/packages/docs/src/pages/4/index.tsx
+++ b/packages/docs/src/pages/4/index.tsx
@@ -9,6 +9,7 @@ import styles from "./v4.module.css";
import { BlueButton } from "../../../components/layout/Button";
import { CoolInput } from "../../../components/TextInput";
import { Spacer } from "../../../components/layout/Spacer";
+import { V4Countdown } from "../../components/V4Countdown";
const V4: React.FC = () => {
const [email, setEmail] = useState<string>(null);
@@ -74,8 +75,11 @@ const V4: React.FC = () => {
<Head>{Seo.renderTitle("Remotion V4")}</Head>
<div className={styles.container}>
<div className={styles.wrapper}>
- <p className={styles.title}>V4 Launch</p>
+ <h1 className={styles.pagetitle}>Remotion V4 launches in</h1>
+ <V4Countdown />
+ <Spacer />
+ <Spacer />
<div className={styles.panel}>
<p>
Get a newsletter with all the imporant information when Remotion
diff --git a/packages/docs/src/pages/4/v4.module.css b/packages/docs/src/pages/4/v4.module.css
index 7957037cc1..3b1b1346a9 100644
--- a/packages/docs/src/pages/4/v4.module.css
+++ b/packages/docs/src/pages/4/v4.module.css
@@ -28,3 +28,8 @@
margin-bottom: 0;
font-weight: bold;
}
+
+.pagetitle {
+ font-size: 3em;
+ text-align: center;
+}