Skip to content

🎥 Make videos programmatically with React

countdown removed when at 0

Patric Salvisbergcd2b0fc70bcc
diff --git a/packages/docs/src/components/V4Countdown.tsx b/packages/docs/src/components/V4Countdown.tsx
index fb73822180..9895a5f38b 100644
--- a/packages/docs/src/components/V4Countdown.tsx
+++ b/packages/docs/src/components/V4Countdown.tsx
@@ -1,3 +1,4 @@
+import type { SetStateAction } from "react";
import React, { useEffect, useState } from "react";
const style: React.CSSProperties = {
@@ -32,7 +33,9 @@ const timeLabel: React.CSSProperties = {
marginBottom: 0,
};
-export const V4Countdown: React.FC = () => {
+export const V4Countdown: React.FC<{
+ setShowCountdown: React.Dispatch<SetStateAction<boolean>>;
+}> = ({ setShowCountdown }) => {
const [countdown, setCountdown] = useState<[string, string, string, string]>([
"00",
"00",
@@ -74,6 +77,10 @@ export const V4Countdown: React.FC = () => {
return [strDays, strHours, strMinutes, strSeconds];
};
+ if (Math.floor(Date.now() / 1000) > targetUnixTimeStamp) {
+ setShowCountdown(false);
+ }
+
return (
<div style={style}>
<div style={timeWrapper}>
diff --git a/packages/docs/src/pages/4/index.tsx b/packages/docs/src/pages/4/index.tsx
index 06602c02cf..301aa40b83 100644
--- a/packages/docs/src/pages/4/index.tsx
+++ b/packages/docs/src/pages/4/index.tsx
@@ -25,7 +25,7 @@ const V4: React.FC = () => {
const [loading, setLoading] = useState<boolean>(false);
const [subscribed, setSubscribed] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
-
+ const [showCountdown, setShowCountdown] = useState<boolean>(true);
const buttonLabel = useMemo(() => {
if (subscribed) {
return "You're set!";
@@ -112,23 +112,25 @@ const V4: React.FC = () => {
allowFullScreen
/>
<br />
- <div style={{ textAlign: "center" }}>
- <div>
- <V4Countdown />
- </div>
- <div>
- <a
- href="/documents/RemotionV4Launch.ics"
- download="RemotionV4Launch.ics"
- >
- <div
- className={[styles.button, styles.calendarbutton].join(" ")}
+ {showCountdown ? (
+ <div style={{ textAlign: "center" }}>
+ <div>
+ <V4Countdown setShowCountdown={setShowCountdown} />
+ </div>
+ <div>
+ <a
+ href="/documents/RemotionV4Launch.ics"
+ download="RemotionV4Launch.ics"
>
- Add to Calendar
- </div>
- </a>
+ <div
+ className={[styles.button, styles.calendarbutton].join(" ")}
+ >
+ Add to Calendar
+ </div>
+ </a>
+ </div>
</div>
- </div>
+ ) : null}
<div style={{ height: "60px" }} />
<div className={styles.grid}>