diff --git a/documentation/src/components/HomepageFeatures/index.tsx b/documentation/src/components/HomepageFeatures/index.tsx index 1c921504..544b6aa6 100644 --- a/documentation/src/components/HomepageFeatures/index.tsx +++ b/documentation/src/components/HomepageFeatures/index.tsx @@ -1,4 +1,5 @@ import type { ReactNode } from "react"; +import { useEffect, useRef, useState } from "react"; import clsx from "clsx"; import Heading from "@theme/Heading"; import styles from "./styles.module.css"; @@ -164,35 +165,42 @@ function Quote({ name, github, role, testimonial }: FeatureQuote) { } export default function HomepageFeatures(): ReactNode { + const videoRef = useRef(null); + const [videoLoaded, setVideoLoaded] = useState(false); + + useEffect(() => { + const observer = new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting && !videoLoaded) { + setVideoLoaded(true); // Load video only when it first appears + } + }); + }, + { threshold: 0.5 } + ); + + if (videoRef.current) { + observer.observe(videoRef.current); + } + + return () => { + if (videoRef.current) { + observer.unobserve(videoRef.current); + } + }; + }, [videoLoaded]); + return (
-
@@ -200,28 +208,51 @@ export default function HomepageFeatures(): ReactNode { ))} - {/* inline styles in the interest of time */} -
-

- Loved by engineers -

-
+ {/* YouTube Video Section */} +
+

+ Meet Codename Goose +

+
+
+ +
+
+
+ + {/* Testimonials Section */} +
+

Loved by engineers

+
{FeatureQuotes.map((props, idx) => ( ))}